// enable outcomes checkbox
$temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT));
+$temp->add(new admin_setting_grade_profilereport());
+
$temp->add(new admin_setting_configselect('grade_aggregationposition', get_string('aggregationposition', 'grades'),
get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
switch ($mode) {
case "grade":
- //TODO: make the report selectable somehow
- $course = get_record('course', 'id', required_param('id', PARAM_INT));
- if (!empty($course->showgrades)) {
- require_once $CFG->libdir.'/gradelib.php';
- require_once $CFG->dirroot.'/grade/lib.php';
- require_once $CFG->dirroot.'/grade/report/user/lib.php';
-
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
-
- //first make sure we have proper final grades - this must be done before constructing of the grade tree
- grade_regrade_final_grades($course->id);
-
- /// return tracking object
- $gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'user', 'courseid'=>$course->id, 'userid'=>$user->id));
- // Create a report instance
- $report = new grade_report_user($course->id, $gpr, $context, $user->id);
-
- // print the page
- echo '<div class="grade-report-user">'; // css fix to share styles with real report page
- print_heading(get_string('modulename', 'gradereport_user'). ' - '.fullname($report->user));
+ if (empty($CFG->grade_profilereport) or !file_exists($CFG->dirroot.'/grade/report/'.$CFG->grade_profilereport.'/lib.php')) {
+ $CFG->grade_profilereport = 'user';
+ }
+ require_once $CFG->libdir.'/gradelib.php';
+ require_once $CFG->dirroot.'/grade/lib.php';
+ require_once $CFG->dirroot.'/grade/report/'.$CFG->grade_profilereport.'/lib.php';
- if ($report->fill_table()) {
- echo $report->print_table(true);
- }
- echo '</div>';
+ $course = get_record('course', 'id', required_param('id', PARAM_INT));
+ $functionname = 'grade_report_'.$CFG->grade_profilereport.'_profilereport';
+ if (function_exists($functionname)) {
+ $functionname($course, $user);
}
break;
$mform->addElement('select', 'report_user_showhiddenitems', get_string('showhiddenitems', 'grades'), $options);
$mform->setHelpButton('report_user_showhiddenitems', array(false, get_string('showhiddenitems', 'grades'),
false, true, false, get_string('configshowhiddenitems', 'grades')));
+}
+
+function grade_report_user_profilereport($course, $user) {
+ if (!empty($course->showgrades)) {
+
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+
+ //first make sure we have proper final grades - this must be done before constructing of the grade tree
+ grade_regrade_final_grades($course->id);
+
+ /// return tracking object
+ $gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'user', 'courseid'=>$course->id, 'userid'=>$user->id));
+ // Create a report instance
+ $report = new grade_report_user($course->id, $gpr, $context, $user->id);
+ // print the page
+ echo '<div class="grade-report-user">'; // css fix to share styles with real report page
+ print_heading(get_string('modulename', 'gradereport_user'). ' - '.fullname($report->user));
+
+ if ($report->fill_table()) {
+ echo $report->print_table(true);
+ }
+ echo '</div>';
+ }
}
+
?>
$string['configgradepublishing'] = 'Enable publishing in exports and imports: Exported grades can be accessed by accessing a URL, without having to log on to a Moodle site. Grades can be imported by accessing such a URL (which means that a moodle site can import grades published by another site). By default only administrators may use this feature, please educate users before adding required capabilities to other roles (dangers of bookmark sharing and download accelerators, IP restrictions, etc.).';
$string['confighiddenasdate'] = 'If user can not see hidden grades show date instead of \'-\'.';
$string['configmeanselection'] = 'Select which types of grades will be included in the column averages. Cells with no grade can be ignored, or counted as 0 (default setting).';
+$string['configprofilereport'] = 'Grade report used on user profile page.';
$string['configquickfeedback'] = 'Quick Feedback adds a text input element in each grade cell on the grader report, allowing you to edit many grades at once. You can then click the Update button to perform all these changes at once, instead of one at a time.';
$string['configquickgrading'] = 'Quick Grading adds a text input element in each grade cell on the grader report, allowing you to edit the feedback for many grades at once. You can then click the Update button to perform all these changes at once, instead of one at a time.';
$string['configrangesdecimalpoints'] = 'The number of decimal points to display for each range, above a column of grades. This can be overriden per grading item.';
$string['prefrows'] = 'Special rows';
$string['prefshow'] = 'Show/hide toggles';
$string['previewrows'] = 'Preview rows';
+$string['profilereport'] = 'User profile report';
$string['publishing'] = 'Publishing';
$string['quickfeedback'] = 'Quick Feedback';
$string['quickgrading'] = 'Quick Grading';
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
+ /**
+ * This function may be used in ancestors for lazy loading of choices
+ */
+ function load_choices() {
+ /*
+ if (!empty($this->choices)) {
+ return;
+ }
+ .... load choices here
+ */
+ }
+
function get_setting() {
global $CFG;
return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
}
function write_setting($data) {
+ $this->load_choices();
// check that what we got was in the original choices
// or that the data is the default setting - needed during install when choices can not be constructed yet
if ($data != $this->defaultsetting and ! in_array($data, array_keys($this->choices))) {
}
function output_html() {
+ $this->load_choices();
if ($this->get_setting() === NULL) {
$current = $this->defaultsetting;
} else {
}
}
+/**
+ * Selection of grade report in user ptofile
+ */
+class admin_setting_grade_profilereport extends admin_setting_configselect {
+ function admin_setting_grade_profilereport() {
+ parent::admin_setting_configselect('grade_profilereport', get_string('profilereport', 'grades'), get_string('configprofilereport', 'grades'), 'user', null);
+ }
+
+ function load_choices() {
+ if (!empty($this->choices)) {
+ return;
+ }
+ $this->choices = array();
+
+ global $CFG;
+ require_once($CFG->libdir.'/gradelib.php');
+
+ foreach (get_list_of_plugins('grade/report') as $plugin) {
+ if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php')) {
+ require_once($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php');
+ $functionname = 'grade_report_'.$plugin.'_profilereport';
+ if (function_exists($functionname)) {
+ $this->choices[$plugin] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'/lang/');
+ }
+ }
+ }
+ }
+}
+
// Code for a function that helps externalpages print proper headers and footers
// N.B.: THIS FUNCTION HANDLES AUTHENTICATION