mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-9628 Simplified and improved the expanding/collapsing of categories. There are now three view types: full, aggregates only and grades only.
This commit is contained in:
parent
f60c61b1b2
commit
384960dd68
@ -54,8 +54,9 @@ class edit_category_form extends moodleform {
|
||||
// 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);
|
||||
|
@ -521,12 +521,17 @@ class grade_tree {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class grade_report_grader extends grade_report {
|
||||
var $userselect;
|
||||
|
||||
/**
|
||||
* List of collapsed captegories from user perference
|
||||
* List of collapsed categories from user preference
|
||||
* @var array $collapsed
|
||||
*/
|
||||
var $collapsed;
|
||||
@ -72,14 +72,10 @@ class grade_report_grader extends grade_report {
|
||||
// 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 {
|
||||
@ -977,14 +973,19 @@ class grade_report_grader extends grade_report {
|
||||
|
||||
$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');
|
||||
$expand_contract = 'switch_minus'; // Default: expanded
|
||||
$strswitch_minus = $this->get_lang_string('aggregatesonly', 'grades');
|
||||
$strswitch_plus = $this->get_lang_string('gradesonly', 'grades');
|
||||
$strswitch_whole = $this->get_lang_string('fullmode', 'grades');
|
||||
|
||||
if (in_array($element['object']->id, $this->collapsed)) {
|
||||
$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['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="'
|
||||
@ -1008,25 +1009,35 @@ class grade_report_grader extends grade_report {
|
||||
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]);
|
||||
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;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -44,8 +44,9 @@ class grader_report_preferences_form extends moodleform {
|
||||
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'),
|
||||
|
@ -36,7 +36,8 @@ $settings->add(new admin_setting_configselect('grade_report_aggregationposition'
|
||||
$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,
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$plugin->version = 2007080103;
|
||||
$plugin->version = 2007080900;
|
||||
$plugin->requires = 2007080103;
|
||||
|
||||
?>
|
||||
|
@ -23,6 +23,7 @@ $string['aggregatemodeall'] = 'Mode of all grades';
|
||||
$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';
|
||||
@ -138,6 +139,7 @@ $string['finalgradehelp'] = 'The final grade (cached) after all calculations are
|
||||
$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.';
|
||||
@ -171,6 +173,7 @@ $string['gradessettings'] = 'Grade settings';
|
||||
$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';
|
||||
|
@ -69,7 +69,8 @@ define('GRADE_HISTORY_DELETE', 3);
|
||||
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);
|
||||
|
@ -6075,9 +6075,9 @@ function course_scale_used($courseid, $scaleid) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -7178,16 +7178,16 @@ function in_object_vars($var, $object)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -7205,7 +7205,7 @@ function object_array_unique($array, $keep_key_assoc = true) {
|
||||
foreach ($duplicate_keys as $key) {
|
||||
unset($array[$key]);
|
||||
}
|
||||
|
||||
|
||||
return $keep_key_assoc ? $array : array_values($array);
|
||||
}
|
||||
|
||||
|
BIN
pix/t/switch_whole.gif
Normal file
BIN
pix/t/switch_whole.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 B |
Loading…
x
Reference in New Issue
Block a user