. /** * Model logs table class. * * @package tool_analytics * @copyright 2017 David Monllao {@link http://www.davidmonllao.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace tool_analytics\output; defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); /** * Model logs table class. * * @package tool_analytics * @copyright 2017 David Monllao {@link http://www.davidmonllao.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class model_logs extends \table_sql { /** * @var \core_analytics\model */ protected $model = null; /** * @var string|false */ protected $evaluationmode = false; /** * Sets up the table_log parameters. * * @param string $uniqueid unique id of form. * @param \core_analytics\model $model */ public function __construct($uniqueid, $model) { global $PAGE; parent::__construct($uniqueid); $this->model = $model; $this->set_attribute('class', 'modellog generaltable generalbox'); $this->set_attribute('aria-live', 'polite'); $this->define_columns(array('time', 'version', 'evaluationmode', 'indicators', 'timesplitting', 'accuracy', 'info', 'usermodified')); $this->define_headers(array( get_string('time'), get_string('version'), get_string('evaluationmode', 'tool_analytics'), get_string('indicators', 'tool_analytics'), get_string('timesplittingmethod', 'analytics'), get_string('accuracy', 'tool_analytics'), get_string('info', 'tool_analytics'), get_string('fullnameuser'), )); $evaluationmodehelp = new \help_icon('evaluationmode', 'tool_analytics'); $this->define_help_for_headers([null, null, $evaluationmodehelp, null, null, null, null, null]); $this->pageable(true); $this->collapsible(false); $this->sortable(false); $this->is_downloadable(false); $this->evaluationmode = optional_param('evaluationmode', false, PARAM_ALPHANUM); if ($this->evaluationmode && $this->evaluationmode != 'configuration' && $this->evaluationmode != 'trainedmodel') { $this->evaluationmode = ''; } $this->define_baseurl($PAGE->url); } /** * Generate the version column. * * @param \stdClass $log log data. * @return string HTML for the version column */ public function col_version($log) { $recenttimestr = get_string('strftimerecent', 'core_langconfig'); return userdate($log->version, $recenttimestr); } /** * Generate the evaluation mode column. * * @param \stdClass $log log data. * @return string HTML for the evaluationmode column */ public function col_evaluationmode($log) { return get_string('evaluationmodecol' . $log->evaluationmode, 'tool_analytics'); } /** * Generate the time column. * * @param \stdClass $log log data. * @return string HTML for the time column */ public function col_time($log) { $recenttimestr = get_string('strftimerecent', 'core_langconfig'); return userdate($log->timecreated, $recenttimestr); } /** * Generate the indicators column. * * @param \stdClass $log log data. * @return string HTML for the indicators column */ public function col_indicators($log) { $indicatorclasses = json_decode($log->indicators); $indicators = array(); foreach ($indicatorclasses as $indicatorclass) { $indicator = \core_analytics\manager::get_indicator($indicatorclass); if ($indicator) { $indicators[] = $indicator->get_name(); } else { debugging('Can\'t load ' . $indicatorclass . ' indicator', DEBUG_DEVELOPER); } } return '