. /** * This file contains the definition for the grading table which subclassses easy_table * * @package tool_assignmentupgrade * @copyright 2012 NetSpot {@link http://www.netspot.com.au} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir.'/tablelib.php'); require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/mod/assign/locallib.php'); /** * Extends table_sql to provide a table of assignment submissions * * @package tool_assignmentupgrade * @copyright 2012 NetSpot {@link http://www.netspot.com.au} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_assignmentupgrade_assignments_table extends table_sql implements renderable { /** @var int $perpage */ private $perpage = 10; /** @var int $rownum (global index of current row in table) */ private $rownum = -1; /** @var renderer_base for getting output */ private $output = null; /** @var boolean anyupgradableassignments - True if there is one or more assignments that can upgraded */ public $anyupgradableassignments = false; /** * This table loads a list of the old assignment instances and tests them to see * if they can be upgraded * * @param int $perpage How many per page * @param int $rowoffset The starting row for pagination */ public function __construct($perpage, $rowoffset=0) { global $PAGE; parent::__construct('tool_assignmentupgrade_assignments'); $this->perpage = $perpage; $this->output = $PAGE->get_renderer('tool_assignmentupgrade'); $this->define_baseurl(new moodle_url('/admin/tool/assignmentupgrade/listnotupgraded.php')); $this->anyupgradableassignments = tool_assignmentupgrade_any_upgradable_assignments(); // Do some business - then set the sql. if ($rowoffset) { $this->rownum = $rowoffset - 1; } $fields = 'a.id as id, a.name as name, a.assignmenttype as type, c.shortname as courseshortname, c.id as courseid, COUNT(s.id) as submissioncount'; $from = '{assignment} a JOIN {course} c ON a.course = c.id ' . ' LEFT JOIN {assignment_submissions} s ON a.id = s.assignment'; $where = '1 = 1'; $where .= ' GROUP BY a.id, a.name, a.assignmenttype, c.shortname, c.id '; $this->set_sql($fields, $from, $where, array()); $this->set_count_sql('SELECT COUNT(*) FROM {assignment} a JOIN {course} c ON a.course = c.id', array()); $columns = array(); $headers = array(); $columns[] = 'select'; $headers[] = get_string('select', 'tool_assignmentupgrade') . '