Permalink
Browse files

Can now create and re-edit all three types of questions.

Still working on grading ...
  • Loading branch information...
1 parent 2834cce commit 2a2c9725bbadd1e4391e03b54eafdab23ad18ae8 moodler committed Oct 15, 2002
Showing with 225 additions and 61 deletions.
  1. +5 −1 mod/quiz/edit.php
  2. +12 −9 mod/quiz/lib.php
  3. +19 −18 mod/quiz/multichoice.html
  4. +130 −18 mod/quiz/question.php
  5. +56 −12 mod/quiz/shortanswer.html
  6. +3 −3 mod/quiz/truefalse.html
View
@@ -90,7 +90,11 @@
$modform->grades[$key] = 1; // default score
}
}
- $modform->questions = implode(",", $questions);
+ if ($questions) {
+ $modform->questions = implode(",", $questions);
+ } else {
+ $modform->questions = "";
+ }
}
if ($delete) { /// Delete a question from the list
View
@@ -195,7 +195,7 @@ function quiz_print_question($number, $questionid, $grade, $courseid) {
if (!$options = get_record("quiz_shortanswer", "question", $question->id)) {
notify("Error: Missing question options!");
}
- echo "<P>$question->question</P>";
+ echo text_to_html($question->questiontext);
if ($question->image) {
print_file_picture($question->image, $courseid, 200);
}
@@ -218,7 +218,7 @@ function quiz_print_question($number, $questionid, $grade, $courseid) {
if (!$false->answer) {
$false->answer = get_string("false", "quiz");
}
- echo "<P>$question->question</P>";
+ echo text_to_html($question->questiontext);
if ($question->image) {
print_file_picture($question->image, $courseid, 200);
}
@@ -235,7 +235,7 @@ function quiz_print_question($number, $questionid, $grade, $courseid) {
if (!$answers = get_records_list("quiz_answers", "id", $options->answers)) {
notify("Error: Missing question answers!");
}
- echo "<P>$question->question</P>";
+ echo text_to_html($question->questiontext);
if ($question->image) {
print_file_picture($question->image, $courseid, 200);
}
@@ -286,7 +286,7 @@ function quiz_print_quiz_questions($quiz, $results=NULL) {
echo "<INPUT TYPE=hidden NAME=q VALUE=\"$quiz->id\">";
foreach ($questions as $key => $questionid) {
print_simple_box_start("CENTER", "90%");
- quiz_print_question($key+1, $questionid, $grades[$questionid]->grade, $course->id);
+ quiz_print_question($key+1, $questionid, $grades[$questionid]->grade, $quiz->course);
print_simple_box_end();
echo "<BR>";
}
@@ -577,11 +577,11 @@ function quiz_save_best_grade($quiz, $user) {
}
-function quiz_get_answer($question) {
+function quiz_get_answers($question) {
// Given a question, returns the correct answers and grades
switch ($question->type) {
case SHORTANSWER; // Could be multiple answers
- return get_records_sql("SELECT a.*, sa.case, g.grade
+ return get_records_sql("SELECT a.*, sa.usecase, g.grade
FROM quiz_shortanswer sa, quiz_answers a, quiz_question_grades g
WHERE sa.question = '$question->id'
AND sa.question = a.question
@@ -702,9 +702,12 @@ function quiz_grade_attempt_results($quiz, $questions) {
$result->sumgrades = 0;
+ global $db;
+ $db->debug=true;
+
foreach ($questions as $question) {
- if (!$answers = quiz_get_answer($question)) {
- error("No answer defined for question id $question->id!");
+ if (!$answers = quiz_get_answers($question)) {
+ error("No answers defined for question id $question->id!");
}
$grade = 0; // default
@@ -719,7 +722,7 @@ function quiz_grade_attempt_results($quiz, $questions) {
}
foreach($answers as $answer) { // There might be multiple right answers
$feedback[$answer->id] = $answer->feedback;
- if (!$answer->case) { // Don't compare case
+ if (!$answer->usecase) { // Don't compare case
$answer->answer = strtolower($answer->answer);
$question->answer = strtolower($question->answer);
}
View
@@ -16,23 +16,24 @@
<TR valign=top>
<TD align=right><P><B><? print_string("question", "quiz") ?>:</B></P></TD>
<TD>
- <textarea name="intro" rows=5 cols=50 wrap="virtual"><? p($question->question) ?></textarea>
+ <textarea name="questiontext" rows=5 cols=50 wrap="virtual"><? p($question->questiontext)?></textarea>
<? helpbutton("text", get_string("helptext")); ?>
</TD>
</TR>
<TR valign=top>
- <TD align=right><P><B><? print_string("imageaddress", "quiz") ?>:</B></P></TD>
+ <TD align=right><P><B><? print_string("imagedisplay", "quiz") ?>:</B></P></TD>
<TD>
- <INPUT type="text" name="image" size=80 value="<? p($question->image) ?>">
+ <? choose_from_menu($images, "image", "$question->image", get_string("none"),"",""); ?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("answerhowmany", "quiz") ?>:</B></P></TD>
<TD>
<?
- $options[0] = get_string("answersingleno", "quiz");
- $options[1] = get_string("answersingleyes", "quiz");
- choose_from_menu($options, "single", "$options->single", "");
+ unset($menu);
+ $menu[0] = get_string("answersingleno", "quiz");
+ $menu[1] = get_string("answersingleyes", "quiz");
+ choose_from_menu($menu, "single", "$options->single", "");
?>
</TD>
</TR>
@@ -50,14 +51,14 @@
<INPUT type="text" name="answer[]" size=50 value="<? p($answers[0]->answer) ?>">&nbsp;&nbsp;
<? print_string("grade", "quiz");
echo ":&nbsp;";
- choose_from_menu($gradeoptions, "fraction[]", "$answers[0]->fraction", ""); ?>
+ choose_from_menu($gradeoptionsfull, "fraction[]", $answers[0]->fraction, ""); ?>
<BR>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
- <textarea name="feedback" rows=2 cols=50 wrap="virtual"><? p($answers[0]->feedback) ?></textarea>
+ <textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><? p($answers[0]->feedback) ?></textarea>
</TD>
</TR>
@@ -71,14 +72,14 @@
<INPUT type="text" name="answer[]" size=50 value="<? p($answers[1]->answer) ?>">&nbsp;&nbsp;
<? print_string("grade", "quiz");
echo ":&nbsp;";
- choose_from_menu($gradeoptions, "fraction[]", "$answers[1]->fraction", ""); ?>
+ choose_from_menu($gradeoptionsfull, "fraction[]", $answers[1]->fraction, ""); ?>
<BR>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
- <textarea name="feedback" rows=2 cols=50 wrap="virtual"><? p($answers[1]->feedback) ?></textarea>
+ <textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><? p($answers[1]->feedback) ?></textarea>
</TD>
</TR>
@@ -92,14 +93,14 @@
<INPUT type="text" name="answer[]" size=50 value="<? p($answers[2]->answer) ?>">&nbsp;&nbsp;
<? print_string("grade", "quiz");
echo ":&nbsp;";
- choose_from_menu($gradeoptions, "fraction[]", "$answers[2]->fraction", ""); ?>
+ choose_from_menu($gradeoptionsfull, "fraction[]", $answers[2]->fraction, ""); ?>
<BR>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
- <textarea name="feedback" rows=2 cols=50 wrap="virtual"><? p($answers[2]->feedback) ?></textarea>
+ <textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><? p($answers[2]->feedback) ?></textarea>
</TD>
</TR>
@@ -113,14 +114,14 @@
<INPUT type="text" name="answer[]" size=50 value="<? p($answers[3]->answer) ?>">&nbsp;&nbsp;
<? print_string("grade", "quiz");
echo ":&nbsp;";
- choose_from_menu($gradeoptions, "fraction[]", "$answers[3]->fraction", ""); ?>
+ choose_from_menu($gradeoptionsfull, "fraction[]", $answers[3]->fraction, ""); ?>
<BR>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
- <textarea name="feedback" rows=2 cols=50 wrap="virtual"><? p($answers[3]->feedback) ?></textarea>
+ <textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><? p($answers[3]->feedback) ?></textarea>
</TD>
</TR>
@@ -134,14 +135,14 @@
<INPUT type="text" name="answer[]" size=50 value="<? p($answers[4]->answer) ?>">&nbsp;&nbsp;
<? print_string("grade", "quiz");
echo ":&nbsp;";
- choose_from_menu($gradeoptions, "fraction[]", "$answers[4]->fraction", ""); ?>
+ choose_from_menu($gradeoptionsfull, "fraction[]", $answers[4]->fraction, ""); ?>
<BR>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
- <textarea name="feedback" rows=2 cols=50 wrap="virtual"><? p($answers[4]->feedback) ?></textarea>
+ <textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><? p($answers[4]->feedback) ?></textarea>
</TD>
</TR>
@@ -155,14 +156,14 @@
<INPUT type="text" name="answer[]" size=50 value="<? p($answers[5]->answer) ?>">&nbsp;&nbsp;
<? print_string("grade", "quiz");
echo ":&nbsp;";
- choose_from_menu($gradeoptions, "fraction[]", "$answers[5]->fraction", ""); ?>
+ choose_from_menu($gradeoptionsfull, "fraction[]", $answers[5]->fraction, ""); ?>
<BR>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><? print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
- <textarea name="feedback" rows=2 cols=50 wrap="virtual"><? p($answers[5]->feedback) ?></textarea>
+ <textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><? p($answers[5]->feedback) ?></textarea>
</TD>
</TR>
</TABLE>
Oops, something went wrong.

0 comments on commit 2a2c972

Please sign in to comment.