From: skodak Date: Tue, 26 Feb 2008 23:19:58 +0000 (+0000) Subject: MDL-13158 choice/index.php only return values for choices in the current course.... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c01a1ce0f2ab8ab5df4fe5c9adb42f6c9ac4718e;p=moodle.git MDL-13158 choice/index.php only return values for choices in the current course.; merged from MOODLE_19_STABLE --- diff --git a/mod/choice/index.php b/mod/choice/index.php index f60fda7b4d..2b5cdead0b 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -26,13 +26,17 @@ notice(get_string('thereareno', 'moodle', $strchoices), "../../course/view.php?id=$course->id"); } - if ( !empty($USER->id) and $allanswers = get_records("choice_answers", "userid", $USER->id)) { // TODO: limit to choices from this course only + $sql = "SELECT cha.* + FROM {$CFG->prefix}choice ch, {$CFG->prefix}choice_answers cha + WHERE cha.choiceid = ch.id AND + ch.course = $course->id AND cha.userid = $USER->id"; + + $answers = array () ; + if (isloggedin() and !isguestuser() and $allanswers = get_records_sql($sql)) { foreach ($allanswers as $aa) { $answers[$aa->choiceid] = $aa; } - - } else { - $answers = array () ; + unset($allanswers); }