Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 19, 2007
1 parent deb2988 commit d297269
Show file tree
Hide file tree
Showing 13 changed files with 284 additions and 162 deletions.
29 changes: 16 additions & 13 deletions admin/settings/grades.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// enable outcomes checkbox
$temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT));
// enable publishing in exports/imports
$temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0, PARAM_INT));

$temp->add(new admin_setting_configselect('grade_aggregationposition', get_string('aggregationposition', 'grades'),
get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
Expand All @@ -33,6 +31,11 @@
'4' => '4',
'5' => '5')));

$temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0, PARAM_INT));

// enable publishing in exports/imports
$temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0, PARAM_INT));

$temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
Expand All @@ -46,20 +49,11 @@
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5')));
'5' => '5')));

$temp->add(new admin_setting_special_gradeexport());
$ADMIN->add('grades', $temp);

/// Scales and outcomes

$scales = new admin_externalpage('scales', get_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
$ADMIN->add('grades', $scales);
$outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
$ADMIN->add('grades', $outcomes);
$letters = new admin_externalpage('letters', get_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/edit.php', 'moodle/grade:manageletters');
$ADMIN->add('grades', $letters);

/// Grade category settings
$temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'));

Expand Down Expand Up @@ -96,6 +90,15 @@

$ADMIN->add('grades', $temp);

/// Scales and outcomes

$scales = new admin_externalpage('scales', get_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
$ADMIN->add('grades', $scales);
$outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
$ADMIN->add('grades', $outcomes);
$letters = new admin_externalpage('letters', get_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/edit.php', 'moodle/grade:manageletters');
$ADMIN->add('grades', $letters);

// The plugins must implement a settings.php file that adds their admin settings to the $settings object

// Reports
Expand Down
30 changes: 2 additions & 28 deletions grade/edit/tree/calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,35 +187,9 @@ function get_grade_tree(&$gtree, $element, $current_itemid=null, $errors=null) {
}
}

$icon = '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="icon" alt=""/>' . "\n";
$icon = $gtree->get_element_icon($element);
$last = '';
$catcourseitem = false;

switch ($type) {
case 'item':
if ($object->itemtype == 'mod') {
$icon = '<img src="'.$CFG->modpixpath.'/'.$object->itemmodule.'/icon.gif" class="icon" alt="'
. get_string('modulename', $object->itemmodule).'"/>' . "\n";
} else if ($object->itemtype == 'manual') {
//TODO: add manual grading icon
if (empty($object->outcomeid)) {
$icon = '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon" alt="'
. get_string('manualgrade', 'grades').'"/>' . "\n"; // TODO: localize
} else {
$icon = '<img src="'.$CFG->pixpath.'/i/outcomes.gif" class="icon" alt="'
. get_string('outcome', 'grades').'"/>' . "\n";
}
}
break;
case 'courseitem':
case 'categoryitem':
$icon = '<img src="'.$CFG->pixpath.'/i/category_grade.gif" class="icon" alt="'.get_string('categorygrade').'"/>' . "\n"; // TODO: localize
$catcourseitem = true;
break;
case 'category':
$icon = '<img src="'.$CFG->pixpath.'/f/folder.gif" class="icon" alt="'.get_string('category').'"/>' . "\n";
break;
}
$catcourseitem = ($element['type'] == 'courseitem' or $element['type'] == 'categoryitem');

if ($type != 'category') {
$return_string .= '<li class="'.$type.'">'.$icon.$name.'</li>' . "\n";
Expand Down
26 changes: 15 additions & 11 deletions grade/edit/tree/category_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function definition() {
GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'));

// visible elements
$mform->addElement('header', 'general', get_string('gradecategory', 'grades'));
$mform->addElement('header', 'gradecat', get_string('gradecategory', 'grades'));
$mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));

if ($CFG->grade_aggregation == -1) {
Expand All @@ -62,12 +62,14 @@ function definition() {
$mform->addElement('static', 'aggregateonlygraded', get_string('aggregateonlygraded', 'grades'));
}

if (!empty($CFG->enableoutcomes) && $CFG->grade_aggregateoutcomes == -1) {
$mform->addElement('advcheckbox', 'aggregateoutcomes', get_string('aggregateoutcomes', 'grades'));
$mform->setHelpButton('aggregateoutcomes', array(false, get_string('aggregateoutcomes', 'grades'),
false, true, false, get_string('aggregateoutcomeshelp', 'grades')));
} else {
$mform->addElement('static', 'aggregateoutcomes', get_string('aggregateoutcomes', 'grades'));
if (!empty($CFG->enableoutcomes)) {
if($CFG->grade_aggregateoutcomes == -1) {
$mform->addElement('advcheckbox', 'aggregateoutcomes', get_string('aggregateoutcomes', 'grades'));
$mform->setHelpButton('aggregateoutcomes', array(false, get_string('aggregateoutcomes', 'grades'),
false, true, false, get_string('aggregateoutcomeshelp', 'grades')));
} else {
$mform->addElement('static', 'aggregateoutcomes', get_string('aggregateoutcomes', 'grades'));
}
}

if ($CFG->grade_aggregatesubcats == -1) {
Expand Down Expand Up @@ -111,7 +113,7 @@ function definition() {
}

// user preferences
$mform->addElement('header', 'general', get_string('userpreferences', 'grades'));
$mform->addElement('header', 'userpref', get_string('myreportpreferences', 'grades'));
$options = array(GRADE_REPORT_PREFERENCE_DEFAULT => get_string('default', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('fullmode', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
Expand Down Expand Up @@ -158,9 +160,11 @@ function definition_after_data() {
$agg_el->setValue($checkbox_values[$CFG->grade_aggregateonlygraded]);
}

if ($CFG->grade_aggregateoutcomes != -1) {
$agg_el =& $mform->getElement('aggregateoutcomes');
$agg_el->setValue($checkbox_values[$CFG->grade_aggregateoutcomes]);
if (!empty($CFG->enableoutcomes)) {
if ($CFG->grade_aggregateoutcomes != -1) {
$agg_el =& $mform->getElement('aggregateoutcomes');
$agg_el->setValue($checkbox_values[$CFG->grade_aggregateoutcomes]);
}
}

if ($CFG->grade_aggregatesubcats != -1) {
Expand Down
30 changes: 2 additions & 28 deletions grade/edit/tree/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,35 +201,9 @@ function print_grade_tree(&$gtree, $element, $moving, &$gpr, $switch, $switchedl
$actions .= $gtree->get_hiding_icon($element, $gpr);

/// prepare icon
$icon = '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="icon" alt=""/>';
$icon = $gtree->get_element_icon($element);
$last = '';
$catcourseitem = false;
switch ($element['type']) {
case 'item':
if ($object->itemtype == 'mod') {
$icon = '<img src="'.$CFG->modpixpath.'/'.$object->itemmodule.'/icon.gif" class="icon" alt="'
. get_string('modulename', $object->itemmodule).'"/>';
} else if ($object->itemtype == 'manual') {
//TODO: add manual grading icon
if (empty($object->outcomeid)) {
$icon = '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon" alt="'
. get_string('manualgrade', 'grades').'"/>'; // TODO: localize
} else {
$icon = '<img src="'.$CFG->pixpath.'/i/outcomes.gif" class="icon" alt="'
. get_string('outcome', 'grades').'"/>';

}
}
break;
case 'courseitem':
case 'categoryitem':
$icon = '<img src="'.$CFG->pixpath.'/i/category_grade.gif" class="icon" alt="'.get_string('categorygrade').'"/>'; // TODO: localize
$catcourseitem = true;
break;
case 'category':
$icon = '<img src="'.$CFG->pixpath.'/f/folder.gif" class="icon" alt="'.get_string('category').'"/>';
break;
}
$catcourseitem = ($element['type'] == 'courseitem' or $element['type'] == 'categoryitem');

/// prepare move target if needed
$moveto = '';
Expand Down
57 changes: 56 additions & 1 deletion grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,6 @@ function get_grade_eid($grade_grade) {
return 'g'.$grade_grade->id;
}
}

}

/**
Expand Down Expand Up @@ -919,6 +918,7 @@ function grade_tree($courseid, $fillers=true, $category_grade_last=false, $colla
}

grade_tree::fill_levels($this->levels, $this->top_element, 0);

}

/**
Expand Down Expand Up @@ -1344,6 +1344,61 @@ function get_calculation_icon($element, $gpr) {

return $calculation_icon;
}

/**
* Returns icon of element
* @param object $element
* @param bool $spacerifnone return spacer if no icon found
* @return string icon or spacer
*/
function get_element_icon(&$element, $spacerifnone=true) {
global $CFG;

switch ($element['type']) {
case 'item':
case 'courseitem':
case 'categoryitem':
if ($element['object']->is_calculated()) {
return '<img src="'.$CFG->pixpath.'/i/calc.gif" class="icon" alt="'.get_string('calculation', 'grades').'"/>';

} else if (($element['object']->is_course_item() or $element['object']->is_category_item())
and ($element['object']->gradetype == GRADE_TYPE_SCALE or $element['object']->gradetype == GRADE_TYPE_VALUE)) {
if ($category = $element['object']->get_item_category()) {
switch ($category->aggregation) {
case GRADE_AGGREGATE_MEAN:
case GRADE_AGGREGATE_MEDIAN:
case GRADE_AGGREGATE_WEIGHTED_MEAN:
case GRADE_AGGREGATE_EXTRACREDIT_MEAN:
return '<img src="'.$CFG->pixpath.'/i/agg_mean.gif" class="icon" alt="'.get_string('aggregation', 'grades').'"/>';
//case GRADE_AGGREGATE_SUM:
//return '<img src="'.$CFG->pixpath.'/i/agg_sum.gif" class="icon" alt="'.get_string('aggregation', 'grades').'"/>';
}
}

} else if ($element['object']->itemtype == 'mod') {
return '<img src="'.$CFG->modpixpath.'/'.$element['object']->itemmodule.'/icon.gif" class="icon" alt="'
.get_string('modulename', $element['object']->itemmodule).'"/>';

} else if ($element['object']->itemtype == 'manual') {
if ($element['object']->is_outcome_item()) {
return '<img src="'.$CFG->pixpath.'/i/outcomes.gif" class="icon" alt="'.get_string('outcome', 'grades').'"/>';
} else {
//TODO: add better icon
return '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon" alt="'.get_string('manualitem', 'grades').'"/>';
}
}
break;

case 'category':
return '<img src="'.$CFG->pixpath.'/f/folder.gif" class="icon" alt="'.get_string('category', 'grades').'"/>';
}

if ($spacerifnone) {
return '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="icon" alt=""/>';
} else {
return '';
}
}
}

?>
2 changes: 2 additions & 0 deletions grade/report/grader/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
}

$report->load_users();


$numusers = $report->get_numusers();
$report->load_final_grades();

Expand Down
33 changes: 24 additions & 9 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ function load_final_grades() {

$userids = array_keys($this->users);


if ($grades = get_records_sql($sql)) {
foreach ($grades as $graderec) {
if (in_array($graderec->userid, $userids)) {
if (in_array($graderec->userid, $userids) and array_key_exists($graderec->itemid, $this->gtree->items)) { // some items may not be present!!
$this->grades[$graderec->userid][$graderec->itemid] = new grade_grade($graderec, false);
$this->grades[$graderec->userid][$graderec->itemid]->grade_item =& $this->gtree->items[$graderec->itemid]; // db caching
}
Expand Down Expand Up @@ -603,20 +604,23 @@ function get_headerhtml() {
*/
function get_studentshtml() {
global $CFG, $USER;

$studentshtml = '';
$strfeedback = $this->get_lang_string("feedback");
$strgrade = $this->get_lang_string('grade');
$strfeedback = $this->get_lang_string("feedback");
$strgrade = $this->get_lang_string('grade');
$gradetabindex = 1;
$showuserimage = $this->get_pref('showuserimage');
$numusers = count($this->users);
$numusers = count($this->users);

// Preload scale objects for items with a scaleid
$scales_list = '';
$tabindices = array();

foreach ($this->gtree->items as $item) {
if (!empty($item->scaleid)) {
$scales_list .= "$item->scaleid,";
}

$tabindices[$item->id]['grade'] = $gradetabindex;
$tabindices[$item->id]['feedback'] = $gradetabindex + $numusers;
$gradetabindex += $numusers * 2;
Expand All @@ -633,9 +637,13 @@ function get_studentshtml() {
foreach ($this->users as $userid => $user) {

if ($canviewhidden) {
$hiding_affected = array();
$altered = array();
$unknown = array();
} else {
$hiding_affected = grade_grade::get_hiding_affected($this->grades[$userid], $this->gtree->items);
$altered = $hiding_affected['altered'];
$unknown = $hiding_affected['unknown'];
unset($hiding_affected);
}

$columncount = 0;
Expand All @@ -651,17 +659,24 @@ function get_studentshtml() {

foreach ($this->gtree->items as $itemid=>$unused) {
$item =& $this->gtree->items[$itemid];
$grade = $this->grades[$userid][$item->id];

// Get the decimal points preference for this item
$decimalpoints = $item->get_decimals();

$grade = $this->grades[$userid][$item->id];
$gradeval = $grade->finalgrade;
if (in_array($itemid, $unknown)) {
$gradeval = null;
} else if (array_key_exists($itemid, $altered)) {
$gradeval = $altered[$itemid];
} else {
$gradeval = $grade->finalgrade;
}

// MDL-11274
// Hide grades in the grader report if the current grader doesn't have 'moodle/grade:viewhidden'
if (!$canviewhidden and ($grade->is_hidden() or in_array($itemid, $hiding_affected))) {
if (!is_null($gradeval) and $grade->is_hidden()) {
if (!$canviewhidden and $grade->is_hidden()) {
if (!empty($CFG->grade_hiddenasdate) and !is_null($grade->finalgrade) and !$item->is_category_item() and !$item->is_course_item()) {
// the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records
$studentshtml .= '<td class="cell c'.$columncount++.'">'.userdate($grade->timecreated,get_string('strftimedatetimeshort')).'</td>';
} else {
$studentshtml .= '<td class="cell c'.$columncount++.'">-</td>';
Expand Down
Loading

0 comments on commit d297269

Please sign in to comment.