/**
  * Check and set data to sort return comparation function
  * $field field to compare
  * $descending order
  */
 public static function set_order($field, $ascending = true)
 {
     $sortfields = array('name' => array('name'), 'shortdescription' => array('shortdescription'), 'startdate' => array('startdate', 'duedate', 'name'), 'duedate' => array('duedate', 'startdate', 'name'), 'automaticgrading' => array('automaticgrading', 'duedate', 'name'));
     if (isset($sortfields[$field])) {
         self::$fields = $sortfields[$field];
     } else {
         //Unknow field
         self::$fields = $sortfields['duedate'];
     }
     if ($ascending) {
         self::$ascending = -1;
     } else {
         self::$ascending = 1;
     }
 }
Beispiel #2
0
    if ($vpl->get_grade() != 0 && !$instance->example) {
        $no_grade = false;
    }
    if ($instance->startdate > 0) {
        $startdate = true;
    }
    if ($instance->duedate > 0) {
        $duedate = true;
    }
}
//if no instance with grade
$grader = $grader && !$no_grade;
$student = $student && !$no_grade;
//usort of old PHP versions don't call static class functions
if ($sort > '') {
    $corder = new vpl_list_util();
    $corder->set_order($sort, $sortdir == 'down');
    usort($vpls, array($corder, 'cpm'));
}
//Generate table
$table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
$table->head = array('#', $strname, $strshortdescription);
$table->align = array('left', 'left', 'left');
if ($startdate) {
    $table->head[] = $strstartdate;
    $table->align[] = 'center';
}
if ($duedate) {
    $table->head[] = $strduedate;
    $table->align[] = 'center';