Artem Andreev
14 years ago
7 changed files with 430 additions and 176 deletions
@ -1,118 +0,0 @@ |
|||||
<?php // $Id: export_form.php,v 1.2.2.3 2009/03/11 18:17:38 dlnsk Exp $
|
|
||||
|
|
||||
require_once($CFG->libdir.'/formslib.php'); |
|
||||
|
|
||||
class mod_attforblock_export_form extends moodleform { |
|
||||
|
|
||||
function definition() { |
|
||||
|
|
||||
global $CFG, $USER; |
|
||||
$mform =& $this->_form; |
|
||||
|
|
||||
$course = $this->_customdata['course']; |
|
||||
$cm = $this->_customdata['cm']; |
|
||||
// $coursecontext = $this->_customdata['coursecontext']; |
|
||||
$modcontext = $this->_customdata['modcontext']; |
|
||||
// $forum = $this->_customdata['forum']; |
|
||||
// $post = $this->_customdata['post']; // hack alert |
|
||||
|
|
||||
|
|
||||
$mform->addElement('header', 'general', get_string('export','quiz')); |
|
||||
$mform->setHelpButton('general', array('export', get_string('export','quiz'), 'attforblock')); |
|
||||
|
|
||||
// $mform->addElement('date_selector', 'sessiondate', get_string('sessiondate','attforblock')); |
|
||||
$groupmode=groups_get_activity_groupmode($cm); |
|
||||
$groups = groups_get_activity_allowed_groups($cm, $USER->id); |
|
||||
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) { |
|
||||
$grouplist[0] = get_string('allparticipants'); |
|
||||
} |
|
||||
if ($groups) { |
|
||||
foreach ($groups as $group) { |
|
||||
$grouplist[$group->id] = $group->name; |
|
||||
} |
|
||||
} |
|
||||
$mform->addElement('select', 'group', get_string('group'), $grouplist); |
|
||||
|
|
||||
$ident = array(); |
|
||||
$ident[] =& MoodleQuickForm::createElement('checkbox', 'id', '', get_string('studentid', 'attforblock')); |
|
||||
$ident[] =& MoodleQuickForm::createElement('checkbox', 'uname', '', get_string('username')); |
|
||||
$mform->addGroup($ident, 'ident', get_string('identifyby','attforblock'), array('<br />'), true); |
|
||||
$mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
// for ($i=0; $i<=23; $i++) { |
|
||||
// $hours[$i] = sprintf("%02d",$i); |
|
||||
// } |
|
||||
// for ($i=0; $i<60; $i+=5) { |
|
||||
// $minutes[$i] = sprintf("%02d",$i); |
|
||||
// } |
|
||||
// $stime = array(); |
|
||||
// $stime[] =& MoodleQuickForm::createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true); |
|
||||
// $stime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true); |
|
||||
// $mform->addGroup($stime, 'stime', get_string('sessionstarttime','attforblock'), array(' '), true); |
|
||||
|
|
||||
// $durtime = array(); |
|
||||
// $durtime[] =& MoodleQuickForm::createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true); |
|
||||
// $durtime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true); |
|
||||
// $mform->addGroup($durtime, 'durtime', get_string('duration','attforblock'), array(' '), true); |
|
||||
|
|
||||
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall','attforblock'), get_string('yes')); |
|
||||
$mform->setDefault('includeallsessions', true); |
|
||||
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken','attforblock'), get_string('yes')); |
|
||||
$mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod','attforblock')); |
|
||||
$mform->setDefault('sessionstartdate', $course->startdate); |
|
||||
$mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked'); |
|
||||
$mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod','attforblock')); |
|
||||
$mform->disabledIf('sessionenddate', 'includeallsessions', 'checked'); |
|
||||
|
|
||||
$mform->addElement('select', 'format', get_string('format'), |
|
||||
array('excel' => get_string('downloadexcel','attforblock'), |
|
||||
'ooo' => get_string('downloadooo','attforblock'), |
|
||||
'text' => get_string('downloadtext','attforblock') |
|
||||
)); |
|
||||
|
|
||||
// $opts = array(); |
|
||||
// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Mon', '', get_string('monday','calendar')); |
|
||||
//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Tue', '', get_string('tuesday','calendar')); |
|
||||
//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Wed', '', get_string('wednesday','calendar')); |
|
||||
//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Thu', '', get_string('thursday','calendar')); |
|
||||
//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Fri', '', get_string('friday','calendar')); |
|
||||
//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Sat', '', get_string('saturday','calendar')); |
|
||||
// $mform->addGroup($opts, 'opts', get_string('sessiondays','attforblock'), array(' '), true); |
|
||||
// $mform->disabledIf('opts', 'addmultiply', 'notchecked'); |
|
||||
// |
|
||||
// $period = array(1=>1,2,3,4,5,6,7,8); |
|
||||
// $periodgroup = array(); |
|
||||
// $periodgroup[] =& MoodleQuickForm::createElement('select', 'period', '', $period, false, true); |
|
||||
// $periodgroup[] =& MoodleQuickForm::createElement('static', 'perioddesc', '', get_string('week','attforblock')); |
|
||||
// $mform->addGroup($periodgroup, 'periodgroup', get_string('period','attforblock'), array(' '), false); |
|
||||
// $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked'); |
|
||||
// |
|
||||
// $mform->addElement('text', 'sdescription', get_string('description', 'attforblock'), 'size="48"'); |
|
||||
// $mform->setType('sdescription', PARAM_TEXT); |
|
||||
// $mform->addRule('sdescription', get_string('maximumchars', '', 100), 'maxlength', 100, 'client'); |
|
||||
|
|
||||
//------------------------------------------------------------------------------- |
|
||||
// buttons |
|
||||
$submit_string = get_string('ok'); |
|
||||
$this->add_action_buttons(false, $submit_string); |
|
||||
|
|
||||
$mform->addElement('hidden', 'id', $cm->id); |
|
||||
// $mform->addElement('hidden', 'action', 'add'); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
// function validation($data, $files) { |
|
||||
// $errors = parent::validation($data, $files); |
|
||||
// if (($data['timeend']!=0) && ($data['timestart']!=0) |
|
||||
// && $data['timeend'] <= $data['timestart']) { |
|
||||
// $errors['timeend'] = get_string('timestartenderror', 'forum'); |
|
||||
// } |
|
||||
// return $errors; |
|
||||
// } |
|
||||
|
|
||||
} |
|
||||
?> |
|
@ -0,0 +1,193 @@ |
|||||
|
<?php |
||||
|
|
||||
|
/** |
||||
|
* Export attendance sessions |
||||
|
* |
||||
|
* @package mod |
||||
|
* @subpackage attforblock |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
require_once(dirname(__FILE__).'/../../config.php'); |
||||
|
require_once(dirname(__FILE__).'/locallib.php'); |
||||
|
require_once(dirname(__FILE__).'/export_form.php'); |
||||
|
require_once(dirname(__FILE__).'/renderables.php'); |
||||
|
require_once(dirname(__FILE__).'/renderhelpers.php'); |
||||
|
|
||||
|
$id = required_param('id', PARAM_INT); |
||||
|
|
||||
|
$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); |
||||
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); |
||||
|
$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); |
||||
|
|
||||
|
require_login($course, true, $cm); |
||||
|
|
||||
|
$att = new attforblock($att, $cm, $course, $PAGE->context); |
||||
|
|
||||
|
$att->perm->require_export_capability(); |
||||
|
|
||||
|
$PAGE->set_url($att->url_export()); |
||||
|
$PAGE->set_title($course->shortname. ": ".$att->name); |
||||
|
$PAGE->set_heading($course->fullname); |
||||
|
$PAGE->set_cacheable(true); |
||||
|
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock')); |
||||
|
$PAGE->navbar->add(get_string('export', 'quiz')); |
||||
|
|
||||
|
$formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context); |
||||
|
$mform = new mod_attforblock_export_form($att->url_export(), $formparams); |
||||
|
|
||||
|
if ($mform->is_submitted()) { |
||||
|
$formdata = $mform->get_data(); |
||||
|
|
||||
|
$pageparams = new att_page_with_filter_controls(); |
||||
|
$pageparams->init($cm); |
||||
|
$pageparams->group = $formdata->group; |
||||
|
$pageparams->set_current_sesstype($formdata->group ? $formdata->group : att_page_with_filter_controls::SESSTYPE_ALL); |
||||
|
if (isset($formdata->includeallsessions)) { |
||||
|
if (isset($formdata->includenottaken)) { |
||||
|
$pageparams->view = VIEW_ALL; |
||||
|
} else { |
||||
|
$pageparams->view = VIEW_ALLPAST; |
||||
|
$pageparams->curdate = time(); |
||||
|
} |
||||
|
$pageparams->init_start_end_date(); |
||||
|
} else { |
||||
|
$pageparams->startdate = $formdata->sessionstartdate; |
||||
|
$pageparams->enddate = $formdata->sessionenddate; |
||||
|
} |
||||
|
$att->pageparams = $pageparams; |
||||
|
|
||||
|
$reportdata = new attforblock_report_data($att); |
||||
|
if ($reportdata->users) { |
||||
|
$filename = clean_filename($course->shortname.'_Attendances_'.userdate(time(), '%Y%m%d-%H%M')); |
||||
|
|
||||
|
$group = $formdata->group ? $reportdata->groups[$formdata->group] : 0; |
||||
|
$data->tabhead = array(); |
||||
|
$data->course = $att->course->fullname; |
||||
|
$data->group = $group ? $group->name : get_string('allparticipants'); |
||||
|
|
||||
|
if (isset($formdata->ident['id'])) { |
||||
|
$data->tabhead[] = get_string('studentid', 'attforblock'); |
||||
|
} |
||||
|
if (isset($formdata->ident['uname'])) { |
||||
|
$data->tabhead[] = get_string('username'); |
||||
|
} |
||||
|
$data->tabhead[] = get_string('lastname'); |
||||
|
$data->tabhead[] = get_string('firstname'); |
||||
|
|
||||
|
|
||||
|
if (count($reportdata->sessions) > 0) { |
||||
|
foreach($reportdata->sessions as $sess) { |
||||
|
$text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attforblock')); |
||||
|
$text .= ' '; |
||||
|
$text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attforblock'); |
||||
|
$data->tabhead[] = $text; |
||||
|
} |
||||
|
} else { |
||||
|
print_error('sessionsnotfound', 'attforblock', $att->url_manage()); |
||||
|
} |
||||
|
if ($reportdata->gradable) |
||||
|
$data->tabhead[] = get_string('grade'); |
||||
|
|
||||
|
$i = 0; |
||||
|
$data->table = array(); |
||||
|
foreach($reportdata->users as $user) { |
||||
|
if (isset($formdata->ident['id'])) { |
||||
|
$data->table[$i][] = $user->id; |
||||
|
} |
||||
|
if (isset($formdata->ident['uname'])) { |
||||
|
$data->table[$i][] = $user->username; |
||||
|
} |
||||
|
$data->table[$i][] = $user->lastname; |
||||
|
$data->table[$i][] = $user->firstname; |
||||
|
$cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user); |
||||
|
$data->table[$i] = array_merge($data->table[$i], $cellsgenerator->get_cells()); |
||||
|
if ($reportdata->gradable) |
||||
|
$data->table[$i][] = $reportdata->grades[$user->id].' / '.$reportdata->maxgrades[$user->id]; |
||||
|
$i++; |
||||
|
} |
||||
|
|
||||
|
if ($formdata->format === 'text') { |
||||
|
ExportToCSV($data, $filename); |
||||
|
} else { |
||||
|
ExportToTableEd($data, $filename, $formdata->format); |
||||
|
} |
||||
|
exit; |
||||
|
} else { |
||||
|
print_error('studentsnotfound', 'attendance', $att->url_manage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$output = $PAGE->get_renderer('mod_attforblock'); |
||||
|
$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_EXPORT); |
||||
|
echo $output->header(); |
||||
|
echo $output->heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname); |
||||
|
echo $output->render($tabs); |
||||
|
|
||||
|
$mform->display(); |
||||
|
|
||||
|
echo $OUTPUT->footer(); |
||||
|
|
||||
|
|
||||
|
function ExportToTableEd($data, $filename, $format) { |
||||
|
global $CFG; |
||||
|
|
||||
|
if ($format === 'excel') { |
||||
|
require_once("$CFG->libdir/excellib.class.php"); |
||||
|
$filename .= ".xls"; |
||||
|
$workbook = new MoodleExcelWorkbook("-"); |
||||
|
} else { |
||||
|
require_once("$CFG->libdir/odslib.class.php"); |
||||
|
$filename .= ".ods"; |
||||
|
$workbook = new MoodleODSWorkbook("-"); |
||||
|
} |
||||
|
/// Sending HTTP headers |
||||
|
$workbook->send($filename); |
||||
|
/// Creating the first worksheet |
||||
|
$myxls =& $workbook->add_worksheet('Attendances'); |
||||
|
/// format types |
||||
|
$formatbc =& $workbook->add_format(); |
||||
|
$formatbc->set_bold(1); |
||||
|
|
||||
|
$myxls->write(0, 0, get_string('course'), $formatbc); |
||||
|
$myxls->write(0, 1, $data->course); |
||||
|
$myxls->write(1, 0, get_string('group'), $formatbc); |
||||
|
$myxls->write(1, 1, $data->group); |
||||
|
|
||||
|
$i = 3; |
||||
|
$j = 0; |
||||
|
foreach ($data->tabhead as $cell) { |
||||
|
$myxls->write($i, $j++, $cell, $formatbc); |
||||
|
} |
||||
|
$i++; |
||||
|
$j = 0; |
||||
|
foreach ($data->table as $row) { |
||||
|
foreach ($row as $cell) { |
||||
|
$myxls->write($i, $j++, $cell); |
||||
|
} |
||||
|
$i++; |
||||
|
$j = 0; |
||||
|
} |
||||
|
$workbook->close(); |
||||
|
} |
||||
|
|
||||
|
function ExportToCSV($data, $filename) { |
||||
|
$filename .= ".txt"; |
||||
|
|
||||
|
header("Content-Type: application/download\n"); |
||||
|
header("Content-Disposition: attachment; filename=\"$filename\""); |
||||
|
header("Expires: 0"); |
||||
|
header("Cache-Control: must-revalidate,post-check=0,pre-check=0"); |
||||
|
header("Pragma: public"); |
||||
|
|
||||
|
echo get_string('course')."\t".$data->course."\n"; |
||||
|
echo get_string('group')."\t".$data->group."\n\n"; |
||||
|
|
||||
|
echo implode("\t", $data->tabhead)."\n"; |
||||
|
foreach ($data->table as $row) { |
||||
|
echo implode("\t", $row)."\n"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
?> |
@ -0,0 +1,70 @@ |
|||||
|
<?php // $Id: export_form.php,v 1.2.2.3 2009/03/11 18:17:38 dlnsk Exp $
|
||||
|
|
||||
|
require_once($CFG->libdir.'/formslib.php'); |
||||
|
|
||||
|
class mod_attforblock_export_form extends moodleform { |
||||
|
|
||||
|
function definition() { |
||||
|
|
||||
|
global $CFG, $USER; |
||||
|
$mform =& $this->_form; |
||||
|
|
||||
|
$course = $this->_customdata['course']; |
||||
|
$cm = $this->_customdata['cm']; |
||||
|
$modcontext = $this->_customdata['modcontext']; |
||||
|
|
||||
|
|
||||
|
$mform->addElement('header', 'general', get_string('export','quiz')); |
||||
|
|
||||
|
$groupmode=groups_get_activity_groupmode($cm); |
||||
|
$groups = groups_get_activity_allowed_groups($cm, $USER->id); |
||||
|
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) { |
||||
|
$grouplist[0] = get_string('allparticipants'); |
||||
|
} |
||||
|
if ($groups) { |
||||
|
foreach ($groups as $group) { |
||||
|
$grouplist[$group->id] = $group->name; |
||||
|
} |
||||
|
} |
||||
|
$mform->addElement('select', 'group', get_string('group'), $grouplist); |
||||
|
|
||||
|
$ident = array(); |
||||
|
$ident[] =& MoodleQuickForm::createElement('checkbox', 'id', '', get_string('studentid', 'attforblock')); |
||||
|
$ident[] =& MoodleQuickForm::createElement('checkbox', 'uname', '', get_string('username')); |
||||
|
$mform->addGroup($ident, 'ident', get_string('identifyby','attforblock'), array('<br />'), true); |
||||
|
$mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); |
||||
|
|
||||
|
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall','attforblock'), get_string('yes')); |
||||
|
$mform->setDefault('includeallsessions', true); |
||||
|
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken','attforblock'), get_string('yes')); |
||||
|
$mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod','attforblock')); |
||||
|
$mform->setDefault('sessionstartdate', $course->startdate); |
||||
|
$mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked'); |
||||
|
$mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod','attforblock')); |
||||
|
$mform->disabledIf('sessionenddate', 'includeallsessions', 'checked'); |
||||
|
|
||||
|
$mform->addElement('select', 'format', get_string('format'), |
||||
|
array('excel' => get_string('downloadexcel','attforblock'), |
||||
|
'ooo' => get_string('downloadooo','attforblock'), |
||||
|
'text' => get_string('downloadtext','attforblock') |
||||
|
)); |
||||
|
|
||||
|
// buttons |
||||
|
$submit_string = get_string('ok'); |
||||
|
$this->add_action_buttons(false, $submit_string); |
||||
|
|
||||
|
$mform->addElement('hidden', 'id', $cm->id); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// function validation($data, $files) { |
||||
|
// $errors = parent::validation($data, $files); |
||||
|
// if (($data['timeend']!=0) && ($data['timestart']!=0) |
||||
|
// && $data['timeend'] <= $data['timestart']) { |
||||
|
// $errors['timeend'] = get_string('timestartenderror', 'forum'); |
||||
|
// } |
||||
|
// return $errors; |
||||
|
// } |
||||
|
|
||||
|
} |
||||
|
?> |
@ -0,0 +1,157 @@ |
|||||
|
<?php |
||||
|
/** |
||||
|
* Attendance module renderering helpers |
||||
|
* |
||||
|
* @package mod |
||||
|
* @subpackage attforblock |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
defined('MOODLE_INTERNAL') || die(); |
||||
|
|
||||
|
require_once(dirname(__FILE__).'/renderables.php'); |
||||
|
|
||||
|
/** |
||||
|
* Template method for generating user's session's cells |
||||
|
*/ |
||||
|
class user_sessions_cells_generator { |
||||
|
protected $cells = array(); |
||||
|
|
||||
|
protected $reportdata; |
||||
|
protected $user; |
||||
|
|
||||
|
public function __construct(attforblock_report_data $reportdata, $user) { |
||||
|
$this->reportdata = $reportdata; |
||||
|
$this->user = $user; |
||||
|
} |
||||
|
|
||||
|
public function get_cells() { |
||||
|
$this->init_cells(); |
||||
|
foreach ($this->reportdata->sessions as $sess) { |
||||
|
if (array_key_exists($sess->id, $this->reportdata->sessionslog[$this->user->id])) { |
||||
|
$statusid = $this->reportdata->sessionslog[$this->user->id][$sess->id]->statusid; |
||||
|
if (array_key_exists($statusid, $this->reportdata->statuses)) { |
||||
|
$this->construct_existing_status_cell($this->reportdata->statuses[$statusid]->acronym); |
||||
|
} else { |
||||
|
$this->construct_hidden_status_cell($this->reportdata->allstatuses[$statusid]->acronym); |
||||
|
} |
||||
|
} else { |
||||
|
if ($this->user->enrolmentstart > $sess->sessdate) { |
||||
|
$starttext = get_string('enrolmentstart', 'attforblock', userdate($this->user->enrolmentstart, '%d.%m.%Y')); |
||||
|
$this->construct_enrolments_info_cell($starttext); |
||||
|
} |
||||
|
elseif ($this->user->enrolmentend and $this->user->enrolmentend < $sess->sessdate) { |
||||
|
$endtext = get_string('enrolmentend', 'attforblock', userdate($this->user->enrolmentend, '%d.%m.%Y')); |
||||
|
$this->construct_enrolments_info_cell($endtext); |
||||
|
} |
||||
|
// no enrolmentend and ENROL_USER_SUSPENDED |
||||
|
elseif (!$this->user->enrolmentend and $this->user->enrolmentstatus == ENROL_USER_SUSPENDED) { |
||||
|
$suspendext = get_string('enrolmentsuspended', 'attforblock', userdate($this->user->enrolmentend, '%d.%m.%Y')); |
||||
|
$this->construct_enrolments_info_cell($suspendext); |
||||
|
} |
||||
|
else { |
||||
|
if ($sess->groupid == 0 or array_key_exists($sess->groupid, $this->reportdata->usersgroups[$this->user->id])) |
||||
|
$this->construct_not_taken_cell('?'); |
||||
|
else |
||||
|
$this->construct_not_existing_for_user_session_cell(''); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
$this->finalize_cells(); |
||||
|
|
||||
|
return $this->cells; |
||||
|
} |
||||
|
|
||||
|
protected function init_cells() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected function construct_existing_status_cell($text) { |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
|
||||
|
protected function construct_hidden_status_cell($text) { |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
|
||||
|
protected function construct_enrolments_info_cell($text) { |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
|
||||
|
protected function construct_not_taken_cell($text) { |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
|
||||
|
protected function construct_not_existing_for_user_session_cell($text) { |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
|
||||
|
protected function finalize_cells() { |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class user_sessions_cells_html_generator extends user_sessions_cells_generator { |
||||
|
private $cell; |
||||
|
|
||||
|
protected function construct_hidden_status_cell($text) { |
||||
|
$this->cells[] = html_writer::tag('s', $text); |
||||
|
} |
||||
|
|
||||
|
protected function construct_enrolments_info_cell($text) { |
||||
|
if (is_null($this->cell)) { |
||||
|
$this->cell = new html_table_cell($text); |
||||
|
$this->cell->colspan = 1; |
||||
|
} |
||||
|
else { |
||||
|
if ($this->cell->text != $text) { |
||||
|
$this->cells[] = $this->cell; |
||||
|
$this->cell = new html_table_cell($text); |
||||
|
$this->cell->colspan = 1; |
||||
|
} |
||||
|
else |
||||
|
$this->cell->colspan++; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private function close_open_cell_if_needed(){ |
||||
|
if ($this->cell) { |
||||
|
$this->cells[] = $this->cell; |
||||
|
$this->cell = null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected function construct_not_taken_cell($text) { |
||||
|
$this->close_open_cell_if_needed(); |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
|
||||
|
protected function construct_not_existing_for_user_session_cell($text) { |
||||
|
$this->close_open_cell_if_needed(); |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
|
||||
|
protected function finalize_cells() { |
||||
|
if ($this->cell) |
||||
|
$this->cells[] = $this->cell; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class user_sessions_cells_text_generator extends user_sessions_cells_generator { |
||||
|
private $enrolments_info_cell_text; |
||||
|
|
||||
|
protected function construct_hidden_status_cell($text) { |
||||
|
$this->cells[] = '-'.$text; |
||||
|
} |
||||
|
|
||||
|
protected function construct_enrolments_info_cell($text) { |
||||
|
if ($this->enrolments_info_cell_text != $text) { |
||||
|
$this->enrolments_info_cell_text = $text; |
||||
|
$this->cells[] = $text; |
||||
|
} |
||||
|
else |
||||
|
$this->cells[] = '←'; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
?> |
Loading…
Reference in new issue