Ultimate Quiz MOD v2.0.0 (Pre-Alpha Release #1)

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

--------------------------------------------------------------------
Important notes (thank you to Lugsciath and HFScratch)
Change text field to NULL: http://forums.cricketmx.com/viewtopic.p ... 743#p96743 OR http://forums.cricketmx.com/viewtopic.p ... 741#p96741 (use only one of these solutions)
Enter the first category: http://forums.cricketmx.com/viewtopic.p ... 739#p96739
Changing the values of the minimum/maximum number of questions: http://forums.cricketmx.com/viewtopic.p ... 739#p96739
--------------------------------------------------------------------

Here is what is done:

- Submitting quizzes
- Playing quizzes
- Recording stats for quizzes

- Category view (except passwords)
- Index view
- Statistics view


I feel it's at a stage where it is usable, even if not all of the features are in yet. I still want to add the minor features (passwords for categories, minor options for the admin like playing quizzes once, not letting users play their own quizzes, Cash MOD functionality, etc) and 2 major features (ability to moderate quizzes and the ACP functions) before I release the first Beta.

For those that want to use this Pre-Alpha version, you will need to put this SQL into phpMyAdmin to create some tables and add to the config table: (I know some of my column lengths don't add up, like quiz_date being 16 in one table and 20 in another - I'm aware of this. at some point I will go back and make sure everything matches up :))
INSERT INTO `phpbb_config` (`config_name`, `config_value`, `is_dynamic`) VALUES
('quiz_submit_min', '3', 0),
('quiz_submit_max', '9', 0),
('quiz_submit_max_multiple_choice', '4', 0),
('quiz_save_enabled', '1', 0),
('quiz_show_answers', '1', 0),
('quiz_time_limit_per_question', '15', 0),
('quiz_show_how_many_stats', '5', 0);

--
-- Table structure for table `phpbb_quiz`
--

CREATE TABLE IF NOT EXISTS `phpbb_quiz` (
`quiz_id` int(5) NOT NULL auto_increment,
`quiz_author` int(5) NOT NULL default '0',
`quiz_category` int(5) NOT NULL default '0',
`quiz_name` varchar(150) NOT NULL default '',
`quiz_date` int(16) NOT NULL default '0',
`quiz_number_of_questions` int(3) NOT NULL default '0',
`quiz_views` int(5) NOT NULL default '0',
PRIMARY KEY (`quiz_id`)
);

--
-- Table structure for table `phpbb_quiz_categories`
--

CREATE TABLE IF NOT EXISTS `phpbb_quiz_categories` (
`quiz_category_id` int(11) NOT NULL auto_increment,
`quiz_category_name` varchar(150) NOT NULL default '',
`quiz_category_description` varchar(255) NOT NULL default '',
`quiz_category_password` varchar(100) NOT NULL default '',
PRIMARY KEY (`quiz_category_id`)
);

--
-- Table structure for table `phpbb_quiz_data`
--

CREATE TABLE IF NOT EXISTS `phpbb_quiz_data` (
`quiz_data_id` int(5) NOT NULL auto_increment,
`quiz_question_id` int(5) NOT NULL default '0',
`quiz_answer` varchar(255) NOT NULL default '',
`quiz_correct` int(1) NOT NULL default '0',
`quiz_uid` varchar(255) NOT NULL default '',
`quiz_bitfield` varchar(8) NOT NULL default '',
`quiz_options` mediumint(4) NOT NULL default '0',
PRIMARY KEY (`quiz_data_id`)
) ;

--
-- Table structure for table `phpbb_quiz_progressive`
--

CREATE TABLE IF NOT EXISTS `phpbb_quiz_progressive` (
`quiz_progress_id` int(5) NOT NULL auto_increment,
`quiz_id` int(5) NOT NULL default '0',
`quiz_player_id` int(10) NOT NULL default '0',
`quiz_progress_time` int(20) NOT NULL default '0',
`quiz_progress_stop_time` int(10) NOT NULL default '0',
`quiz_time_used` int(15) NOT NULL default '0',
`quiz_progress_saved` text NOT NULL,
`quiz_in_progress` int(1) NOT NULL default '0',
PRIMARY KEY (`quiz_progress_id`)
) ;

--
-- Table structure for table `phpbb_quiz_questions`
--

CREATE TABLE IF NOT EXISTS `phpbb_quiz_questions` (
`quiz_question_id` int(5) NOT NULL auto_increment,
`quiz_related_id` int(5) NOT NULL default '0',
`quiz_question` varchar(255) NOT NULL default '',
`quiz_uid` varchar(255) NOT NULL default '',
`quiz_bitfield` varchar(8) NOT NULL default '',
`quiz_options` mediumint(4) NOT NULL default '0',
PRIMARY KEY (`quiz_question_id`)
) ;

--
-- Table structure for table `phpbb_quiz_statistics`
--

CREATE TABLE IF NOT EXISTS `phpbb_quiz_statistics` (
`quiz_stats_id` int(5) NOT NULL auto_increment,
`quiz_question_id` int(5) NOT NULL default '0',
`quiz_id` int(5) NOT NULL default '0',
`quiz_answer` varchar(255) NOT NULL default '',
`quiz_correct` int(1) NOT NULL default '0',
`quiz_player` int(10) NOT NULL default '0',
PRIMARY KEY (`quiz_stats_id`)
) ;

--
-- Table structure for table `phpbb_quiz_statistics_overview`
--

CREATE TABLE IF NOT EXISTS `phpbb_quiz_statistics_overview` (
`stats_id` int(6) NOT NULL auto_increment,
`quiz_id` int(6) NOT NULL default '0',
`quiz_correct` int(2) NOT NULL default '0',
`quiz_incorrect` int(2) NOT NULL default '0',
`user_id` int(6) NOT NULL default '0',
`quiz_time` int(20) NOT NULL default '0',
PRIMARY KEY (`stats_id`)
) ;
Don't forget to change phpbb_ to something else if you use another table prefix.

In the download, simply copy the files from the directories they are in (in the zip file) to their respective directories on your forum :)

In this pre-alpha release, no files need to be edited. Obviously this will change at a later date, as the quiz link will need to be added to the header and the table constants to go into constants.php (they are in functions_quiz.php at the moment :wink: ) - but if everyone is like me, then there being no file edits for this release should be a good thing :)

In the statistics section I have started to play with classes and objects. I've never used classes within any of my MODs before so it is quite new to me. Over time I might start to make the submit quiz part of the MOD based on objects as well, as I think that could do with some simplifying!

Thanks everyone for persevering with me, I know it has taken a long time. Most of the hard work is done, I feel it is downhill from here :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

Nice one battye. Have downloaded the files and hoping to install and test everything within my test site later. ;)
If you don't ask...
User avatar
HFScratch
Greenhorn
Greenhorn
Posts: 3
Joined: Tue Mar 31, 2009 3:26 pm

Thank you battye.

Where i can download the files?
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Hi HFScratch, welcome to the forum :)
I have sent you a PM with the link.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Lugsciath
Frequent Poster
Frequent Poster
Posts: 34
Joined: Wed Nov 19, 2008 6:29 am

It works ;) ... dont forget to refresh the cache and templates ;). One little problem: For later i need more than 9 questions - a minimum of 24. How could i change that (isnt it hardcoded?). Btw: It would be better to place a inputform than a pulldownmenu.

I got a displayproblem with the german Umlauts, too -> Try äöüÄÖÜß. They are shown as ?? (utf-8?).

One more Problem: I can submit a quiz, but i cant submit a category. Without this i cant choose a quiz (categories arent shown), so i cant play. ;)

(I know, that i could correct it in the database, but other ones cant.) :)

Nice to see it work, Greetings

Uwe

BTW. Begin translations on that to german.
Lugsciath
Frequent Poster
Frequent Poster
Posts: 34
Joined: Wed Nov 19, 2008 6:29 am

Here is the missing sql code

Code: Select all

SQL-Befehl: 
INSERT INTO `phpbb_quiz_categories` ( `quiz_category_name` , `quiz_category_description` )
VALUES (
'General', 'Maincategory'
)
At least one category should exist at beginning.

if you have the same problem (Quiz without category) try this:

Code: Select all

UPDATE `phpbb_quiz` SET `quiz_category` = '1' WHERE `quiz_id` =1 LIMIT 1 ;

The number of questions could be changed in phpbb_config table

Code: Select all

('quiz_submit_min', '3', 0),
('quiz_submit_max', '9', 0),
into submit max ... 24 ;)
Lugsciath
Frequent Poster
Frequent Poster
Posts: 34
Joined: Wed Nov 19, 2008 6:29 am

uh ... a error occurs:

Code: Select all

SQL ERROR [ mysql4 ]

Field 'quiz_progress_saved' doesn't have a default value [1364]

SQL

INSERT INTO phpbb_quiz_progressive (quiz_player_id, quiz_progress_time, quiz_id, quiz_in_progress) VALUES ('3', 1242118296, 1, 1)

BACKTRACE

FILE: includes/db/mysql.php
LINE: 174
CALL: dbal->sql_error()

FILE: quiz.php
LINE: 785
CALL: dbal_mysql->sql_query()
Solutions for that?
Lugsciath
Frequent Poster
Frequent Poster
Posts: 34
Joined: Wed Nov 19, 2008 6:29 am

So, my solution/workaround is (don´t know if it is correct)

In quiz.php search

Code: Select all

	$progress_array = array(
  		'quiz_player_id'			=> $user->data['user_id'],
   		'quiz_progress_time'		=> time(),
		'quiz_id'					=> $quiz_id,
add after

Code: Select all

              'quiz_progress_saved'       => '',
Now it works well. Ähm... is a possibility there to switch the given time off?
User avatar
HFScratch
Greenhorn
Greenhorn
Posts: 3
Joined: Tue Mar 31, 2009 3:26 pm

battye wrote:Hi HFScratch, welcome to the forum :)
I have sent you a PM with the link.
I will install it now.

Thank you battye :)
User avatar
HFScratch
Greenhorn
Greenhorn
Posts: 3
Joined: Tue Mar 31, 2009 3:26 pm

Lugsciath wrote:So, my solution/workaround is (don´t know if it is correct)

In quiz.php search

Code: Select all

	$progress_array = array(
  		'quiz_player_id'			=> $user->data['user_id'],
   		'quiz_progress_time'		=> time(),
		'quiz_id'					=> $quiz_id,
add after

Code: Select all

              'quiz_progress_saved'       => '',
Yes, sometimes MySQL need to set any text field to NULL or you must send empty string to it.

To set NULL as default value for quiz_progress_saved field use this SQL:

Code: Select all

ALTER TABLE `phpbb_quiz_progressive` CHANGE `quiz_progress_saved` `quiz_progress_saved` TEXT DEFAULT NULL
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Thanks HFScratch and Lugsciath - this release is very rough around the edges (I hadn't even thought about the lack of a starting category). I have added your notes in to the first post, and Lugsciath I have added your addition to the code.
Yes, sometimes MySQL need to set any text field to NULL or you must send empty string to it.

To set NULL as default value for quiz_progress_saved field use this SQL:

Code: Select all

ALTER TABLE `phpbb_quiz_progressive` CHANGE `quiz_progress_saved` `quiz_progress_saved` TEXT DEFAULT NULL
I was not aware of that. I guess this must be specific to certain setups, otherwise I would have gotten that error. Thanks HFScratch :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Lugsciath
Frequent Poster
Frequent Poster
Posts: 34
Joined: Wed Nov 19, 2008 6:29 am

I´ve changed the amount of questions to 24. Seams to work good. So it is already useful in this early step of development to me. Very good work :) *thumbup*

Greetings

Uwe
80giga
Greenhorn
Greenhorn
Posts: 2
Joined: Thu May 07, 2009 12:38 pm

Very nice !

Yes me too can't add new category

NB. french translate begin ...
Lugsciath
Frequent Poster
Frequent Poster
Posts: 34
Joined: Wed Nov 19, 2008 6:29 am

the german language file

/language/de/mods/quiz.php

Code: Select all

<?php
/** 
*
* Ultimate Quiz MOD [English]
*
* @package language
* @version $Id: quiz.php, battye (c) 2004, 2005, 2008
* @copyright (c) 2008 battye, CricketMX.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

if (empty($lang) || !is_array($lang))
{
	$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
 'QUIZ' => 'Quiz',

	// Functions
	'SELECT_A_CATEGORY'				=> 'Wähle eine Kategorie',
	'SELECT_A_CATEGORY_EXPLAIN'		=> 'Wähle eine Kategorie welche das Genre vom Quiz am Besten trifft.',

	// Submit quiz
	'SELECT_NUMBER'					=> 'Anzahl der Fragen',
	'SELECT_NUMBER_EXPLAIN'			=> 'Du darfst zwischen <strong>%1$s</strong> und <strong>%2$s</strong> Fragen in diesem Quiz stellen. Wieviele Fragen sollen gestellt werden?',

	'SUBMIT_STEP_1'					=> 'Stufe 1 von 3 - Gib dein Quiz ein!',
	'SUBMIT_STEP_2'					=> 'Stufe 2 von 3 - Gib deine Antworten ein!',
	'SUBMIT_STEP_3'					=> 'Stufe 3 von 3 - Prüfe ob alles korrekt ist!',

	'SUBMIT_QUIZ' 					=> 'Quiz beitragen',
	'SELECT_QUIZ_NAME' 				=> 'Wähle einen Namen für dieses Quiz',
	'SELECT_QUIZ_NAME_EXPLAIN'		=> 'Das ist der Name der in der Liste der Quizze erscheint. Wähle einen Namen der kurz genug ist aber der Lesern einen Eindruck davon gibt um was es im Quiz geht.',
	'ENTER_QUESTION'				=> 'Gib deine Frage ein',
	'IS_TRUE_FALSE'					=> 'wahr oder falsch Frage',
	'MULTIPLE_CHOICE_QUESTION'		=> 'Multiple choice Frage',
	'INPUT_ANSWER_QUESTION'			=> 'Input answer Frage',
	'MULTIPLES_REVEAL'				=> 'Mehrfachrahmen',
	'NOT_TRUE_FALSE'				=> 'Trenne die Mehrfachauswahl durch Hinzufügen einer neuen Mehrfachantwort auf einer neuen Zeile. Für ein nur Eingabequiz, einfach nur eine einzige Textzeile eingeben.',
	'SUBMIT_INFORMATION'			=> 'Gib Fragen in jeder der nachfolgenden %1$s Felder ein. Für wahr und falsch Fragen, klick die Checkbox zum Beispiel - es muss dann nichts in die Box eingegeben werden. Wenn du die Fragen des Quiz eingibst, gib einfach die Antwort in die grosse Box ein. Für Mehrfachantworten musst du %2$s Alternativen eingeben, jede in einer neuen Zeile. Du wirst nach der richtigen gefragt, die du nach dem Absenden dieser Seite auswählen sollst.',
	'VERIFY_SUBMIT_INFORMATION' 	=> 'Für Mehrfachantworten wähle die richtige durch anklicken der box an der linken Seite. Für wahr und falsch Antworten wähle statt dessen wahr oder falsch. Eingabe Antworten müssen nicht geprüft werden, sie werden so genommen wie sie sind.',
	'FINAL_VERIFY_SUBMIT'			=> 'Bitte prüfe alle Eingaben, wenn alle richtig sind klicke auf Absenden unten.',
	'TRUE_FALSE_TRUE'				=> 'Wahr',
	'TRUE_FALSE_FALSE'				=> 'Falsch',
	'richtig _ANSWER'				=> 'Richtige Antwort',
	'QUIZ_SUBMISSION_SUCCESSFUL'	=> 'Dein Quiz wurde erfolgreich in die Datenbank übernommen.<br /><br />%sZurück zur Quiz Index Seite.%s',

	'OUTSIDE_QUESTION_PARAM'		=> 'Du hast keine Nummer zwischen <strong>%1$d</strong> und <strong>%2$d</strong> gewählt, geh zurück und versuche es nochmal.',
	'NUMBER_Fragen_UNDEFINED'	=> 'Die Nummer von Fragen in diesem Quiz ist nicht angegeben, bitte geh auf die vorherige Seite und korrigiere dies.',
	'TOO_MANY_CHOICES'				=> 'Eine oder mehrere von deinen Mehrfachauswahlfragen besitzt <strong>mehr als %s</strong> Auswahlmöglichkeiten! Bitte entferne darüberliegende Auswahlen.<br /><br />',
	'EMPTY_QUESTION'				=> 'Du hast eines oder mehrere Fragefelder leergelassen! Klicke den Zurückbutton in deinem Browser um auf die vorherige Seite zurückzukehren und stelle sicher das keine Felder leer gelassen werden.',
	'EMPTY_ANSWER'					=> 'Du hast eines oder mehrere Antwortfelder leergelassen. Klicke den Zurückbutton in deinem Browser um auf die vorherige Seite zurückzukehren und stelle sicher das keine Felder leer gelassen werden.',
	'EMPTY_QUIZ_FIELDS'				=> 'Du hast einige Felder leer gelassen! Stelle sicher das alle Felder richtig ausgefüllt werden.',
	'EMPTY_RADIO_BOX'				=> 'Du hast eine oder mehrere radio Auswahlen nicht ausgewählt, das bedeutet, das du immer noch eine Mehrfachauswahl und/oder wahr falsch Antwort auswählen musst, <strong>oder</strong> du hast keinen Quiznamen oder Kategorie ausgewählt.',

	// Index
	'QUIZ_PASSWORD_PROTECTED_CAT'	=> 'Ein Password wird für die Kategorie benötigt',
	'VIEW_QUIZ_CATEGORIES'			=> 'Wähle eine Kategorie',
	'NUMBER_OF_QUIZ_INDEX_SINGLE'	=> '%d Quiz',
	'NUMBER_OF_QUIZ_INDEX_PLURAL'	=> '%d Quizze',
	'NUMBER_OF_QUIZ_VIEWS_SINGLE'	=> '%d Betrachter',
	'NUMBER_OF_QUIZ_VIEWS_PLURAL'	=> '%d Betrachter',
	'QUIZ_NAME'						=> 'Quizname',
	'QUIZ_AUTHOR'					=> 'Autor',
	'QUIZ_DATE'						=> 'Beitragsdatum',
	'QUIZ_VIEWS'					=> 'Betrachtungen',

	// Play quiz
	'PLAY_QUIZ'						=> 'Spiel Quiz',
	'QUIZ_SAVE'						=> 'Sichere Quiz',
	'QUIZ_TIME_REMAINING'			=> 'Zeit verbleibend (Sekunden)',
	'QUIZ_NO_TYPE_SUBMIT'			=> 'Dieses Quiz war weder gesichert noch beigetragen',

	// Answers page
	'SHOW_RESULTS_INCORRECT '		=> 'Du antwortest<strong>%s</strong><br />Die richtige Antwort war <strong>%s</strong>',
	'SHOW_RESULTS_CORRECT '			=> 'Du antwortest richtig <strong>%s</strong>',
	'TIME_SUMMARY'					=> 'Du löstest das Quiz in <strong>%d</strong> Sekunden',
	'RESULTS_SUMMARY'				=> 'Richtige Antworten: <strong>%d</strong><br />Unrichtige Antworten: <strong>%d</strong>',
	'QUIZ_RESULTS'					=> 'Quiz Resulate',
	'QUIZ_TIME_EXCEEDED'			=> 'Du hast die erlaubte Zeit für dieses Quiz überschritten. Du brauchtest <strong>%d</strong> Sekunden. Deine Antworten wurden nicht gespeichert.',
	'QUIZ_PROGRESS_SAVED'			=> 'Dieses Quiz wurde gespeichert. Du kannst es zu einem späteren Zeitpunkt fortsetzen',
	'CHEATING_ATTEMPT'				=> 'Du siehst diese Meldung, weil eines von den folgenden Ereignissen erfolgte::<br /><br />- Ein Mogelversuch wurde festgestellt. Du kannst nicht ein Quiz verlassen und später es wieder aufnehmen ohne den Speicherprozess zu durchlaufen.<br />- Du hast versucht ein Quiz wieder beizutragen, dessen Zeitlimit ablief<br />- Du spieltest dieses Quiz schon und der Admin erlaubte keine Mehrfachversuche.',
	'MULTIPLE_SUBMISSION'			=> 'Es scheint das du versucht hast dieses Quiz mehrfach beizutragen.',

	// statistics
	'QUIZ_STATISTICS'				=> 'Quiz Statistik',
	'QUIZ_PLAYER'					=> 'Quiz Spieler',
	'QUIZ_richtig '					=> 'Richtig ',
	'QUIZ_INrichtig '				=> 'Unrichtig ',
	'QUIZ_PERCENTAGE'				=> 'Prozentzahl',

	// statistic module names
	'QUIZ_BEST_RESULTS_STATS'			=> 'Beste Resultate',
	'QUIZ_MOST_PLAYED_STATS'			=> 'Meist gespielt',
	'QUIZ_MOST_richtig _ANSWERS_STATS'	=> 'Meiste richtige Antworten',
	// 'QUIZ_HIGH_PERCENT_ANSWERS_STATS'	=> 'Höchste Prozentzahl von richtigen Antworten',
 ));
 ?>
Hint: Please use a editor like phpcoder or notepad++ for editing. Save the file in the given path, this file is utf-8 without BOM
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Lugsciath: I love Notepad++, but since converting to Mac I now use Taco editor. I really miss Notepad++ - last time I checked there was only a Windows version :(

80giga: To add the first category: http://forums.cricketmx.com/viewtopic.p ... 739#p96739 :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Post Reply