Skip to content
Snippets Groups Projects
Commit c26d04f9 authored by Thomas Dondorf's avatar Thomas Dondorf
Browse files

Merge branch 'event_firering_tests' into 'master'

Event firering tests

See merge request !8
parents 9d0abea9 f9c6f21b
Branches
Tags
1 merge request!8Event firering tests
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The report_viewed event.
*
* @package learning_analytics
* @copyright 2014 YOUR NAME
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace local_learning_analytics\event;
defined('MOODLE_INTERNAL') || die();
class report_viewed extends \core\event\base {
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'local_learning_analytics_rep';
}
protected function validate_data() {
if (!isset($this->data['objecttable'])) {
throw new \coding_exception('The objecttable must be set in $data.');
}
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ namespace local_learning_analytics;
use moodle_url;
use core_component;
use html_writer;
use local_learning_analytics\event\report_viewed;
defined('MOODLE_INTERNAL') || die;
......@@ -40,6 +41,7 @@ class router {
string $pagename = null
) : string {
global $PAGE;
global $DB;
$outputs = $instance->run($params);
......@@ -61,6 +63,15 @@ class router {
$renderer = $PAGE->get_renderer('local_learning_analytics');
$ret .= $renderer->render_output_list($outputs);
$ret .= "</div>";
$objectid = $DB->get_record_select('local_learning_analytics_rep', "reportname='{$reportname}'")->id;
$event = report_viewed::create(array(
'contextid' => $PAGE->context->id,
'objectid' => $objectid
));
$event->add_record_snapshot('course', $PAGE->course);
$event->trigger();
return $ret;
}
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Main entry point for Learning Analytics UI
*
* @package local_learning_analytics
* @copyright Lehr- und Forschungsgebiet Ingenieurhydrologie - RWTH Aachen University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
//define('CLI_SCRIPT', true);
global $DB;
$datas = $DB->get_records('local_learning_analytics_rep');
$dataarray = array();
foreach($datas as $data){
array_push($dataarray, $data->reportname);
}
$insertarray = array();
$reports = array('coursedashboard', 'activities', 'learners', 'browser_os');
foreach($reports as $report) {
if(!in_array($report, $dataarray)) {
array_push($insertarray, set_entry($report));
}
}
$DB->insert_records('local_learning_analytics_rep', $insertarray);
function set_entry($report) {
$entr = new \stdClass();
$entr->reportname = $report;
return $entr;
}
\ No newline at end of file
......@@ -17,5 +17,15 @@
<INDEX NAME="courseid_prevcourseid_idx" UNIQUE="true" FIELDS="courseid, prevcourseid"/>
</INDEXES>
</TABLE>
<TABLE NAME="local_learning_analytics_rep" COMMENT="Previous course">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="reportname" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
......@@ -61,7 +61,6 @@ $PAGE->requires->css('/local/learning_analytics/static/styles.css');
$mainoutput = $output->render_from_template('local_learning_analytics/course', [
'content' => $resultinghtml
]);
echo $output->header();
echo $mainoutput;
echo $output->footer();
......@@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die;
$plugin->component = 'local_learning_analytics';
$plugin->version = 2020030601;
$plugin->version = 2020032000;
$plugin->release = 'v0.1.0-dev';
$plugin->maturity = MATURITY_ALPHA;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment