MDL-47543 core_grades: improve navigation menu in grade administration
authorMarina Glancy <marina@moodle.com>
Tue, 7 Oct 2014 13:58:19 +0000 (21:58 +0800)
committerMarina Glancy <marina@moodle.com>
Wed, 8 Oct 2014 07:03:36 +0000 (15:03 +0800)
grade/edit/tree/index.php
grade/lib.php
grade/report/grader/preferences.php
lang/en/deprecated.txt
lang/en/grades.php

index 849c23b..e73bc93 100644 (file)
@@ -244,7 +244,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
     }
 }
 
-print_grade_page_head($courseid, 'settings', 'setup', get_string('setupgradeslayout', 'grades'));
+print_grade_page_head($courseid, 'settings', 'setup', get_string('categoriesanditems', 'grades'));
 
 // Print Table of categories and items
 echo $OUTPUT->box_start('gradetreebox generalbox');
index 643bdb9..58fbd57 100644 (file)
@@ -651,6 +651,10 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
         $plugin_info['report'] = $reports;
     }
 
+    if ($settings = grade_helper::get_info_manage_settings($courseid)) {
+        $plugin_info['settings'] = $settings;
+    }
+
     if ($scale = grade_helper::get_info_scales($courseid)) {
         $plugin_info['scale'] = array('view'=>$scale);
     }
@@ -685,16 +689,6 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
         }
     }
 
-    // Hide course settings if we're not in a course
-    if ($settings = grade_helper::get_info_manage_settings($courseid)) {
-        $plugin_info['settings'] = $settings;
-    }
-
-    // Put preferences last
-    if ($preferences = grade_helper::get_plugins_report_preferences($courseid)) {
-        $plugin_info['preferences'] = $preferences;
-    }
-
     foreach ($plugin_info as $plugin_type => $plugins) {
         if (!empty($plugins->id) && $active_plugin == $plugins->id) {
             $plugin_info['strings']['active_plugin_str'] = $plugins->string;
@@ -788,6 +782,11 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
                                $buttons=false, $shownavigation=true) {
     global $CFG, $OUTPUT, $PAGE;
 
+    if ($active_type === 'preferences') {
+        // In Moodle 2.8 report preferences were moved under 'settings'. Allow backward compatibility for 3rd party grade reports.
+        $active_type = 'settings';
+    }
+
     $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin);
 
     // Determine the string of the active plugin
@@ -2405,6 +2404,13 @@ function grade_extend_settings($plugininfo, $courseid) {
         }
     }
 
+    if ($settings = grade_helper::get_info_manage_settings($courseid)) {
+        $settingsnode = $gradenode->add($strings['settings'], null, navigation_node::TYPE_CONTAINER);
+        foreach ($settings as $setting) {
+            $settingsnode->add($setting->string, $setting->link, navigation_node::TYPE_SETTING, null, $setting->id, new pix_icon('i/settings', ''));
+        }
+    }
+
     if ($imports = grade_helper::get_plugins_import($courseid)) {
         $importnode = $gradenode->add($strings['import'], null, navigation_node::TYPE_CONTAINER);
         foreach ($imports as $import) {
@@ -2419,20 +2425,6 @@ function grade_extend_settings($plugininfo, $courseid) {
         }
     }
 
-    if ($settings = grade_helper::get_info_manage_settings($courseid)) {
-        $settingsnode = $gradenode->add($strings['settings'], null, navigation_node::TYPE_CONTAINER);
-        foreach ($settings as $setting) {
-            $settingsnode->add($setting->string, $setting->link, navigation_node::TYPE_SETTING, null, $setting->id, new pix_icon('i/settings', ''));
-        }
-    }
-
-    if ($preferences = grade_helper::get_plugins_report_preferences($courseid)) {
-        $preferencesnode = $gradenode->add(get_string('myreportpreferences', 'grades'), null, navigation_node::TYPE_CONTAINER);
-        foreach ($preferences as $preference) {
-            $preferencesnode->add($preference->string, $preference->link, navigation_node::TYPE_SETTING, null, $preference->id, new pix_icon('i/settings', ''));
-        }
-    }
-
     if ($letters = grade_helper::get_info_letters($courseid)) {
         $letters = array_shift($letters);
         $gradenode->add($strings['letter'], $letters->link, navigation_node::TYPE_SETTING, null, $letters->id, new pix_icon('i/settings', ''));
@@ -2545,8 +2537,7 @@ abstract class grade_helper {
                 'letter' => get_string('letters', 'grades'),
                 'export' => get_string('export', 'grades'),
                 'import' => get_string('import'),
-                'preferences' => get_string('mypreferences', 'grades'),
-                'settings' => get_string('settings')
+                'settings' => get_string('edittree', 'grades')
             );
         }
         return self::$pluginstrings;
@@ -2587,12 +2578,18 @@ abstract class grade_helper {
         $context = context_course::instance($courseid);
         self::$managesetting = array();
         if ($courseid != SITEID && has_capability('moodle/grade:manage', $context)) {
+            self::$managesetting['categoriesanditems'] = new grade_plugin_info('setup',
+                new moodle_url('/grade/edit/tree/index.php', array('id' => $courseid)),
+                get_string('categoriesanditems', 'grades'));
             self::$managesetting['coursesettings'] = new grade_plugin_info('coursesettings',
                 new moodle_url('/grade/edit/settings/index.php', array('id'=>$courseid)),
                 get_string('coursegradesettings', 'grades'));
-            self::$managesetting['setup'] = new grade_plugin_info('setup',
-                new moodle_url('/grade/edit/tree/index.php', array('id' => $courseid)),
-                get_string('setupgradeslayout', 'grades'));
+        }
+        if (self::$gradereportpreferences === null) {
+            self::get_plugins_reports($courseid);
+        }
+        if (self::$gradereportpreferences) {
+            self::$managesetting = array_merge(self::$managesetting, self::$gradereportpreferences);
         }
         return self::$managesetting;
     }
@@ -2629,7 +2626,8 @@ abstract class grade_helper {
             // Add link to preferences tab if such a page exists
             if (file_exists($plugindir.'/preferences.php')) {
                 $url = new moodle_url('/grade/report/'.$plugin.'/preferences.php', array('id'=>$courseid));
-                $gradepreferences[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr);
+                $gradepreferences[$plugin] = new grade_plugin_info($plugin, $url,
+                    get_string('mypreferences', 'grades') . ': ' . $pluginstr);
             }
         }
         if (count($gradereports) == 0) {
@@ -2646,19 +2644,7 @@ abstract class grade_helper {
         self::$gradereportpreferences = $gradepreferences;
         return self::$gradereports;
     }
-    /**
-     * Returns an array of grade plugin report preferences for plugin reports that
-     * support preferences
-     * @param int $courseid
-     * @return array
-     */
-    public static function get_plugins_report_preferences($courseid) {
-        if (self::$gradereportpreferences !== null) {
-            return self::$gradereportpreferences;
-        }
-        self::get_plugins_reports($courseid);
-        return self::$gradereportpreferences;
-    }
+
     /**
      * Get information on scales
      * @param int $courseid
index 1fc07f0..029afa4 100644 (file)
@@ -69,7 +69,7 @@ if ($mform->is_cancelled()){
     redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid);
 }
 
-print_grade_page_head($courseid, 'preferences', 'grader', get_string('preferences', 'gradereport_grader'));
+print_grade_page_head($courseid, 'settings', 'grader', get_string('preferences', 'gradereport_grader'));
 
 // If USER has admin capability, print a link to the site config page for this report
 if (has_capability('moodle/site:config', $systemcontext)) {
index c2b5e6a..a17e036 100644 (file)
@@ -4,8 +4,6 @@ hidden,core_portfolio
 hidden,core_question
 hidden,core_repository
 hidden,core_role
-categoriesanditems,core_grades
 simpleview,core_grades
 fullview,core_grades
 categoriesedit,core_grades
-edittree,core_grades
index fa07263..42eb9e8 100644 (file)
@@ -116,6 +116,7 @@ $string['calculationsaved'] = 'Calculation saved';
 $string['calculationview'] = 'View calculation';
 $string['cannotaccessgroup'] = 'Can not access grades of selected group, sorry.';
 $string['categories'] = 'Categories';
+$string['categoriesanditems'] = 'Categories and items';
 $string['category'] = 'Category';
 $string['categoryedit'] = 'Edit category';
 $string['categoryname'] = 'Category name';
@@ -173,6 +174,7 @@ $string['editgradeletters'] = 'Edit grade letters';
 $string['editoutcome'] = 'Edit outcome';
 $string['editoutcomes'] = 'Edit outcomes';
 $string['editscale'] = 'Edit scale';
+$string['edittree'] = 'Setup';
 $string['editverbose'] = 'Edit {$a->category} {$a->itemmodule} {$a->itemname}';
 $string['enableajax'] = 'Enable AJAX';
 $string['enableajax_help'] = 'Adds a layer of AJAX functionality to the grader report, simplifying and speeding up common operations. Depends on Javascript being switched on at the user\'s browser level.';
@@ -593,7 +595,6 @@ $string['setgradeletters'] = 'Set grade letters';
 $string['setpreferences'] = 'Set preferences';
 $string['setting'] = 'Setting';
 $string['settings'] = 'Settings';
-$string['setupgradeslayout'] = 'Set up grades layout';
 $string['setweights'] = 'Set weights';
 $string['showanalysisicon'] = 'Show grade analysis icon';
 $string['showanalysisicon_desc'] = 'Whether to show grade analysis icon by default. If the activity module supports it, the grade analysis icon links to a page with more detailed explanation of the grade and how it was obtained.';
@@ -739,8 +740,6 @@ $string['yourgrade'] = 'Your grade';
 
 // Deprecated since Moodle 2.8
 
-$string['categoriesanditems'] = 'Setup';
 $string['categoriesedit'] = 'Edit setup';
-$string['edittree'] = 'Setup';
 $string['fullview'] = 'Full view';
 $string['simpleview'] = 'Simple view';