From: nicolasconnault Date: Wed, 1 Aug 2007 14:08:50 +0000 (+0000) Subject: MDL-10674 and MDL-10675 finished X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2e3987a935749c9cb12d58dccc05d6b7b3d6a6e3;p=moodle.git MDL-10674 and MDL-10675 finished --- diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index c8b3aa12b1..20ec0b7488 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -432,10 +432,17 @@ class grade_report_grader extends grade_report { } foreach ($row as $columnkey => $element) { + $sort_link = ''; + if (isset($element['object']->id)) { + $sort_link = $this->baseurl.'&sortitemid=' . $element['object']->id; + } + $eid = $element['eid']; $object = $element['object']; $type = $element['type']; $categorystate = @$element['categorystate']; + $itemmodule = null; + $iteminstance = null; if (!empty($element['colspan'])) { $colspan = 'colspan="'.$element['colspan'].'"'; @@ -467,14 +474,17 @@ class grade_report_grader extends grade_report { } // Element is a grade_item else { + $itemmodule = $element['object']->itemmodule; + $iteminstance = $element['object']->iteminstance; + if ($element['object']->id == $this->sortitemid) { if ($this->sortorder == 'ASC') { - $arrow = print_arrow('up', $strsortasc, true); + $arrow = $this->get_sort_arrow('up', $sort_link); } else { - $arrow = print_arrow('down', $strsortdesc, true); + $arrow = $this->get_sort_arrow('down', $sort_link); } } else { - $arrow = ''; + $arrow = $this->get_sort_arrow('move', $sort_link); } $dimmed = ''; @@ -487,15 +497,12 @@ class grade_report_grader extends grade_report { .$this->get_lang_string('modulename', $object->itemmodule).'"/>'; } else if ($object->itemtype == 'manual') { //TODO: add manual grading icon - $icon = ''.$this->get_lang_string('manualgrade', 'grades')
-                              .''; + $icon = ''
+                                .$this->get_lang_string('manualgrade', 'grades') .''; } - - $headerhtml .= ''. $element['object']->get_name() - . '' . $arrow; - + $headerlink = $this->get_module_link($element['object']->get_name(), $itemmodule, $iteminstance); + $headerhtml .= ''. $headerlink . $arrow; $headerhtml .= $this->get_icons($element) . ''; $this->items[$element['object']->sortorder] =& $element['object']; diff --git a/grade/report/lib.php b/grade/report/lib.php index 5b95cdea7a..c457af4dfc 100755 --- a/grade/report/lib.php +++ b/grade/report/lib.php @@ -342,5 +342,50 @@ class grade_report { $this->groupwheresql = " AND gm.groupid = $this->currentgroup "; } } + + /** + * Returns an arrow icon inside an tag, for the purpose of sorting a column. + * @param string $direction + * @param string $sort_link + * @param string HTML + */ + function get_sort_arrow($direction='move', $sort_link=null) { + $matrix = array('up' => 'asc', 'down' => 'desc', 'move' => 'asc'); + $strsort = $this->get_lang_string('sort' . $matrix[$direction]); + $arrow = print_arrow($direction, $strsort, true); + $html = '' . $arrow . ''; + return $html; + } + + /** + * Builds and returns a HTML link to the grade or view page of the module given. + * If no itemmodule is given, only the name of the category/item is returned, no link. + * @param string $modulename The shortname of the module, will become the visible header + * @param string $itemmodule The name of the module type (e.g. assignment, quiz...) + * @param int $iteminstance The instance number of the module + * @return string HTML + */ + function get_module_link($modulename, $itemmodule=null, $iteminstance=null) { + global $CFG, $COURSE; + + $link = null; + if (!is_null($itemmodule) AND !is_null($iteminstance)) { + $coursemodule = get_coursemodule_from_instance($itemmodule, $iteminstance, $COURSE->id); + + $dir = $CFG->dirroot . "/mod/$itemmodule/"; + $url = $CFG->wwwroot . "/mod/$itemmodule/"; + + if (file_exists($dir . 'grade.php')) { + $url .= 'grade.php'; + } else { + $url .= 'view.php'; + } + + $url .= "?id=$coursemodule->id"; + return '' . $modulename . ''; + } + + return $modulename; + } } ?> diff --git a/lib/weblib.php b/lib/weblib.php index 214d12d3b1..419db6a822 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2136,7 +2136,7 @@ function convert_urls_into_links(&$text) { * * @param string $needle The string to search for * @param string $haystack The string to search for $needle in - * @param int $case whether to do case-sensitive or insensitive matching. + * @param int $case whether to do case-sensitive or insensitive matching. * @return string * @todo Finish documenting this function */ @@ -2897,7 +2897,7 @@ function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='', $force } $oppositlangdir = ($langdir == 'rtl') ? '_ltr' : '_rtl'; - + if ($files) { /// Produce a list of all the files first echo '/**************************************'."\n"; @@ -2979,7 +2979,7 @@ function theme_setup($theme = '', $params=NULL) { if ($langdir == 'rtl') { $params[] = 'langdir='.get_string('thisdirection'); } - + if ($theme != $CFG->theme) { $params[] = 'forceconfig='.$theme; } @@ -5839,7 +5839,7 @@ function print_side_block_start($heading='', $attributes = array()) { } echo '
'; - + if (!empty($THEME->customcorners)) { echo '
'."\n"; } @@ -5884,9 +5884,9 @@ function print_side_block_end($attributes = array()) { require_once($CFG->dirroot.'/lib/custom_corners_lib.php'); print_custom_corners_end(); } - + echo '
'; - + // IE workaround: if I do it THIS way, it works! WTF? if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) { echo '