mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
rating MDL-21657 changes based on Petr's feedback
This commit is contained in:
parent
6aee047797
commit
f1f6a75524
@ -1235,7 +1235,6 @@ class core_renderer extends renderer_base {
|
||||
*/
|
||||
function render_rating(rating $rating) {
|
||||
global $CFG, $USER, $PAGE;
|
||||
static $strrate;//holds the string "rate". Its static so we only fetch it once.
|
||||
static $havesetupjavascript = false;
|
||||
|
||||
if( !$havesetupjavascript && !empty($CFG->enableajax) ) {
|
||||
@ -1243,11 +1242,8 @@ class core_renderer extends renderer_base {
|
||||
$havesetupjavascript = true;
|
||||
}
|
||||
|
||||
if (empty($strrate)) {
|
||||
$strrate = get_string("rate", "rating");
|
||||
}
|
||||
|
||||
$strratings = '';
|
||||
$strrate = get_string("rate", "rating");
|
||||
$strratings = ''; //the string we'll return
|
||||
|
||||
if($rating->settings->permissions[RATING_VIEW] || $rating->settings->permissions[RATING_VIEW_ALL]) {
|
||||
switch ($rating->settings->aggregationmethod) {
|
||||
@ -1327,7 +1323,7 @@ END;
|
||||
$strratings .= html_writer::select($scalearray, 'rating'.$rating->itemid, $rating->rating, false, array('class'=>'postratingmenu ratinginput'));
|
||||
|
||||
//output submit button
|
||||
$strratings .= '<span class="ratingsubmit"><input type="submit" class="postratingmenusubmit" id="postratingsubmit'.$rating->itemid.'" value="'.get_string('rate', 'forum').'" />';
|
||||
$strratings .= '<span class="ratingsubmit"><input type="submit" class="postratingmenusubmit" id="postratingsubmit'.$rating->itemid.'" value="'.s(get_string('rate', 'rating')).'" />';
|
||||
|
||||
//ajax code is included by rating::load_ratings()
|
||||
|
||||
|
@ -26,18 +26,15 @@
|
||||
require_once("../config.php");
|
||||
require_once("ratinglib.php");
|
||||
|
||||
$itemcontextid = required_param('contextid', PARAM_INT);
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$itemid = required_param('itemid', PARAM_INT);
|
||||
$scaleid = required_param('scaleid', PARAM_INT);
|
||||
$sort = optional_param('sort', '', PARAM_ALPHA);
|
||||
|
||||
$context = get_context_instance_by_id($itemcontextid);
|
||||
$cm = get_coursemodule_from_id('', $context->instanceid, 0, false, MUST_EXIST);
|
||||
$courseid = $cm->course;
|
||||
//$course = get_course_from_path($context->path);
|
||||
require_login($courseid, false, $cm);
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
require_login($course, false, $cm);
|
||||
|
||||
$url = new moodle_url('/rating/index.php', array('contextid'=>$itemcontextid,'itemid'=>$itemid));
|
||||
$url = new moodle_url('/rating/index.php', array('contextid'=>$contextid,'itemid'=>$itemid));
|
||||
if ($sort !== 0) {
|
||||
$url->param('sort', $sort);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('ratinglib.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$itemid = required_param('itemid', PARAM_INT);
|
||||
@ -36,22 +37,20 @@ $scaleid = required_param('scaleid', PARAM_INT);
|
||||
$userrating = required_param('rating'.$itemid, PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);//will only be supplied for non-ajax requests
|
||||
|
||||
require_once('ratinglib.php');
|
||||
|
||||
$result = new stdClass;
|
||||
|
||||
if( !isloggedin() ){ //session has expired
|
||||
if( !isloggedin() && !$returnurl ){ //session has expired and its an ajax request
|
||||
$result->error = get_string('sessionexpired', 'ratings');
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
|
||||
$context = get_context_instance_by_id($contextid);
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
require_login($course, false, $cm);
|
||||
|
||||
$permissions = rating::get_rating_permissions($context);
|
||||
if( !$permissions[RATING_POST] ) {
|
||||
//check if its a non-ajax request
|
||||
if( $returnurl ) {
|
||||
if( $returnurl ) { //if its a non-ajax request
|
||||
echo $OUTPUT->header();
|
||||
echo get_string('ratepermissiondenied', 'ratings');
|
||||
echo $OUTPUT->footer();
|
||||
@ -76,10 +75,6 @@ $PAGE->set_url('/lib/rate.php', array(
|
||||
'returnurl'=>$returnurl,
|
||||
));
|
||||
|
||||
if( $returnurl ) {
|
||||
//
|
||||
}
|
||||
|
||||
//todo how can we validate the forum post,glossary entry or whatever id?
|
||||
//how do we know where to look for the item? how we we work from module to forum_posts, glossary_entries etc?
|
||||
//if ($rating_context->contextlevel == CONTEXT_COURSE) {
|
||||
|
@ -152,13 +152,12 @@ class rating implements renderable {
|
||||
global $DB;
|
||||
|
||||
$sql = "SELECT r.id, r.rating, r.itemid, r.userid, r.timemodified,
|
||||
u.firstname, u.lastname, u.imagealt, u.picture
|
||||
FROM {rating} r
|
||||
LEFT JOIN {user} u ON r.userid = u.id
|
||||
WHERE
|
||||
r.contextid = :contextid AND
|
||||
r.itemid = :itemid
|
||||
$sort";
|
||||
u.firstname, u.lastname, u.imagealt, u.picture
|
||||
FROM {rating} r
|
||||
LEFT JOIN {user} u ON r.userid = u.id
|
||||
WHERE r.contextid = :contextid AND
|
||||
r.itemid = :itemid
|
||||
$sort";
|
||||
|
||||
$params['contextid'] = $context->id;
|
||||
$params['itemid'] = $itemid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user