error("Continue: No answers found");
}
$correctanswer = false;
- $response = get_string('defaultessayresponse', 'lesson');
foreach ($answers as $answer) {
$answerid = $answer->id;
$newpageid = $answer->jumpto;
break; // quit answer analysis immediately after a match has been found
}
}
- if (!isset($response)) { //if no feedback message provided, use default message
- if ($correctanswer) {
- $response = get_string("thatsthecorrectanswer", "lesson");
- } else {
- $response = get_string("thatsthewronganswer", "lesson");
- }
- }
$studentanswer = $useranswer;
break;
}
}
$newpageid = $answer->jumpto;
- if (!$response = trim($answer->response)) {
- if ($correctanswer) {
- $response = get_string("thatsthecorrectanswer", "lesson");
- } else {
- $response = get_string("thatsthewronganswer", "lesson");
- }
- }
+ $response = trim($answer->response);
$studentanswer = $answer->answer;
break;
}
if ((count($useranswers) == $ncorrect) and ($nhits == $ncorrect)) {
$correctanswer = true;
- if (!$response = $correctresponse) {
- $response = get_string("thatsthecorrectanswer", "lesson");
- }
+ $response = $correctresponse;
$newpageid = $correctpageid;
} else {
- if (!$response = $wrongresponse) {
- $response = get_string("thatsthewronganswer", "lesson");
- }
+ $response = $wrongresponse;
$newpageid = $wrongpageid;
}
} else {
}
}
$newpageid = $answer->jumpto;
- if (!$response = trim($answer->response)) {
- if ($correctanswer) {
- $response = get_string("thatsthecorrectanswer", "lesson");
- } else {
- $response = get_string("thatsthewronganswer", "lesson");
- }
- }
+ $response = trim($answer->response);
$studentanswer = $answer->answer;
}
break;
$userresponse = implode(",", $userresponse);
if ($ncorrect == count($answers)-2) { // dont count correct/wrong responses in the total.
- $response = get_string("thatsthecorrectanswer", "lesson");
foreach ($answers as $answer) {
if ($answer->response == NULL && $answer->answer != NULL) {
$response = $answer->answer;
}
$correctanswer = true;
} else {
- $response = get_string("thatsthewronganswer", "lesson");
$t = 0;
foreach ($answers as $answer) {
if ($answer->response == NULL && $answer->answer != NULL) {
break;
}
}
- if ($correctanswer) {
- if (!$response) {
- $response = get_string("thatsthecorrectanswer", "lesson");
- }
- } else {
- if (!$response) {
- $response = get_string("thatsthewronganswer", "lesson");
- }
- }
break;
case LESSON_BRANCHTABLE:
}
}
}
- // convert jumpto page into a proper page id
+ // TODO: merge this code with the jump code below. Convert jumpto page into a proper page id
if ($newpageid == 0) {
$newpageid = $pageid;
} elseif ($newpageid == LESSON_NEXTPAGE) {
}
}
+ // Determine default feedback if necessary
+ $nodefaultresponse = false; // Flag for redirecting when default feedback is turned off
+ if (empty($response)) {
+ if (!$lesson->feedback and !$noanswer and !($lesson->review and !$correctanswer and !$isessayquestion)) {
+ // These conditions have been met:
+ // 1. The lesson manager has not supplied feedback to the student
+ // 2. Not displaying default feedback
+ // 3. The user did provide an answer
+ // 4. We are not reviewing with an incorrect answer (and not reviewing an essay question)
+
+ $nodefaultresponse = true; // This will cause a redirect below
+ } else if ($isessayquestion) {
+ $response = get_string('defaultessayresponse', 'lesson');
+ } else if ($correctanswer) {
+ $response = get_string('thatsthecorrectanswer', 'lesson');
+ } else {
+ $response = get_string('thatsthewronganswer', 'lesson');
+ }
+ }
+
// display response (if there is one - there should be!)
// display: lesson title, page title, question text, student's answer(s) before feedback message
if ($noanswer) {
- $feedback = get_string("noanswer", "lesson");
+ $feedback = get_string('noanswer', 'lesson');
} else if ($response) {
//optionally display question page title
//if ($title = get_field("lesson_pages", "title", "id", $pageid)) {
// print_heading($title);
//}
- if ($lesson->review && !$correctanswer && !$isessayquestion) {
+ if ($lesson->review and !$correctanswer and !$isessayquestion) {
$nretakes = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id);
$qattempts = count_records("lesson_attempts", "userid", $USER->id, "retry", $nretakes, "pageid", $pageid);
if ($qattempts == 1) {
}
}
- // this is where some jump numbers are interpreted
+ // TODO: merge with the jump code above. This is where some jump numbers are interpreted
if($outoftime) {
$newpageid = LESSON_EOL; // ran out of time for the test, so go to eol
} elseif (isset($USER->modattempts[$lesson->id])) {
}
}
+ if ($nodefaultresponse) {
+ // Don't display feedback
+ redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$newpageid");
+ }
+
/// Set Messages
// This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher
fwrite ($bf,full_tag("MAXATTEMPTS",4,false,$lesson->maxattempts));
fwrite ($bf,full_tag("REVIEW",4,false,$lesson->review));
fwrite ($bf,full_tag("NEXTPAGEDEFAULT",4,false,$lesson->nextpagedefault));
+ fwrite ($bf,full_tag("FEEDBACK",4,false,$lesson->feedback));
fwrite ($bf,full_tag("MINQUESTIONS",4,false,$lesson->minquestions));
fwrite ($bf,full_tag("MAXPAGES",4,false,$lesson->maxpages));
fwrite ($bf,full_tag("TIMED",4,false,$lesson->timed));
fwrite ($bf,full_tag("MAXATTEMPTS",5,false,$default->maxattempts));
fwrite ($bf,full_tag("REVIEW",5,false,$default->review));
fwrite ($bf,full_tag("NEXTPAGEDEFAULT",5,false,$default->nextpagedefault));
+ fwrite ($bf,full_tag("FEEDBACK",5,false,$default->feedback));
fwrite ($bf,full_tag("MINQUESTIONS",5,false,$default->minquestions));
fwrite ($bf,full_tag("MAXPAGES",5,false,$default->maxpages));
fwrite ($bf,full_tag("TIMED",5,false,$default->timed));
<FIELD NAME="maxanswers" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="4" SEQUENCE="false" ENUM="false" PREVIOUS="usemaxgrade" NEXT="maxattempts"/>
<FIELD NAME="maxattempts" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="5" SEQUENCE="false" ENUM="false" PREVIOUS="maxanswers" NEXT="review"/>
<FIELD NAME="review" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="maxattempts" NEXT="nextpagedefault"/>
- <FIELD NAME="nextpagedefault" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="review" NEXT="minquestions"/>
- <FIELD NAME="minquestions" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="nextpagedefault" NEXT="maxpages"/>
+ <FIELD NAME="nextpagedefault" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="review" NEXT="feedback"/>
+ <FIELD NAME="feedback" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="nextpagedefault" NEXT="minquestions"/>
+ <FIELD NAME="minquestions" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="feedback" NEXT="maxpages"/>
<FIELD NAME="maxpages" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="minquestions" NEXT="timed"/>
<FIELD NAME="timed" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="maxpages" NEXT="maxtime"/>
<FIELD NAME="maxtime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timed" NEXT="retake"/>
<FIELD NAME="maxanswers" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="4" SEQUENCE="false" ENUM="false" PREVIOUS="usemaxgrade" NEXT="maxattempts"/>
<FIELD NAME="maxattempts" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="5" SEQUENCE="false" ENUM="false" PREVIOUS="maxanswers" NEXT="review"/>
<FIELD NAME="review" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="maxattempts" NEXT="nextpagedefault"/>
- <FIELD NAME="nextpagedefault" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="review" NEXT="minquestions"/>
- <FIELD NAME="minquestions" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="nextpagedefault" NEXT="maxpages"/>
+ <FIELD NAME="nextpagedefault" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="review" NEXT="feedback"/>
+ <FIELD NAME="feedback" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="nextpagedefault" NEXT="minquestions"/>
+ <FIELD NAME="minquestions" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="feedback" NEXT="maxpages"/>
<FIELD NAME="maxpages" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="minquestions" NEXT="timed"/>
<FIELD NAME="timed" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="maxpages" NEXT="maxtime"/>
<FIELD NAME="maxtime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timed" NEXT="retake"/>
table_column('lesson_default', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'retake');
}
+ if ($oldversion < 2006091202) {
+ table_column('lesson', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault');
+ table_column('lesson_default', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault');
+ }
+
return true;
}
`maxattempts` int(3) unsigned NOT NULL default '5',
`review` TINYINT(3) UNSIGNED NOT NULL default '0',
`nextpagedefault` int(3) unsigned NOT NULL default '0',
+ `feedback` int(3) unsigned NOT NULL default '1',
`minquestions` int(3) unsigned NOT NULL default '0',
`maxpages` int(3) unsigned NOT NULL default '0',
`timed` TINYINT(3) UNSIGNED NOT NULL default '0',
`maxattempts` int(3) unsigned NOT NULL default '5',
`review` tinyint(3) unsigned NOT NULL default '0',
`nextpagedefault` int(3) unsigned NOT NULL default '0',
+ `feedback` int(3) unsigned NOT NULL default '1',
`minquestions` tinyint(3) unsigned NOT NULL default '0',
`maxpages` int(3) unsigned NOT NULL default '0',
`timed` int(3) unsigned NOT NULL default '0',
modify_database('', 'ALTER TABLE prefix_lesson_high_scores
ALTER COLUMN userid SET DEFAULT 0');
}
+
+ if ($oldversion < 2006091202) {
+ table_column('lesson', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault');
+ table_column('lesson_default', '', 'feedback', 'int', '3', 'unsigned', '1', 'not null', 'nextpagedefault');
+ }
return true;
}
maxattempts INT NOT NULL default '5',
review INT NOT NULL DEFAULT '0',
nextpagedefault INT NOT NULL default '0',
+ feedback INT NOT NULL default '1',
minquestions INT NOT NULL default '0',
maxpages INT NOT NULL default '0',
timed INT NOT NULL DEFAULT '0',
maxattempts INT NOT NULL default '5',
review INT NOT NULL default '0',
nextpagedefault INT NOT NULL default '0',
+ feedback INT NOT NULL default '1',
minquestions INT NOT NULL default '0',
maxpages INT NOT NULL default '0',
timed INT NOT NULL default '0',
if (empty($title)) {
$title = $name;
}
-
+
$output = "<div align=\"$align\" class=\"lessonbutton $class\">\n";
$output .= "<script type=\"text/javascript\" charset=\"utf-8\">
<!--
- document.write('<a href=\"javascript: document.$form.submit();\" title=\"$title\"$id>$name</a>');
+ document.write('<a href=\"javascript: document.$form.submit();\" title=\"".addslashes($title)."\"$id>".addslashes($name)."</a>');
// -->
</script>
<noscript>
if (!isset($form->nextpagedefault)) {
$form->nextpagedefault = 0;
}
+ if (!isset($form->feedback)) {
+ $form->feedback = 1;
+ }
if (!isset($form->minquestions)) {
$form->minquestions = 0;
}
</td>
</tr>
+<tr>
+ <td align="right"><strong><?php print_string('displaydefaultfeedback', 'lesson'); ?>:</strong></td>
+ <td>
+ <?php
+ $options = array();
+ $options[0] = get_string('no'); $options[1] = get_string('yes');
+ choose_from_menu($options, 'feedback', $form->feedback, '');
+ helpbutton('feedback', get_string('displaydefaultfeedback', 'lesson'), 'lesson');
+ ?>
+ </td>
+</tr>
+
<tr valign="top">
<td align="right"><b><?php print_string("minimumnumberofquestions", "lesson") ?>:</b></td>
<td>
$lesson->maxattempts = backup_todb($info['MOD']['#']['MAXATTEMPTS']['0']['#']);
$lesson->review = backup_todb($info['MOD']['#']['REVIEW']['0']['#']);
$lesson->nextpagedefault = backup_todb($info['MOD']['#']['NEXTPAGEDEFAULT']['0']['#']);
+ $lesson->feedback = backup_todb($info['MOD']['#']['FEEDBACK']['0']['#']);
$lesson->minquestions = backup_todb($info['MOD']['#']['MINQUESTIONS']['0']['#']);
$lesson->maxpages = backup_todb($info['MOD']['#']['MAXPAGES']['0']['#']);
$lesson->timed = backup_todb($info['MOD']['#']['TIMED']['0']['#']);
$default->maxattempts = backup_todb($default_info['#']['MAXATTEMPTS']['0']['#']);
$default->review = backup_todb($default_info['#']['REVIEW']['0']['#']);
$default->nextpagedefault = backup_todb($default_info['#']['NEXTPAGEDEFAULT']['0']['#']);
+ $default->feedback = backup_todb($default_info['#']['FEEDBACK']['0']['#']);
$default->minquestions = backup_todb($default_info['#']['MINQUESTIONS']['0']['#']);
$default->maxpages = backup_todb($default_info['#']['MAXPAGES']['0']['#']);
$default->timed = backup_todb($default_info['#']['TIMED']['0']['#']);
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2006091201; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2006091202; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2006080900; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)