mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
Added display default feedback in lesson settings
Led to reducing some redundant code in action/continue.php Also, a bug fix in locallib.php for function lesson_print_submit_link (needed to add slashes or else js would break)
This commit is contained in:
parent
1032b61d3f
commit
62bb11d837
@ -65,7 +65,6 @@
|
||||
error("Continue: No answers found");
|
||||
}
|
||||
$correctanswer = false;
|
||||
$response = get_string('defaultessayresponse', 'lesson');
|
||||
foreach ($answers as $answer) {
|
||||
$answerid = $answer->id;
|
||||
$newpageid = $answer->jumpto;
|
||||
@ -181,13 +180,6 @@
|
||||
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;
|
||||
|
||||
@ -211,13 +203,7 @@
|
||||
}
|
||||
}
|
||||
$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;
|
||||
|
||||
@ -318,14 +304,10 @@
|
||||
}
|
||||
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 {
|
||||
@ -349,13 +331,7 @@
|
||||
}
|
||||
}
|
||||
$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;
|
||||
@ -409,7 +385,6 @@
|
||||
$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;
|
||||
@ -424,7 +399,6 @@
|
||||
}
|
||||
$correctanswer = true;
|
||||
} else {
|
||||
$response = get_string("thatsthewronganswer", "lesson");
|
||||
$t = 0;
|
||||
foreach ($answers as $answer) {
|
||||
if ($answer->response == NULL && $answer->answer != NULL) {
|
||||
@ -483,15 +457,6 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($correctanswer) {
|
||||
if (!$response) {
|
||||
$response = get_string("thatsthecorrectanswer", "lesson");
|
||||
}
|
||||
} else {
|
||||
if (!$response) {
|
||||
$response = get_string("thatsthewronganswer", "lesson");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LESSON_BRANCHTABLE:
|
||||
@ -600,7 +565,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
@ -653,17 +618,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
@ -689,7 +674,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 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])) {
|
||||
@ -756,6 +741,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -83,6 +83,7 @@
|
||||
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));
|
||||
@ -405,6 +406,7 @@
|
||||
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));
|
||||
|
@ -19,8 +19,9 @@
|
||||
<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"/>
|
||||
@ -145,8 +146,9 @@
|
||||
<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"/>
|
||||
|
@ -231,6 +231,11 @@ function lesson_upgrade($oldversion) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ CREATE TABLE `prefix_lesson` (
|
||||
`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',
|
||||
@ -131,6 +132,7 @@ CREATE TABLE `prefix_lesson_default`
|
||||
`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',
|
||||
|
@ -352,6 +352,11 @@ function lesson_upgrade($oldversion) {
|
||||
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;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ CREATE TABLE prefix_lesson (
|
||||
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',
|
||||
@ -119,6 +120,7 @@ CREATE TABLE prefix_lesson_default
|
||||
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',
|
||||
|
@ -401,11 +401,11 @@ function lesson_print_submit_link($name, $form, $align = 'center', $class='stand
|
||||
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>
|
||||
|
@ -31,6 +31,9 @@ if ($form->mode == "add") {
|
||||
if (!isset($form->nextpagedefault)) {
|
||||
$form->nextpagedefault = 0;
|
||||
}
|
||||
if (!isset($form->feedback)) {
|
||||
$form->feedback = 1;
|
||||
}
|
||||
if (!isset($form->minquestions)) {
|
||||
$form->minquestions = 0;
|
||||
}
|
||||
@ -320,6 +323,18 @@ if ($form->mode == "add") {
|
||||
</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>
|
||||
|
@ -73,6 +73,7 @@
|
||||
$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']['#']);
|
||||
@ -664,6 +665,7 @@
|
||||
$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']['#']);
|
||||
|
@ -5,7 +5,7 @@
|
||||
/// 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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user