Permalink
Browse files

New feature:

Maximum-number-of-questions-per-page
  • Loading branch information...
1 parent edb42f0 commit d70ccc495ca904789940f281655b94d9a8e8637b kaipe committed Jan 3, 2005
View
@@ -11,6 +11,7 @@
$string['addrandom2'] = 'random questions ';
$string['addselectedtoquiz'] = 'Add selected to quiz';
$string['aiken'] = 'Aiken format';
+$string['allinone'] = 'Unlimited';
$string['allowreview'] = 'Allow review';
$string['alreadysubmitted'] = 'It is likely that you have already submitted this attempt';
$string['alternativeunits'] = 'Alternative Units';
@@ -199,6 +200,7 @@
$string['questionname'] = 'Question name';
$string['questionnametoolong'] = 'Question name too long at line $a (255 char. max). It has been truncated.';
$string['questions'] = 'Questions';
+$string['questionsperpage'] = 'Max number of questions per page';
$string['quizavailable'] = 'The quiz is available until: $a';
$string['quizclose'] = 'Close the quiz';
$string['quizclosed'] = 'This quiz closed on $a';
View
@@ -165,6 +165,9 @@
} else if ('shuffleorder' == $key) {
$shuffleorder = explode(",", $value); // Actual order questions were given in
+ } else if ('navigation' == $key) {
+ $navigation = $value; // Determines next page to show in quiz
+
} else { // Useful for debugging new question types. Must be last.
error("Unrecognizable input has been posted ($key -> $value)");
}
@@ -184,13 +187,16 @@
$questions[$qid]->maxgrade = $grade->grade;
}
- if (!$result = quiz_grade_responses($quiz, $questions)) {
+ if (!$result = quiz_grade_responses($quiz, $questions, $unattempt->id)) {
error("Could not grade your quiz attempt!");
}
- if ($attempt = quiz_save_attempt($quiz, $questions, $result, $attemptnumber)) {
- add_to_log($course->id, "quiz", "submit",
+ if ($attempt = quiz_save_attempt($quiz, $questions, $result,
+ $attemptnumber, 0 == $navigation)) {
+ if (empty($navigation)) {
+ add_to_log($course->id, "quiz", "submit",
"review.php?id=$cm->id&attempt=$attempt->id", "$quiz->id", $cm->id);
+ }
} else {
notice(get_string("alreadysubmitted", "quiz"), "view.php?id=$cm->id");
if (empty($quiz->popup)) {
@@ -199,38 +205,51 @@
exit;
}
- if (! quiz_save_best_grade($quiz, $USER->id)) {
- error("Sorry! Could not calculate your best grade!");
- }
-
- if (empty($quiz->popup) and !$quiz->feedback) {
- // No need to stop on this page, go directly to view.php
- redirect('view.php?q='.$quiz->id);
- }
+ if (empty($navigation)) {
+ /// Attempt has finished
- $strgrade = get_string("grade");
- $strscore = get_string("score", "quiz");
+ if (! quiz_save_best_grade($quiz, $USER->id)) {
+ error("Sorry! Could not calculate your best grade!");
+ }
+
+ if (empty($quiz->popup) and !$quiz->feedback) {
+ // No need to stop on this page, go directly to view.php
+ redirect('view.php?q='.$quiz->id);
+ }
- if ($quiz->grade) {
- print_heading("$strscore: $result->sumgrades/$quiz->sumgrades ($result->percentage %)");
- print_heading("$strgrade: $result->grade/$quiz->grade");
- }
+ $strgrade = get_string("grade");
+ $strscore = get_string("score", "quiz");
- /// continue button - use javascript to close down child window if in popup
- include('attempt_close_js.php');
+ if ($quiz->grade) {
+ print_heading("$strscore: $result->sumgrades/$quiz->sumgrades ($result->percentage %)");
+ print_heading("$strgrade: $result->grade/$quiz->grade");
+ }
- if ($quiz->feedback) {
- $quiz->shuffleanswers = false; // Never shuffle answers in feedback
- quiz_print_quiz_questions($quiz, $questions, $result, $shuffleorder);
/// continue button - use javascript to close down child window if in popup
include('attempt_close_js.php');
- }
- if (empty($quiz->popup)) {
- print_footer($course);
- }
+ if ($quiz->feedback) {
+ $quiz->shuffleanswers = false; // Never shuffle answers in feedback
+
+ /// Make sure to get all questions in case not all are shown
+ /// in quiz all the time.
+ $questions = quiz_get_attempt_questions($quiz, $attempt);
+ quiz_print_quiz_questions($quiz, $questions,
+ quiz_grade_responses($quiz, $questions, $unattempt->id),
+ $shuffleorder);
+ /// continue button - use javascript to close down child window if in popup
+ include('attempt_close_js.php');
+ }
- exit;
+ if (empty($quiz->popup)) {
+ print_footer($course);
+ }
+
+ exit;
+ }
+ } else {
+ $navigation= 1;
+ $shuffleorder= NULL;
}
@@ -289,7 +308,7 @@
$questions = quiz_get_attempt_questions($quiz, $attempt, true);
if ($quiz->attemptonlast && $attemptnumber >= 2 and
- $quiz->attempts == 0 || !unattempt) {
+ $quiz->attempts == 0 || !$unattempt) {
// There are unlimited attempts or it is a new attempt.
// As the attempt also builds on the last, we can here
// have the student see the scores of the pre-entered
@@ -303,7 +322,8 @@
// We do not show feedback or correct answers during an attempt:
$quiz->feedback = $quiz->correctanswers = false;
- if (!quiz_print_quiz_questions($quiz, $questions, $result)) {
+ if (!quiz_print_quiz_questions($quiz, $questions,
+ $result, $shuffleorder, $navigation)) {
print_continue("view.php?id=$cm->id");
}
@@ -302,6 +302,9 @@ function quiz_upgrade($oldversion) {
table_column('quiz_categories', '', 'sortorder', '', '', '', '999');
}
+ if ($oldversion < 2005010300) {
+ table_column("quiz", "", "questionsperpage", "integer", "10", "", "0", "not null", "review");
+ }
return true;
}
@@ -26,6 +26,7 @@ CREATE TABLE `prefix_quiz` (
`correctanswers` tinyint(4) NOT NULL default '1',
`grademethod` tinyint(4) NOT NULL default '1',
`review` tinyint(4) NOT NULL default '0',
+ `questionsperpage` int(10) NOT NULL default '0',
`shufflequestions` tinyint(4) NOT NULL default '0',
`shuffleanswers` tinyint(4) NOT NULL default '0',
`questions` text NOT NULL,
@@ -275,7 +275,7 @@ function quiz_upgrade($oldversion) {
}
if ($oldversion < 2004120501) {
- table_column("quiz_calculated", "", "correctanswerformat", "integer", "10", "", "2", "not null", "correctanswerlength");
+ table_column("quiz_calculated", "", "correctanswerformat", "integer", "10", "", "0", "not null", "correctanswerlength");
}
if ($oldversion < 2004121400) { // New field to determine popup window behaviour
@@ -287,6 +287,10 @@ function quiz_upgrade($oldversion) {
table_column('quiz_categories', '', 'sortorder', '', '', '', '999');
}
+ if ($oldversion < 2005010300) {
+ table_column("quiz", "", "questionsperpage", "integer", "10", "", "0", "not null", "review");
+ }
+
return true;
}
@@ -26,6 +26,7 @@ CREATE TABLE prefix_quiz (
correctanswers integer NOT NULL default '1',
grademethod integer NOT NULL default '1',
review integer NOT NULL default '0',
+ questionsperpage integer NOT NULL default '0',
shufflequestions integer NOT NULL default '0',
shuffleanswers integer NOT NULL default '0',
questions text NOT NULL default '',
Oops, something went wrong. Retry.

0 comments on commit d70ccc4

Please sign in to comment.