course)) { error("Course is misconfigured"); } require_login($course->id); if (!$choice = choice_get_choice($cm->instance)) { error("Course module is incorrect"); } if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $USER->id)) { $answerchecked[$current->answer] = "CHECKED"; } if (match_referer() && isset($HTTP_POST_VARS)) { // form submitted $form = (object)$HTTP_POST_VARS; $timenow = time(); if ($current) { $newanswer = $current; $newanswer->answer = $form->answer; $newanswer->timemodified = $timenow; if (! update_record("choice_answers", $newanswer)) { error("Could not update your choice"); } add_to_log($course->id, "choice", "update", "view.php?id=$cm->id", "$choice->id"); } else { $newanswer->choice = $choice->id; $newanswer->userid = $USER->id; $newanswer->answer = $form->answer; $newanswer->timemodified = $timenow; if (! insert_record("choice_answers", $newanswer)) { error("Could not save your choice"); } add_to_log($course->id, "choice", "add", "view.php?id=$cm->id", "$choice->id"); } redirect("$CFG->wwwroot/course/view.php?id=$course->id"); exit; } $strchoice = get_string("modulename", "choice"); $strchoices = get_string("modulenameplural", "choice"); add_to_log($course->id, "choice", "view", "view.php?id=$cm->id", "$choice->id"); if ($course->category) { $navigation = "id\">$course->shortname ->"; } print_header("$course->shortname: $choice->name", "$course->fullname", "$navigation id>$strchoices -> $choice->name", "", "", true, update_module_button($cm->id, $course->id, $strchoice), navmenu($course, $cm)); if (isteacher($course->id)) { if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) { $responsecount = count($allanswers); } else { $responsecount = 0; } echo "
id\">".get_string("viewallresponses", "choice", $responsecount)."
"; } print_simple_box( text_to_html($choice->text) , "center"); echo "