From 936f1350232745ad05f007cffcce58d62b0f289d Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 13 Jul 2007 05:26:45 +0000 Subject: [PATCH] MDL-9628 New constants in gradelib.php: GRADE_EDIT_URL and GRADE_EDIT_DIR Also renamed $report->get_user_pref() to $report->get_pref() , because the returned preference may come from $CFG if it isn't defined as a user preference. --- grade/report/grader/grader_report.php | 56 +++++++++++++-------------- grade/report/grader/index.php | 8 ++-- lib/gradelib.php | 3 ++ 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/grade/report/grader/grader_report.php b/grade/report/grader/grader_report.php index 42914dd279..79668f8c99 100644 --- a/grade/report/grader/grader_report.php +++ b/grade/report/grader/grader_report.php @@ -150,16 +150,16 @@ class grade_report_grader { $this->gradebookroles = $CFG->gradebookroles; // Grab the grade_tree for this course - $this->gtree = new grade_tree($this->courseid, true, false, $this->get_user_pref('aggregationposition')); + $this->gtree = new grade_tree($this->courseid, true, false, $this->get_pref('aggregationposition')); // base url for sorting by first/last name - $this->baseurl = 'report.php?id='.$this->courseid.'&perpage='.$this->get_user_pref('studentsperpage') + $this->baseurl = 'report.php?id='.$this->courseid.'&perpage='.$this->get_pref('studentsperpage') .'&report=grader&page='.$this->page; // - $this->pbarurl = 'report.php?id='.$this->courseid.'&perpage='.$this->get_user_pref('studentsperpage') + $this->pbarurl = 'report.php?id='.$this->courseid.'&perpage='.$this->get_pref('studentsperpage') .'&report=grader&'; - if ($this->get_user_pref('showgroups')) { + if ($this->get_pref('showgroups')) { $this->setup_groups(); } @@ -174,12 +174,12 @@ class grade_report_grader { * @param string $pref The name of the preference (do not include the grade_report_ prefix) * @return mixed The value of the preference */ - function get_user_pref($pref) { + function get_pref($pref) { global $CFG; if (empty($this->user_prefs[$pref])) { $fullprefname = 'grade_report_' . $pref; - $this->user_prefs[$pref] = get_user_preferences($fullprefname, $CFG->$fullprefname); + $this->user_prefs[$pref] = get_preferences($fullprefname, $CFG->$fullprefname); } return $this->user_prefs[$pref]; } @@ -398,8 +398,8 @@ class grade_report_grader { } else { // Print confirmation dialog $eid = $element['eid']; $strdeletecheckfull = get_string('deletecheck', '', $element['object']->get_name()); - $linkyes = "edit_tree.php?target=$eid&action=delete&confirm=1$this->gtree->commonvars"; - $linkno = "edit_tree.php?$this->gtree->commonvars"; + $linkyes = GRADE_EDIT_URL . "/edit_tree.php?target=$eid&action=delete&confirm=1$this->gtree->commonvars"; + $linkno = GRADE_EDIT_URL . "/edit_tree.php?$this->gtree->commonvars"; notice_yesno($strdeletecheckfull, $linkyes, $linkno); } break; @@ -452,14 +452,14 @@ class grade_report_grader { $this->groupwheresql AND ra.contextid ".get_related_contexts_string($this->context)." ORDER BY g.finalgrade $this->sortorder"; - $this->users = get_records_sql($sql, $this->get_user_pref('studentsperpage') * $this->page, - $this->get_user_pref('studentsperpage')); + $this->users = get_records_sql($sql, $this->get_pref('studentsperpage') * $this->page, + $this->get_pref('studentsperpage')); } else { // default sort // get users sorted by lastname $this->users = get_role_users(@implode(',', $CFG->gradebookroles), $this->context, false, 'u.id, u.firstname, u.lastname', 'u.'.$this->sortitemid .' '. $this->sortorder, - false, $this->page * $this->get_user_pref('studentsperpage'), $this->get_user_pref('studentsperpage'), + false, $this->page * $this->get_pref('studentsperpage'), $this->get_pref('studentsperpage'), $this->currentgroup); // need to cut users down by groups @@ -548,7 +548,7 @@ class grade_report_grader { 'grandtotals' => 'sigma'); $pref_name = 'grade_report_show' . $type; - $show_pref = get_user_preferences($pref_name, $CFG->$pref_name); + $show_pref = get_preferences($pref_name, $CFG->$pref_name); $strshow = get_string('show' . $type, 'grades'); $strhide = get_string('hide' . $type, 'grades'); @@ -762,7 +762,7 @@ class grade_report_grader { $scaleopt[$i] = $scaleoption; } - if ($this->get_user_pref('quickgrading') and $grade->is_editable()) { + if ($this->get_pref('quickgrading') and $grade->is_editable()) { $studentshtml .= choose_from_menu($scaleopt, 'grade_'.$userid.'_'.$item->id, $gradeval, get_string('nograde'), '', -1, true); } elseif ($scale = get_record('scale', 'id', $item->scaleid)) { @@ -780,7 +780,7 @@ class grade_report_grader { } } else if ($item->gradetype != GRADE_TYPE_TEXT) { - if ($this->get_user_pref('quickgrading') and $grade->is_editable()) { + if ($this->get_pref('quickgrading') and $grade->is_editable()) { $studentshtml .= ''; } else { @@ -790,8 +790,8 @@ class grade_report_grader { // If quickfeedback is on, print an input element - if ($this->get_user_pref('quickfeedback') and $grade->is_editable()) { - if ($this->get_user_pref('quickgrading')) { + if ($this->get_pref('quickfeedback') and $grade->is_editable()) { + if ($this->get_pref('quickgrading')) { $studentshtml .= '
'; } $studentshtml .= 'get_user_pref('showgrandtotals')) { + if ($this->get_pref('showgrandtotals')) { /** SQL for finding the SUM grades of all visible users ($CFG->gradebookroles) */ @@ -935,7 +935,7 @@ class grade_report_grader { */ function get_scalehtml() { $scalehtml = ''; - if ($this->get_user_pref('showscales')) { + if ($this->get_pref('showscales')) { $scalehtml = ''.get_string('range','grades').''; foreach ($this->items as $item) { $scalehtml .= ''. get_grade_clean($item->grademin).'-'. get_grade_clean($item->grademax).''; @@ -1000,16 +1000,16 @@ class grade_report_grader { $edit_icon = ''; if ($object->is_editable()) { if ($type == 'category') { - $edit_icon = '' + $edit_icon = '' . ''
                            . $stredit.''. "\n"; } else if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem'){ - $edit_icon = '' + $edit_icon = '' . ''
                            . $stredit.''. "\n"; } else if ($type == 'grade' and ($object->is_editable() or empty($object->id))) { // TODO: change link to use itemid and userid to allow creating of new grade objects - $edit_icon = '' + $edit_icon = '' . '' . $stredit.''. "\n"; } @@ -1019,7 +1019,7 @@ class grade_report_grader { if ($type == 'item' or $type == 'courseitem' or $type == 'categoryitem') { // show calculation icon only when calculation possible if (!$object->is_normal_item() and ($object->gradetype == GRADE_TYPE_SCALE or $object->gradetype == GRADE_TYPE_VALUE)) { - $edit_calculation_icon = '' + $edit_calculation_icon = '' . ''
                                        . $streditcalculation.''. "\n"; } @@ -1051,7 +1051,7 @@ class grade_report_grader { // Prepare expand/contract string $expand_contract = 'switch_minus'; // Default: expanded - $state = get_user_preferences('grade_category_' . $object->id, GRADE_CATEGORY_EXPANDED); + $state = get_preferences('grade_category_' . $object->id, GRADE_CATEGORY_EXPANDED); if ($state == GRADE_CATEGORY_CONTRACTED) { $expand_contract = 'switch_plus'; } @@ -1087,20 +1087,20 @@ class grade_report_grader { } // Calculation icon for items and categories - if ($this->get_user_pref('showcalculations')) { + if ($this->get_pref('showcalculations')) { $html .= $edit_calculation_icon; } - if ($this->get_user_pref('showeyecons')) { + if ($this->get_pref('showeyecons')) { $html .= $show_hide_icon; } - if ($this->get_user_pref('showlocks')) { + if ($this->get_pref('showlocks')) { $html .= $lock_unlock_icon; } // If object is a category, display expand/contract icon - if (get_class($object) == 'grade_category' && $this->get_user_pref('aggregationview') == GRADER_REPORT_AGGREGATION_VIEW_COMPACT) { + if (get_class($object) == 'grade_category' && $this->get_pref('aggregationview') == GRADER_REPORT_AGGREGATION_VIEW_COMPACT) { $html .= $contract_expand_icon; } } else { // Editing mode is off diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index 607e63d9d4..d81b92cff7 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -58,7 +58,7 @@ include('tabs.php'); echo $report->group_selector; echo $report->get_toggles_html(); -print_paging_bar($numusers, $report->page, $report->get_user_pref('studentsperpage'), $report->pbarurl); +print_paging_bar($numusers, $report->page, $report->get_pref('studentsperpage'), $report->pbarurl); echo '
'; $reporthtml = ''; @@ -80,13 +80,13 @@ if ($USER->gradeediting) { echo $reporthtml; // print submit button -if ($USER->gradeediting && ($report->get_user_pref('quickfeedback') || $report->get_user_pref('quickgrading'))) { +if ($USER->gradeediting && ($report->get_pref('quickfeedback') || $report->get_pref('quickgrading'))) { echo '
'; echo ''; } // prints paging bar at bottom for large pages -if ($report->get_user_pref('studentsperpage') >= 20) { - print_paging_bar($numusers, $report->page, $report->get_user_pref('studentsperpage'), $report->pbarurl); +if ($report->get_pref('studentsperpage') >= 20) { + print_paging_bar($numusers, $report->page, $report->get_pref('studentsperpage'), $report->pbarurl); } ?> diff --git a/lib/gradelib.php b/lib/gradelib.php index da703aa053..2da7b29240 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -64,6 +64,9 @@ define('GRADE_HISTORY_INSERT', 1); define('GRADE_HISTORY_UPDATE', 2); define('GRADE_HISTORY_DELETE', 3); +// Common directories +define('GRADE_EDIT_DIR', $CFG->dirroot . '/grade/edit'); +define('GRADE_EDIT_DIR', $CFG->wwwroot . '/grade/edit'); require_once($CFG->libdir . '/grade/grade_category.php'); require_once($CFG->libdir . '/grade/grade_item.php'); -- 2.39.5