fractional grades are correct.
Icons now have tooltips and are also a shortcut to editing page.
$string['feedback'] = "Feedback";
$string['filloutoneanswer'] = "You must fill out at least one possible answer. Answers left blank will not be used.";
$string['fillouttwochoices'] = "You must fill out at least two choices. Choices left blank will not be used.";
+$string['fractionsaddwrong'] = "The positive grades you have chosen do not add up to 100%%
+<BR>Instead, they add up to \$a%%
+<BR>Do you want to go back and fix this question?";
+$string['fractionsnomax'] = "One of the answers should be 100%%, so that it is
+<BR>possible to get a full grade for this question.
+<BR>Do you want to go back and fix this question?";
$string['gradeaverage'] = "Average grade";
$string['gradehighest'] = "Highest grade";
$string['grademethod'] = "Grading method";
echo "</DIV>";
}
- if ($link && (strlen($post->message) > $FORUM_LONG_POST)) {
+ if ($link && (strlen(strip_tags($post->message)) > $FORUM_LONG_POST)) {
// Print shortened version
echo format_text(forum_shorten_post($post->message), $post->format);
$numwords = count_words($post->message);
function forum_shorten_post($message) {
global $FORUM_LONG_POST, $FORUM_SHORT_POST;
- if (strlen($message) > $FORUM_LONG_POST) {
+ if (strlen(strip_tags($message)) > $FORUM_LONG_POST) {
// Look for the first return between $FORUM_SHORT_POST and $FORUM_LONG_POST
+ // XXXX
$shortmessage = substr($message, $FORUM_SHORT_POST, $FORUM_LONG_POST);
if ($pos = strpos($shortmessage, "\n")) {
return substr($message, 0, $FORUM_SHORT_POST + $pos);
function quiz_print_question_icon($question) {
// Prints a question icon
+
+ global $QUIZ_QUESTION_TYPE;
+
+ echo "<A HREF=\"question.php?id=$question->id\" TITLE=\"".$QUIZ_QUESTION_TYPE[$question->type]."\">";
switch ($question->type) {
case SHORTANSWER:
- echo "<IMG HEIGHT=16 WIDTH=16 SRC=\"pix/sa.gif\">";
+ echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/sa.gif\">";
break;
case TRUEFALSE:
- echo "<IMG HEIGHT=16 WIDTH=16 SRC=\"pix/tf.gif\">";
+ echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/tf.gif\">";
break;
case MULTICHOICE:
- echo "<IMG HEIGHT=16 WIDTH=16 SRC=\"pix/mc.gif\">";
+ echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/mc.gif\">";
break;
case RANDOM:
- echo "<IMG HEIGHT=16 WIDTH=16 SRC=\"pix/rs.gif\">";
+ echo "<IMG BORDER=0 HEIGHT=16 WIDTH=16 SRC=\"pix/rs.gif\">";
break;
}
+ echo "</A>\n";
}
function quiz_print_question($number, $questionid, $grade, $courseid,
delete_records("quiz_shortanswer", "question", $question->id);
$answers = array();
+ $maxfraction = -1;
// Insert all the new answers
foreach ($form->answer as $key => $formanswer) {
error("Could not insert quiz answer!");
}
$answers[] = $answer->id;
+ if ($fraction[$key] > $maxfraction) {
+ $maxfraction = $fraction[$key];
+ }
}
}
if (!insert_record("quiz_shortanswer", $options)) {
error("Could not insert quiz shortanswer options!");
}
+
+ /// Perform sanity checks on fractional grades
+ if ($maxfraction != 1) {
+ $maxfraction = $maxfraction * 100;
+ notice_yesno(get_string("fractionsnomax", "quiz", $maxfraction), "question.php?id=$question->id", "edit.php");
+ print_footer($course);
+ exit;
+ }
break;
case TRUEFALSE:
delete_records("quiz_answers", "question", $question->id);
delete_records("quiz_answers", "question", $question->id);
delete_records("quiz_multichoice", "question", $question->id);
+ $totalfraction = 0;
+ $maxfraction = -1;
+
$answers = array();
// Insert all the new answers
error("Could not insert quiz answer!");
}
$answers[] = $answer->id;
+
+ if ($fraction[$key] > 0) { // Sanity checks
+ $totalfraction += $fraction[$key];
+ }
+ if ($fraction[$key] > $maxfraction) {
+ $maxfraction = $fraction[$key];
+ }
}
}
if (!insert_record("quiz_multichoice", $options)) {
error("Could not insert quiz multichoice options!");
}
+
+ /// Perform sanity checks on fractional grades
+ if ($options->single) {
+ if ($maxfraction != 1) {
+ $maxfraction = $maxfraction * 100;
+ notice_yesno(get_string("fractionsnomax", "quiz", $maxfraction), "question.php?id=$question->id", "edit.php");
+ print_footer($course);
+ exit;
+ }
+ } else {
+ if ($totalfraction != 1) {
+ $totalfraction = $totalfraction * 100;
+ notice_yesno(get_string("fractionsaddwrong", "quiz", $totalfraction), "question.php?id=$question->id", "edit.php");
+ print_footer($course);
+ exit;
+ }
+ }
break;
case RANDOM:
echo "<P>Not supported yet</P>";