Rating MDL-22270 Prevented fetching of ratings when ratings are turned off
This commit is contained in:
+15
-13
@@ -642,20 +642,22 @@
|
||||
//data_print_template() only adds ratings for singletemplate which is why we're attaching them here
|
||||
//attach ratings to data records
|
||||
require_once($CFG->dirroot.'/rating/lib.php');
|
||||
$ratingoptions = new stdclass();
|
||||
$ratingoptions->context = $cm->context;
|
||||
$ratingoptions->items = $records;
|
||||
$ratingoptions->aggregate = $data->assessed;//the aggregation method
|
||||
$ratingoptions->scaleid = $data->scale;
|
||||
$ratingoptions->userid = $USER->id;
|
||||
$ratingoptions->returnurl = $CFG->wwwroot.'/mod/data/'.$baseurl;
|
||||
$ratingoptions->assesstimestart = $data->assesstimestart;
|
||||
$ratingoptions->assesstimefinish = $data->assesstimefinish;
|
||||
$ratingoptions->plugintype = 'mod';
|
||||
$ratingoptions->pluginname = 'data';
|
||||
if ($data->assessed!=RATING_AGGREGATE_NONE) {
|
||||
$ratingoptions = new stdclass();
|
||||
$ratingoptions->context = $cm->context;
|
||||
$ratingoptions->items = $records;
|
||||
$ratingoptions->aggregate = $data->assessed;//the aggregation method
|
||||
$ratingoptions->scaleid = $data->scale;
|
||||
$ratingoptions->userid = $USER->id;
|
||||
$ratingoptions->returnurl = $CFG->wwwroot.'/mod/data/'.$baseurl;
|
||||
$ratingoptions->assesstimestart = $data->assesstimestart;
|
||||
$ratingoptions->assesstimefinish = $data->assesstimefinish;
|
||||
$ratingoptions->plugintype = 'mod';
|
||||
$ratingoptions->pluginname = 'data';
|
||||
|
||||
$rm = new rating_manager();
|
||||
$records = $rm->get_ratings($ratingoptions);
|
||||
$rm = new rating_manager();
|
||||
$records = $rm->get_ratings($ratingoptions);
|
||||
}
|
||||
|
||||
data_print_template('singletemplate', $records, $data, $search, $page);
|
||||
|
||||
|
||||
+19
-17
@@ -5240,24 +5240,26 @@ function forum_print_discussion($course, $cm, $forum, $discussion, $post, $mode,
|
||||
}
|
||||
|
||||
//load ratings
|
||||
$ratingoptions = new stdclass();
|
||||
$ratingoptions->context = $cm->context;
|
||||
$ratingoptions->items = $posts;
|
||||
$ratingoptions->aggregate = $forum->assessed;//the aggregation method
|
||||
$ratingoptions->scaleid = $forum->scale;
|
||||
$ratingoptions->userid = $USER->id;
|
||||
if ($forum->type == 'single' or !$discussion->id) {
|
||||
$ratingoptions->returnurl = "$CFG->wwwroot/mod/forum/view.php?id=$cm->id";
|
||||
} else {
|
||||
$ratingoptions->returnurl = "$CFG->wwwroot/mod/forum/discuss.php?d=$discussion->id";
|
||||
}
|
||||
$ratingoptions->assesstimestart = $forum->assesstimestart;
|
||||
$ratingoptions->assesstimefinish = $forum->assesstimefinish;
|
||||
$ratingoptions->plugintype = 'mod';
|
||||
$ratingoptions->pluginname = 'forum';
|
||||
if ($forum->assessed!=RATING_AGGREGATE_NONE) {
|
||||
$ratingoptions = new stdclass();
|
||||
$ratingoptions->context = $cm->context;
|
||||
$ratingoptions->items = $posts;
|
||||
$ratingoptions->aggregate = $forum->assessed;//the aggregation method
|
||||
$ratingoptions->scaleid = $forum->scale;
|
||||
$ratingoptions->userid = $USER->id;
|
||||
if ($forum->type == 'single' or !$discussion->id) {
|
||||
$ratingoptions->returnurl = "$CFG->wwwroot/mod/forum/view.php?id=$cm->id";
|
||||
} else {
|
||||
$ratingoptions->returnurl = "$CFG->wwwroot/mod/forum/discuss.php?d=$discussion->id";
|
||||
}
|
||||
$ratingoptions->assesstimestart = $forum->assesstimestart;
|
||||
$ratingoptions->assesstimefinish = $forum->assesstimefinish;
|
||||
$ratingoptions->plugintype = 'mod';
|
||||
$ratingoptions->pluginname = 'forum';
|
||||
|
||||
$rm = new rating_manager();
|
||||
$posts = $rm->get_ratings($ratingoptions);
|
||||
$rm = new rating_manager();
|
||||
$posts = $rm->get_ratings($ratingoptions);
|
||||
}
|
||||
|
||||
|
||||
$post->forum = $forum->id; // Add the forum id to the post object, later used by forum_print_post
|
||||
|
||||
@@ -1095,7 +1095,7 @@ function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $m
|
||||
if ($icons) {
|
||||
echo '<tr valign="top"><td class="icons">'.$icons.'</td></tr>';
|
||||
}
|
||||
if ($entry->rating) {
|
||||
if (!empty($entry->rating)) {
|
||||
echo '<tr valign="top"><td class="ratings">';
|
||||
glossary_print_entry_ratings($course, $entry);
|
||||
echo '</td></tr>';
|
||||
|
||||
+15
-34
@@ -401,41 +401,22 @@ if ($allentries) {
|
||||
|
||||
//load ratings
|
||||
require_once($CFG->dirroot.'/rating/lib.php');
|
||||
$ratingoptions = new stdclass();
|
||||
$ratingoptions->context = $cm->context;
|
||||
$ratingoptions->items = $allentries;
|
||||
$ratingoptions->aggregate = $glossary->assessed;//the aggregation method
|
||||
$ratingoptions->scaleid = $glossary->scale;
|
||||
$ratingoptions->userid = $USER->id;
|
||||
$ratingoptions->returnurl = $CFG->wwwroot.'/mod/glossary/view.php?id='.$cm->id;
|
||||
$ratingoptions->assesstimestart = $glossary->assesstimestart;
|
||||
$ratingoptions->assesstimefinish = $glossary->assesstimefinish;
|
||||
$ratingoptions->plugintype = 'mod';
|
||||
$ratingoptions->pluginname = 'glossary';
|
||||
if ($glossary->assessed!=RATING_AGGREGATE_NONE) {
|
||||
$ratingoptions = new stdclass();
|
||||
$ratingoptions->context = $cm->context;
|
||||
$ratingoptions->items = $allentries;
|
||||
$ratingoptions->aggregate = $glossary->assessed;//the aggregation method
|
||||
$ratingoptions->scaleid = $glossary->scale;
|
||||
$ratingoptions->userid = $USER->id;
|
||||
$ratingoptions->returnurl = $CFG->wwwroot.'/mod/glossary/view.php?id='.$cm->id;
|
||||
$ratingoptions->assesstimestart = $glossary->assesstimestart;
|
||||
$ratingoptions->assesstimefinish = $glossary->assesstimefinish;
|
||||
$ratingoptions->plugintype = 'mod';
|
||||
$ratingoptions->pluginname = 'glossary';
|
||||
|
||||
$rm = new rating_manager();
|
||||
$allentries = $rm->get_ratings($ratingoptions);
|
||||
|
||||
/*$ratings = NULL;
|
||||
$ratingsmenuused = false;
|
||||
if ($glossary->assessed and isloggedin() and !isguestuser()) {
|
||||
$ratings = new object();
|
||||
if ($ratings->scale = make_grades_menu($glossary->scale)) {
|
||||
$ratings->assesstimestart = $glossary->assesstimestart;
|
||||
$ratings->assesstimefinish = $glossary->assesstimefinish;
|
||||
}
|
||||
if ($glossary->assessed == 2 and !has_capability('mod/glossary:rate', $context)) {
|
||||
$ratings->allow = false;
|
||||
} else {
|
||||
$ratings->allow = true;
|
||||
}
|
||||
$formsent = 1;
|
||||
|
||||
echo "<form method=\"post\" action=\"rate.php\">";
|
||||
echo "<div>";
|
||||
echo "<input type=\"hidden\" name=\"glossaryid\" value=\"$glossary->id\" />";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
|
||||
}*/
|
||||
$rm = new rating_manager();
|
||||
$allentries = $rm->get_ratings($ratingoptions);
|
||||
}
|
||||
|
||||
foreach ($allentries as $entry) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user