rating MDL-23908 added info to module config to help the user with rating permissions
authorAndrew Davis <andrew@affinitysoftware.net>
Tue, 24 Aug 2010 13:06:49 +0000 (13:06 +0000)
committerAndrew Davis <andrew@affinitysoftware.net>
Tue, 24 Aug 2010 13:06:49 +0000 (13:06 +0000)
course/moodleform_mod.php
lang/en/rating.php

index 06f0524..68b005a 100644 (file)
@@ -353,7 +353,20 @@ abstract class moodleform_mod extends moodleform {
 
             $mform->addElement('header', 'modstandardratings', get_string('ratings', 'rating'));
 
-            //$mform->addElement('checkbox', 'assessed', get_string('allowratings', 'ratings') , get_string('ratingsuse', 'ratings'));
+            $permission=null;
+            $context = get_context_instance(CONTEXT_MODULE, $this->_cm->id);
+
+            $roles1 = get_roles_with_capability('moodle/rating:rate', $permission, $context);
+            $roles2 = get_roles_with_capability('mod/'.$this->_cm->modname.':rate', $permission, $context);
+
+            $rolesthatcanrate = array();
+            foreach($roles1 as $k1=>$v1) {
+                if (array_key_exists($k1, $roles2)) {
+                    $rolesthatcanrate[] = $v1->name;
+                }
+            }
+
+            $mform->addElement('static', 'rolewarning', '', get_string('rolewarning','rating', implode(', ', $rolesthatcanrate)));
 
             $mform->addElement('select', 'assessed', get_string('aggregatetype', 'rating') , $rm->get_aggregate_types());
             $mform->setDefault('assessed', 0);
index 6cd9ddb..5c9c606 100644 (file)
@@ -33,3 +33,4 @@ $string['ratepermissiondenied'] = 'You do not have permission to rate this item'
 $string['rating'] = 'Rating';
 $string['ratings'] = 'Ratings';
 $string['ratingsuse'] = 'Use ratings';
+$string['rolewarning'] = 'Ratings automatically enter the Gradebook. Activity permissions determine which users can submit ratings.<br />Can submit ratings: {$a}';