Created
June 27, 2009 14:36
-
-
Save igorw/137013 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -rux cache phpBB3/install/install_install.php install_quiz/install/install_install.php | |
--- phpBB3/install/install_install.php 2009-05-31 13:59:00.000000000 +0200 | |
+++ install_quiz/install/install_install.php 2009-06-27 14:39:24.000000000 +0200 | |
@@ -35,7 +35,7 @@ | |
'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), | |
'module_order' => 10, | |
'module_subs' => '', | |
- 'module_stages' => array('INTRO', 'REQUIREMENTS', 'DATABASE', 'ADMINISTRATOR', 'CONFIG_FILE', 'ADVANCED', 'CREATE_TABLE', 'FINAL'), | |
+ 'module_stages' => array('INTRO', 'QUIZ', 'REQUIREMENTS', 'DATABASE', 'ADMINISTRATOR', 'CONFIG_FILE', 'ADVANCED', 'CREATE_TABLE', 'FINAL'), | |
'module_reqs' => '' | |
); | |
} | |
@@ -65,11 +65,16 @@ | |
'BODY' => $lang['INSTALL_INTRO_BODY'], | |
'L_SUBMIT' => $lang['NEXT_STEP'], | |
'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>', | |
- 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language", | |
+ 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&sub=quiz&language=$language", | |
)); | |
break; | |
+ case 'quiz': | |
+ $this->check_user_requirements($mode, $sub); | |
+ | |
+ break; | |
+ | |
case 'requirements': | |
$this->check_server_requirements($mode, $sub); | |
@@ -116,6 +121,83 @@ | |
} | |
/** | |
+ * Checks that the user is qualified to install phpBB | |
+ */ | |
+ function check_user_requirements($mode, $sub) | |
+ { | |
+ global $lang, $template, $phpbb_root_path, $phpEx, $language; | |
+ | |
+ $this->page_title = $lang['STAGE_QUIZ']; | |
+ | |
+ $template->assign_vars(array( | |
+ 'TITLE' => $lang['QUIZ_TITLE'], | |
+ 'BODY' => $lang['QUIZ_EXPLAIN'], | |
+ )); | |
+ | |
+ // Obtain any submitted data | |
+ $data = $this->get_submitted_data(); | |
+ $quiz_sent = $data['quiz_sent']; | |
+ $quiz_answers = $data['quiz_answers']; | |
+ | |
+ foreach ($lang['QUIZ'] as $category => $questions) | |
+ { | |
+ $template->assign_block_vars('options', array( | |
+ 'S_LEGEND' => true, | |
+ 'LEGEND' => $category, | |
+ )); | |
+ | |
+ $passed = true; | |
+ | |
+ foreach ($questions as $qn => $question) | |
+ { | |
+ $answers = ''; | |
+ switch ($question[1]) | |
+ { | |
+ case 'radio': | |
+ foreach ($question[2] as $an => $answer) | |
+ { | |
+ $answer_correct = empty($answer[1]); | |
+ $answer = $answer[0]; | |
+ | |
+ $checked = ''; | |
+ if (!$quiz_sent && empty($answers) || $quiz_sent && isset($quiz_answers[$qn]) && $quiz_answers[$qn] == $an) | |
+ { | |
+ $checked = ' checked="checked"'; | |
+ } | |
+ | |
+ $wrong = ''; | |
+ if ($quiz_sent && isset($quiz_answers[$qn]) && $quiz_answers[$qn] == $an && isset($lang['QUIZ'][$category][$qn][2][$an]) && empty($lang['QUIZ'][$category][$qn][2][$an][1])) | |
+ { | |
+ $wrong = ' class="error" style="font-weight: bold"'; | |
+ $passed = false; | |
+ } | |
+ | |
+ $answers .= '<label><input type="radio" name="quiz_answers[' . $qn . ']" value="' . $an . '"' . $checked . ' /> <span' . $wrong . '>' . $answer . '</span></label><br />'; | |
+ } | |
+ break; | |
+ } | |
+ | |
+ $template->assign_block_vars('options', array( | |
+ 'KEY' => 'first', | |
+ 'TITLE' => $question[0], | |
+ 'CONTENT' => $answers, | |
+ )); | |
+ } | |
+ } | |
+ | |
+ $url = ($passed && $quiz_sent) ? $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language" : $this->p_master->module_url . "?mode=$mode&sub=quiz&language=$language "; | |
+ $submit = (!$passed && $quiz_sent) ? $lang['INSTALL_TEST'] : $lang['INSTALL_START']; | |
+ | |
+ $s_hidden_fields = '<input type="hidden" name="quiz_sent" value="1" />'; | |
+ | |
+ $template->assign_vars(array( | |
+ 'L_SUBMIT' => $submit, | |
+ 'S_HIDDEN' => $s_hidden_fields, | |
+ 'U_ACTION' => $url, | |
+ )); | |
+ } | |
+ | |
+ /** | |
* Checks that the server we are installing on meets the requirements for running phpBB | |
*/ | |
function check_server_requirements($mode, $sub) | |
@@ -512,7 +594,7 @@ | |
$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : ''; | |
$url = (!in_array(false, $passed)) ? $this->p_master->module_url . "?mode=$mode&sub=database&language=$language" : $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language "; | |
- $submit = (!in_array(false, $passed)) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST']; | |
+ $submit = (!in_array(false, $passed)) ? $lang['NEXT_STEP'] : $lang['INSTALL_TEST']; | |
$template->assign_vars(array( | |
@@ -2012,6 +2094,8 @@ | |
'server_name' => request_var('server_name', ''), | |
'server_port' => request_var('server_port', ''), | |
'script_path' => request_var('script_path', ''), | |
+ 'quiz_sent' => request_var('quiz_sent', false), | |
+ 'quiz_answers' => request_var('quiz_answers', array(0 => 0)), | |
); | |
} | |
@@ -2235,4 +2319,4 @@ | |
); | |
} | |
-?> | |
\ No newline at end of file | |
+?> | |
diff -rux cache phpBB3/language/en/install.php install_quiz/language/en/install.php | |
--- phpBB3/language/en/install.php 2009-05-31 13:59:00.000000000 +0200 | |
+++ install_quiz/language/en/install.php 2009-06-27 14:29:32.000000000 +0200 | |
@@ -627,4 +627,42 @@ | |
'TOPICS_TOPIC_TITLE' => 'Welcome to phpBB3', | |
)); | |
-?> | |
\ No newline at end of file | |
+$lang = array_merge($lang, array( | |
+ 'STAGE_QUIZ' => 'User requirements', | |
+ 'QUIZ_TITLE' => 'User requirements', | |
+ 'QUIZ_EXPLAIN' => 'Please take the following quiz to ensure that you are qualified to install phpBB.', | |
+)); | |
+ | |
+$lang['QUIZ'] = array( | |
+ 'General' => array( | |
+ array( | |
+ 'What is phpBB?', | |
+ 'radio', | |
+ array( | |
+ array('A bulletin board software written in the PHP language.', true), | |
+ array('Something else.'), | |
+ array('Something even more else.'), | |
+ ), | |
+ ), | |
+ array( | |
+ 'What is PHP?', | |
+ 'radio', | |
+ array( | |
+ array('Something else.'), | |
+ array('A programming language and enviroment used for web development.', true), | |
+ array('Something even more else.'), | |
+ ), | |
+ ), | |
+ array( | |
+ 'What is a database?', | |
+ 'radio', | |
+ array( | |
+ array('Something else.'), | |
+ array('Something even more else.'), | |
+ array('A collection of tables that contain data.', true), | |
+ ), | |
+ ), | |
+ ), | |
+); | |
+ | |
+?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment