MDL-11718 course settings for reports - for now only user report (rank and showing of hidden items)

This commit is contained in:
skodak 2007-10-27 15:33:43 +00:00
parent 57068674c6
commit 26ed030543
5 changed files with 105 additions and 33 deletions

View file

@ -59,11 +59,6 @@ class course_settings_form extends moodleform {
$mform->setHelpButton('decimalpoints', array(false, get_string('decimalpoints', 'grades'),
false, true, false, get_string('configdecimalpoints', 'grades')));
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$options = array(-1 => get_string('default', 'grades'),
GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades'));
@ -78,6 +73,25 @@ class course_settings_form extends moodleform {
$mform->setHelpButton('aggregationposition', array(false, get_string('aggregationposition', 'grades'),
false, true, false, get_string('configaggregationposition', 'grades')));
// add setting options for plugins
$types = array('report', 'export', 'import');
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')) {
require_once($CFG->dirroot.'/grade/'.$type.'/'.$plugin.'/lib.php');
$functionname = 'grade_'.$type.'_'.$plugin.'_settings_definition';
if (function_exists($functionname)) {
$mform->addElement('header', 'grade_'.$type.$plugin, get_string('modulename', 'grade'.$type.'_'.$plugin, NULL, $CFG->dirroot.'/grade/'.$type.'/'.$plugin.'/lang/'));
$functionname($mform);
}
}
}
}
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons();
}

View file

@ -29,7 +29,6 @@ require_once $CFG->libdir.'/gradelib.php';
require_once 'form.php';
$courseid = optional_param('id', SITEID, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
if (!$course = get_record('course', 'id', $courseid)) {
print_error('nocourseid');
@ -50,32 +49,27 @@ $returnurl = $CFG->wwwroot.'/grade/index.php?id='.$course->id;
$mform = new course_settings_form();
$data = new object;
$data->id = $course->id;
$data->displaytype = grade_get_setting($course->id, 'displaytype', -1);
$data->decimalpoints = grade_get_setting($course->id, 'decimalpoints',- 1);
$data->aggregationposition = grade_get_setting($course->id, 'aggregationposition', -1);
$settings = grade_get_settings($course->id);
$mform->set_data($data);
$mform->set_data($settings);
if ($mform->is_cancelled()) {
redirect($returnurl);
} else if ($data = $mform->get_data()) {
if ($data->displaytype == -1) {
$data->displaytype = null;
$data = (array)$data;
$general = array('displaytype', 'decimalpoints', 'aggregationposition');
foreach ($data as $key=>$value) {
if (!in_array($key, $general) and strpos($key, 'report_') !== 0
and strpos($key, 'import_') !== 0
and strpos($key, 'export_') !== 0) {
continue;
}
if ($value == -1) {
$value = null;
}
grade_set_setting($course->id, $key, $value);
}
grade_set_setting($course->id, 'displaytype', $data->displaytype);
if ($data->decimalpoints == -1) {
$data->decimalpoints = null;
}
grade_set_setting($course->id, 'decimalpoints', $data->decimalpoints);
if ($data->aggregationposition == -1) {
$data->aggregationposition = null;
}
grade_set_setting($course->id, 'aggregationposition', $data->aggregationposition);
redirect($returnurl);
}