Skip to content

Commit

Permalink
MDL-18004 Separated gradebook course settings from report preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Feb 17, 2009
1 parent 9c023be commit 54c4a2c
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 15 deletions.
6 changes: 2 additions & 4 deletions grade/edit/settings/form.php
Expand Up @@ -32,13 +32,11 @@
class course_settings_form extends moodleform {

function definition() {
global $USER, $CFG, $COURSE;
global $USER, $CFG;

$mform =& $this->_form;

$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);

$can_view_admin_links = false;
if (has_capability('moodle/grade:manage', $systemcontext)) {
$can_view_admin_links = true;
Expand Down Expand Up @@ -104,7 +102,7 @@ function definition() {
foreach($types as $type) {
foreach (get_list_of_plugins('grade/'.$type) as $plugin) {
// Include all the settings commands for this plugin if there are any
if (file_exists($CFG->dirroot.'/grade/'.$type.'/'.$plugin.'/lib.php') && has_capability('gradereport/'.$plugin.':view', $context)) {
if (file_exists($CFG->dirroot.'/grade/'.$type.'/'.$plugin.'/lib.php')) {
require_once($CFG->dirroot.'/grade/'.$type.'/'.$plugin.'/lib.php');
$functionname = 'grade_'.$type.'_'.$plugin.'_settings_definition';
if (function_exists($functionname)) {
Expand Down
19 changes: 15 additions & 4 deletions grade/lib.php
Expand Up @@ -429,6 +429,7 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
'letter' => get_string('letters', 'grades'),
'export' => get_string('export', 'grades'),
'import' => get_string('import'),
'preferences' => get_string('mypreferences', 'grades'),
'settings' => get_string('settings'));

// Settings tab first
Expand Down Expand Up @@ -466,7 +467,7 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
// Add link to preferences tab if such a page exists
if (file_exists($CFG->dirroot . '/grade/report/'.$plugin.'/preferences.php')) {
$pref_url = $url_prefix.'report/'.$plugin.'/preferences.php?id='.$courseid;
$plugin_info['settings'][$plugin] = array('id' => $plugin, 'link' => $pref_url, 'string' => get_string('modulename', 'gradereport_'.$plugin));
$plugin_info['preferences'][$plugin] = array('id' => $plugin, 'link' => $pref_url, 'string' => get_string('modulename', 'gradereport_'.$plugin));
}

$count++;
Expand Down Expand Up @@ -614,9 +615,19 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
}

// Put settings last
$settings = $plugin_info['settings'];
unset($plugin_info['settings']);
$plugin_info['settings'] = $settings;
if (!empty($plugin_info['settings'])) {
$settings = $plugin_info['settings'];
unset($plugin_info['settings']);
$plugin_info['settings'] = $settings;
}

// Put preferences last
if (!empty($plugin_info['preferences'])) {
$prefs = $plugin_info['preferences'];
unset($plugin_info['preferences']);
$plugin_info['preferences'] = $prefs;
}

return $plugin_info;
}

Expand Down
2 changes: 1 addition & 1 deletion grade/report/grader/preferences.php
Expand Up @@ -66,7 +66,7 @@
exit;
}

print_grade_page_head($courseid, 'settings', 'grader', get_string('preferences', 'gradereport_grader'));
print_grade_page_head($courseid, 'preferences', '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)) {
Expand Down
3 changes: 2 additions & 1 deletion grade/report/stats/lang/en_utf8/gradereport_stats.php
Expand Up @@ -24,6 +24,7 @@

$string['modulename'] = 'Stats report';
$string['stats:view'] = 'View course stats report';
$string['preferences'] = 'Stats report preferences';

$string['moredata']='Stats Report: More Data';

Expand Down Expand Up @@ -76,4 +77,4 @@
$string['uselocked'] = 'Count locked grades';

$string['printable'] = 'Printer Friendly Version';
?>
?>
2 changes: 1 addition & 1 deletion grade/report/stats/preferences.php
Expand Up @@ -76,7 +76,7 @@
redirect($CFG->wwwroot . '/grade/report/stats/index.php?id='.$courseid);
}

print_grade_page_head($courseid, 'settings', 'stats', get_string('preferences', 'gradereport_stats'));
print_grade_page_head($courseid, 'preferences', 'stats', get_string('preferences', 'gradereport_stats'));

/// If USER has admin capability, print a link to the site config page for this report
/// TODO: Add admin config page for this report
Expand Down
1 change: 0 additions & 1 deletion grade/report/user/index.php
Expand Up @@ -118,7 +118,6 @@

// print the page
print_grade_page_head($courseid, 'report', 'user', get_string('modulename', 'gradereport_user'). ' - '.fullname($report->user));
echo $user_selector;

if ($report->fill_table()) {
echo '<br />'.$report->print_table(true);
Expand Down
4 changes: 3 additions & 1 deletion grade/report/visual/lang/en_utf8/gradereport_visual.php
Expand Up @@ -30,6 +30,8 @@
$string['allgroups'] = 'All Groups';
$string['printable'] = 'Printer Friendly Version';

$string['preferences'] = 'Visual report preferences';

/// settings
$string['prefgeneral'] = 'General';
$string['prefcalc'] = 'Calculations';
Expand Down Expand Up @@ -83,4 +85,4 @@
$string['gradesvsitems:title'] = 'Average Grades vs Items';
$string['visual:vis:grades_vs_items'] = 'View Grades vs Items Visualization';

?>
?>
2 changes: 1 addition & 1 deletion grade/report/visual/preferences.php
Expand Up @@ -76,7 +76,7 @@
redirect($CFG->wwwroot . '/grade/report/visual/index.php?id='.$courseid);
}

print_grade_page_head($courseid, 'settings', 'visual', get_string('preferences', 'gradereport_visual'));
print_grade_page_head($courseid, 'preferences', 'visual', get_string('preferences', 'gradereport_visual'));

/// If USER has admin capability, print a link to the site config page for this report
/// TODO: Add admin config page for this report
Expand Down
1 change: 1 addition & 0 deletions lang/en_utf8/grades.php
Expand Up @@ -347,6 +347,7 @@
$string['movingelement'] = 'Moving $a';
$string['multfactor'] = 'Multiplicator';
$string['multfactorhelp'] = 'Factor by which all grades for this grade item will be multiplied.';
$string['mypreferences'] = 'My preferences';
$string['myreportpreferences'] = 'My report preferences';
$string['navmethod'] = 'Navigation method';
$string['neverdeletehistory'] = 'Never delete history';
Expand Down
3 changes: 2 additions & 1 deletion lib/grade/grade_category.php
Expand Up @@ -585,8 +585,9 @@ private function aggregate_grades($userid, $items, $grade_values, $oldgrade, $ex

/**
* Internal function - aggregation maths.
* Must be public: used by grade_grade::get_hiding_affected()
*/
private function aggregate_values($grade_values, $items) {
public function aggregate_values($grade_values, $items) {
switch ($this->aggregation) {
case GRADE_AGGREGATE_MEDIAN: // Middle point value in the set: ignores frequencies
$num = count($grade_values);
Expand Down

0 comments on commit 54c4a2c

Please sign in to comment.