MDL-18058 glossary rates - secured

This commit is contained in:
stronk7
2009-05-06 09:15:46 +00:00
parent c7ad7da9c0
commit 696018df63
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -131,6 +131,7 @@ $string['importedcategories'] = 'Imported categories';
$string['importedentries'] = 'Imported entries';
$string['importentries'] = 'Import entries';
$string['importentriesfromxml'] = 'Import entries from XML file';
$string['invalidrate'] = 'Invalid glossary rate ($a)';
$string['isglobal'] = 'Is this glossary global?';
$string['linkcategory'] = 'Automatically link this category';
$string['linking'] = 'Auto-linking';
+9
View File
@@ -45,6 +45,10 @@
}
if ($data = data_submitted()) { // form submitted
/// Calculate scale values
$scale_values = make_grades_menu($glossary->scale);
foreach ((array)$data as $entryid => $rating) {
if (!is_numeric($entryid)) {
continue;
@@ -69,6 +73,11 @@
continue;
}
/// Check rate is valid for that glossary scale values
if (!array_key_exists($rating, $scale_values) && $rating != -999) {
print_error('invalidrate', 'glossary', '', $rating);
}
if ($oldrating = get_record("glossary_ratings", "userid", $USER->id, "entryid", $entry->id)) {
//Check if we must delete the rate
if ($rating == -999) {