Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-18523 Only display the 'Synchronise legacy grades' button when ne…

…cessary
  • Loading branch information...
commit 8074fe4f8c3758b07d578b4ed08ada72aa29a5d7 1 parent b50ff44
skodak authored
View
10 grade/edit/tree/index.php
@@ -360,10 +360,12 @@
print_single_button('outcomeitem.php', array('courseid'=>$course->id), get_string('addoutcomeitem', 'grades'), 'get');
}
- //print_single_button('index.php', array('id'=>$course->id, 'action'=>'autosort'), get_string('autosort', 'grades'), 'get');
- echo "<br /><br />";
- print_single_button('index.php', array('id'=>$course->id, 'action'=>'synclegacy'), get_string('synclegacygrades', 'grades'), 'get');
- helpbutton('synclegacygrades', get_string('synclegacygrades', 'grades'), 'grade');
+ if ($legacy = grade_get_legacy_modules($course->id)) {
+ //print_single_button('index.php', array('id'=>$course->id, 'action'=>'autosort'), get_string('autosort', 'grades'), 'get');
+ echo "<br /><br />";
+ print_single_button('index.php', array('id'=>$course->id, 'action'=>'synclegacy'), get_string('synclegacygrades', 'grades').' ('.implode(', ', $legacy).')', 'get');
+ helpbutton('synclegacygrades', get_string('synclegacygrades', 'grades'), 'grade');
+ }
}
echo '</div>';
View
29 lib/gradelib.php
@@ -1157,6 +1157,35 @@ function grade_update_mod_grades($modinstance, $userid=0) {
}
/**
+ * Returns list of currently used mods with legacy grading in course
+ * @param $courseid int
+ * @return array of modname=>modulenamestring mods with legacy grading
+ */
+function grade_get_legacy_modules($courseid) {
+ global $CFG;
+
+ $mods = get_course_mods($courseid);
+ $legacy = array();
+
+ foreach ($mods as $mod) {
+ $modname = $mod->modname;
+
+ $modlib = "$CFG->dirroot/mod/$modname/lib.php";
+ if (!$modlib) {
+ continue;
+ }
+ include_once($modlib);
+ $gradefunc = $modname.'_grades';
+ if (!function_exists($gradefunc)) {
+ continue;
+ }
+ $legacy[$modname] = get_string('modulename', $modname);
+ }
+
+ return $legacy;
+}
+
+/**
* Get and update/create grade item for legacy modules.
*/
function grade_get_legacy_grade_item($modinstance, $grademax, $scaleid) {
View
12 mod/lams/lib.php
@@ -92,18 +92,6 @@ function lams_cron () {
return true;
}
-function lams_grades($lamsid) {
-/// Must return an array of grades for a given instance of this module,
-/// indexed by user. It also returns a maximum allowed grade.
-///
-/// $return->grades = array of grades;
-/// $return->maxgrade = maximum allowed grade;
-///
-/// return $return;
-
- return NULL;
-}
-
function lams_get_participants($lamsid) {
//Must return an array of user records (all data) who are participants
//for a given instance of lams. Must include every user involved
View
7 mod/wiki/lib.php
@@ -237,13 +237,6 @@ function wiki_cron () {
return $result;
}
-function wiki_grades($wikiid) {
-/// Must return an array of grades for a given instance of this module,
-/// indexed by user. It also returns a maximum allowed grade.
-
- return NULL;
-}
-
function wiki_get_participants($wikiid) {
//Returns the users with data in one wiki
//(users with records in wiki_pages and wiki_entries)

0 comments on commit 8074fe4

Please sign in to comment.
Something went wrong with that request. Please try again.