diff --git a/mod/choice/lib.php b/mod/choice/lib.php index a8407a7a92e..e9c36eadbfd 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -67,7 +67,7 @@ function choice_add_instance($choice) { //insert answers if ($choice->id = insert_record("choice", $choice)) { - foreach ($choice as $name => $value) { + foreach ($choice as $name => $value) { if (strstr($name, "newoption")) { /// New option $value = trim($value); if (isset($value) && $value <> '') { @@ -78,7 +78,7 @@ function choice_add_instance($choice) { $option->maxanswers = $choice->{'newlimit'.substr($name, 9)}; } $option->timemodified = time(); - insert_record("choice_options", $option); + insert_record("choice_options", $option); } } } @@ -105,10 +105,10 @@ function choice_update_instance($choice) { $choice->timeopen = 0; $choice->timeclose = 0; } - + //update answers - - foreach ($choice as $name => $value) { + + foreach ($choice as $name => $value) { $value = trim($value); if (strstr($name, "oldoption")) { // Old option @@ -134,13 +134,13 @@ function choice_update_instance($choice) { $option->maxanswers = $choice->{'newlimit'.substr($name, 9)}; } $option->timemodified = time(); - insert_record("choice_options", $option); + insert_record("choice_options", $option); } - } + } } return update_record('choice', $choice); - + } function choice_show_form($choice, $user, $cm) { @@ -154,10 +154,10 @@ $cdisplay = array(); foreach ($choice->option as $optionid => $text) { if (isset($text)) { //make sure there are no dud entries in the db with blank text values. $countanswers = (get_records("choice_answers", "optionid", $optionid)); - $countans = 0; + $countans = 0; if (!empty($countanswers)) { - foreach ($countanswers as $ca) { //only return enrolled users. - if (isstudent($cm->course, $ca->userid) or isteacher($cm->course, $ca->userid)) { + foreach ($countanswers as $ca) { //only return enrolled users. + if (isstudent($cm->course, $ca->userid) or isteacher($cm->course, $ca->userid)) { $countans = $countans+1; } } @@ -169,21 +169,21 @@ $cdisplay = array(); } $maxans = $choice->maxanswers[$optionid]; - $cdisplay[$aid]->optionid = $optionid; - $cdisplay[$aid]->text = $text; - $cdisplay[$aid]->maxanswers = $maxans; - $cdisplay[$aid]->countanswers = $countans; + $cdisplay[$aid]->optionid = $optionid; + $cdisplay[$aid]->text = $text; + $cdisplay[$aid]->maxanswers = $maxans; + $cdisplay[$aid]->countanswers = $countans; - if ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user->id, 'optionid', $optionid)) { - $cdisplay[$aid]->checked = ' checked="checked" '; - } else { - $cdisplay[$aid]->checked = ''; - } + if ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user->id, 'optionid', $optionid)) { + $cdisplay[$aid]->checked = ' checked="checked" '; + } else { + $cdisplay[$aid]->checked = ''; + } if ($choice->limitanswers && ($countans >= $maxans) && (empty($cdisplay[$aid]->checked)) ) { - $cdisplay[$aid]->disabled = ' disabled="disabled" '; - } else { - $cdisplay[$aid]->disabled = ''; - } + $cdisplay[$aid]->disabled = ' disabled="disabled" '; + } else { + $cdisplay[$aid]->disabled = ''; + } $aid++; } } @@ -191,16 +191,16 @@ $cdisplay = array(); switch ($choice->display) { case CHOICE_DISPLAY_HORIZONTAL: echo "
| ";
echo "optionid."\" alt=\"".strip_tags(format_text($cd->text))."\"". $cd->checked.$cd->disabled." />";
- if (!empty($cd->disabled)) {
+ if (!empty($cd->disabled)) {
echo format_text($cd->text." ".get_string('full', 'choice').""); - } else { + } else { echo format_text($cd->text); } - echo " | ";
+ echo "";
}
echo "