Skip to content

Commit

Permalink
MDL-13158 choice/index.php only return values for choices in the curr…
Browse files Browse the repository at this point in the history
…ent course.; merged from MOODLE_19_STABLE
  • Loading branch information
skodak committed Feb 26, 2008
1 parent e06d74d commit c01a1ce
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mod/choice/index.php
Expand Up @@ -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);
}


Expand Down

0 comments on commit c01a1ce

Please sign in to comment.