// user preferences
$mform->addElement('header', 'general', get_string('userpreferences', 'grades'));
$options = array(GRADE_REPORT_PREFERENCE_DEFAULT => get_string('default', 'grades'),
- GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('full', 'grades'),
- GRADE_REPORT_AGGREGATION_VIEW_COMPACT => get_string('compact', 'grades'));
+ GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('fullmode', 'grades'),
+ GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
+ GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades'));
$label = get_string('aggregationview', 'grades') . ' (' . get_string('default', 'grades')
. ': ' . $options[$CFG->grade_report_aggregationview] . ')';
$mform->addElement('select', 'pref_aggregationview', $label, $options);
return;
}
- if (in_array($element['object']->id, $collapsed)) {
+ if (in_array($element['object']->id, $collapsed['aggregatesonly'])) {
$category_item = reset($element['children']); //keep only category item
$element['children'] = array(key($element['children'])=>$category_item);
} else {
- foreach ($element['children'] as $sortorder=>$child) {
+ if (in_array($element['object']->id, $collapsed['gradesonly'])) { // Remove category item
+ reset($element['children']);
+ $first_key = key($element['children']);
+ unset($element['children'][$first_key]);
+ }
+ foreach ($element['children'] as $sortorder=>$child) { // Recurse through the element's children
grade_tree::category_collapse($element['children'][$sortorder], $collapsed);
}
}
var $userselect;
/**
- * List of collapsed captegories from user perference
+ * List of collapsed categories from user preference
* @var array $collapsed
*/
var $collapsed;
// load collapsed settings for this report
if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {
$this->collapsed = unserialize($collapsed);
- foreach ($this->collapsed as $key=>$id) {
- if ($this->get_pref('aggregationview', $id) == GRADE_REPORT_AGGREGATION_VIEW_FULL) {
- unset($this->collapsed[$key]); // full view categories can not be collapsed
- }
- }
} else {
- $this->collapsed = array();
+ $this->collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
}
+
if (empty($CFG->enableoutcomes)) {
$nooutcomes = false;
} else {
$contract_expand_icon = '';
// If object is a category, display expand/contract icon
- if ($element['type'] == 'category' && $this->get_pref('aggregationview', $element['object']->id) == GRADE_REPORT_AGGREGATION_VIEW_COMPACT) {
+ if ($element['type'] == 'category') {
// Load language strings
- $strswitch_minus = $this->get_lang_string('contract', 'grades');
- $strswitch_plus = $this->get_lang_string('expand', 'grades');
+ $strswitch_minus = $this->get_lang_string('aggregatesonly', 'grades');
+ $strswitch_plus = $this->get_lang_string('gradesonly', 'grades');
+ $strswitch_whole = $this->get_lang_string('fullmode', 'grades');
+
$expand_contract = 'switch_minus'; // Default: expanded
+ // $this->get_pref('aggregationview', $element['object']->id) == GRADE_REPORT_AGGREGATION_VIEW_COMPACT
- if (in_array($element['object']->id, $this->collapsed)) {
+ if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) {
$expand_contract = 'switch_plus';
+ } elseif (in_array($element['object']->id, $this->collapsed['gradesonly'])) {
+ $expand_contract = 'switch_whole';
}
$url = $this->gpr->get_return_url(null, array('target'=>$element['eid'], 'action'=>$expand_contract, 'sesskey'=>sesskey()));
$contract_expand_icon = '<a href="'.$url.'"><img src="'.$CFG->pixpath.'/t/'.$expand_contract.'.gif" class="iconsmall" alt="'
if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {
$collapsed = unserialize($collapsed);
} else {
- $collapsed = array();
+ $collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
}
switch ($action) {
- case 'switch_minus':
- if (!in_array($targetid, $collapsed)) {
- $collapsed[] = $targetid;
+ case 'switch_minus': // Add category to array of aggregatesonly
+ if (!in_array($targetid, $collapsed['aggregatesonly'])) {
+ $collapsed['aggregatesonly'][] = $targetid;
set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsed));
}
break;
- case 'switch_plus':
- $key = array_search($targetid, $collapsed);
+ case 'switch_plus': // Remove category from array of aggregatesonly, and add it to array of gradesonly
+ $key = array_search($targetid, $collapsed['aggregatesonly']);
if ($key !== false) {
- unset($collapsed[$key]);
- set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsed));
+ unset($collapsed['aggregatesonly'][$key]);
}
+ if (!in_array($targetid, $collapsed['gradesonly'])) {
+ $collapsed['gradesonly'][] = $targetid;
+ }
+ set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsed));
break;
+ case 'switch_whole': // Remove the category from the array of collapsed cats
+ $key = array_search($targetid, $collapsed['gradesonly']);
+ if ($key !== false) {
+ unset($collapsed['gradesonly'][$key]);
+ set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsed));
+ }
+ break;
default:
break;
}
GRADE_REPORT_AGGREGATION_POSITION_LEFT => get_string('left', 'grades'),
GRADE_REPORT_AGGREGATION_POSITION_RIGHT => get_string('right', 'grades')),
'aggregationview' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
- GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('full', 'grades'),
- GRADE_REPORT_AGGREGATION_VIEW_COMPACT => get_string('compact', 'grades')),
+ GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('fullmode', 'grades'),
+ GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
+ GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades')),
'gradedisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
$settings->add(new admin_setting_configselect('grade_report_aggregationview', get_string('aggregationview', 'grades'),
get_string('configaggregationview', 'grades'), false,
array(GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('full', 'grades'),
- GRADE_REPORT_AGGREGATION_VIEW_COMPACT => get_string('compact', 'grades'))));
+ GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
+ GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades'))));
$settings->add(new admin_setting_configselect('grade_report_gradedisplaytype', get_string('gradedisplaytype', 'grades'),
get_string('configgradedisplaytype', 'grades'), false,
<?PHP // $Id$
-$plugin->version = 2007080103;
+$plugin->version = 2007080900;
$plugin->requires = 2007080103;
?>
$string['aggregatemodegraded'] = 'Mode of non-empty grades';
$string['aggregateoutcomes'] = 'Include outcomes in aggregation';
$string['aggregateoutcomeshelp'] = 'Including outcomes in aggregation may not lead to the desired overall grade, so you have the option to include or leave them out.';
+$string['aggregatesonly'] = 'Aggregates only';
$string['aggregateweightedmeanall'] = 'Weighted mean of all grades';
$string['aggregateweightedmeangraded'] = 'Weighted mean of non-empty grades';
$string['aggregation'] = 'Aggregation';
$string['forelementtypes'] = ' for the selected $a';
$string['forstudents'] = 'For Students';
$string['full'] = 'Full';
+$string['fullmode'] = 'Full view';
$string['grade'] = 'Grade';
$string['gradebook'] = 'Gradebook';
$string['gradebookhiddenerror'] = 'The gradebook is currently set to hide everything from students.';
$string['gradepreferences'] = 'Grade Preferences';
$string['gradepreferenceshelp'] = 'Grade Preferences Help';
$string['grades'] = 'Grades';
+$string['gradesonly'] = 'Grades only';
$string['gradetype'] = 'Grade type';
$string['gradetypehelp'] = 'The type of grade this item uses. Can be of 4 types: none, value, scale and text. Only The value and scale types can be aggregated.';
$string['gradeview'] = 'View Grade';
define('GRADE_REPORT_AGGREGATION_POSITION_LEFT', 0);
define('GRADE_REPORT_AGGREGATION_POSITION_RIGHT', 1);
define('GRADE_REPORT_AGGREGATION_VIEW_FULL', 0);
-define('GRADE_REPORT_AGGREGATION_VIEW_COMPACT', 1);
+define('GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY', 1);
+define('GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY', 1);
define('GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL', 0);
define('GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE', 1);
define('GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER', 2);
}
}
}
-
+
// check if any course grade item makes use of the scale
- $return += count_records('grade_items', 'courseid', $courseid, 'scaleid', $scaleid);
+ $return += count_records('grade_items', 'courseid', $courseid, 'scaleid', $scaleid);
}
return $return;
}
}
/**
- * Returns an array without repeated objects.
+ * Returns an array without repeated objects.
* This function is similar to array_unique, but for arrays that have objects as values
- *
+ *
* @param unknown_type $array
* @param unknown_type $keep_key_assoc
* @return unknown
*/
function object_array_unique($array, $keep_key_assoc = true) {
$duplicate_keys = array();
- $tmp = array();
+ $tmp = array();
foreach ($array as $key=>$val) {
// convert objects to arrays, in_array() does not support objects
foreach ($duplicate_keys as $key) {
unset($array[$key]);
}
-
+
return $keep_key_assoc ? $array : array_values($array);
}