}
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'].'"';
}
// 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 = '';
.$this->get_lang_string('modulename', $object->itemmodule).'"/>';
} else if ($object->itemtype == 'manual') {
//TODO: add manual grading icon
- $icon = '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon" alt="'.$this->get_lang_string('manualgrade', 'grades')
- .'"/>';
+ $icon = '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon" alt="'
+ .$this->get_lang_string('manualgrade', 'grades') .'"/>';
}
-
- $headerhtml .= '<th class="'.$type.$catlevel.$dimmed.'"><a href="'.$this->baseurl.'&sortitemid='
- . $element['object']->id .'">'. $element['object']->get_name()
- . '</a>' . $arrow;
-
+ $headerlink = $this->get_module_link($element['object']->get_name(), $itemmodule, $iteminstance);
+ $headerhtml .= '<th class="'.$type.$catlevel.$dimmed.'">'. $headerlink . $arrow;
$headerhtml .= $this->get_icons($element) . '</th>';
$this->items[$element['object']->sortorder] =& $element['object'];
$this->groupwheresql = " AND gm.groupid = $this->currentgroup ";
}
}
+
+ /**
+ * Returns an arrow icon inside an <a> 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 = '<a href="'.$sort_link .'">' . $arrow . '</a>';
+ 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 '<a href="' . $url . '">' . $modulename . '</a>';
+ }
+
+ return $modulename;
+ }
}
?>
*
* @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
*/
}
$oppositlangdir = ($langdir == 'rtl') ? '_ltr' : '_rtl';
-
+
if ($files) {
/// Produce a list of all the files first
echo '/**************************************'."\n";
if ($langdir == 'rtl') {
$params[] = 'langdir='.get_string('thisdirection');
}
-
+
if ($theme != $CFG->theme) {
$params[] = 'forceconfig='.$theme;
}
}
echo '<div '.$attrtext.'>';
-
+
if (!empty($THEME->customcorners)) {
echo '<div class="wrap">'."\n";
}
require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
print_custom_corners_end();
}
-
+
echo '</div>';
-
+
// IE workaround: if I do it THIS way, it works! WTF?
if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) {
echo '<script type="text/javascript">'."\n//<![CDATA[\n".'elementCookieHide("'.$attributes['id'].'"); '.
function print_arrow($direction='up', $strsort=null, $return=false) {
global $CFG;
- if (!in_array($direction, array('up', 'down', 'right', 'left'))) {
+ if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
return null;
}
case 'down':
$sortdir = 'desc';
break;
+ case 'move':
+ $sortdir = 'asc';
+ break;
default:
$sortdir = null;
break;