Skip to content

Commit

Permalink
MDL-59211 analytics: Make cibot happy
Browse files Browse the repository at this point in the history
Part of MDL-57791 epic.
  • Loading branch information
David Monllao committed Jul 24, 2017
1 parent 1611308 commit 413f19b
Show file tree
Hide file tree
Showing 138 changed files with 2,999 additions and 391 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ theme/boost/scss/fontawesome/
theme/bootstrapbase/less/bootstrap/
theme/bootstrapbase/javascript/html5shiv.js
theme/bootstrapbase/amd/src/bootstrap.js
theme/bootstrapbase/less/fontawesome/
theme/bootstrapbase/less/fontawesome/
2 changes: 1 addition & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ theme/boost/scss/fontawesome/
theme/bootstrapbase/less/bootstrap/
theme/bootstrapbase/javascript/html5shiv.js
theme/bootstrapbase/amd/src/bootstrap.js
theme/bootstrapbase/less/fontawesome/
theme/bootstrapbase/less/fontawesome/
5 changes: 3 additions & 2 deletions admin/tool/models/amd/src/log_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], functi

/**
* Prepares a modal info for a log's results.
*
* @access public
* @param {int} id
* @return {String} HTML info
* @param {string[]} info
*/
loadInfo : function(id, info) {
loadInfo: function(id, info) {

var link = $('[data-model-log-id="' + id + '"]');
str.get_string('loginfo', 'tool_models').then(function(langString) {
Expand Down
43 changes: 37 additions & 6 deletions admin/tool/models/classes/analytics/target/course_dropout.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@
*/
class course_dropout extends \core_analytics\local\target\binary {

protected $coursegradeitem = null;

/**
* get_name
*
* @return string
*/
public static function get_name() {
return get_string('target:coursedropout', 'tool_models');
}

/**
* prediction_actions
*
* @param \core_analytics\prediction $prediction
* @param bool $includedetailsaction
* @return \core_analytics\prediction_action[]
*/
public function prediction_actions(\core_analytics\prediction $prediction, $includedetailsaction = false) {
global $USER;

Expand All @@ -57,17 +67,24 @@ public function prediction_actions(\core_analytics\prediction $prediction, $incl
// Send a message.
$url = new \moodle_url('/message/index.php', array('user' => $USER->id, 'id' => $studentid));
$pix = new \pix_icon('t/message', get_string('sendmessage', 'message'));
$actions['studentmessage'] = new \core_analytics\prediction_action('studentmessage', $prediction, $url, $pix, get_string('sendmessage', 'message'));
$actions['studentmessage'] = new \core_analytics\prediction_action('studentmessage', $prediction, $url, $pix,
get_string('sendmessage', 'message'));

// View outline report.
$url = new \moodle_url('/report/outline/user.php', array('id' => $studentid, 'course' => $sampledata['course']->id,
'mode' => 'outline'));
$pix = new \pix_icon('i/report', get_string('outlinereport'));
$actions['viewoutlinereport'] = new \core_analytics\prediction_action('viewoutlinereport', $prediction, $url, $pix, get_string('outlinereport'));
$actions['viewoutlinereport'] = new \core_analytics\prediction_action('viewoutlinereport', $prediction, $url, $pix,
get_string('outlinereport'));

return $actions;
}

/**
* classes_description
*
* @return string[]
*/
protected static function classes_description() {
return array(
get_string('labelstudentdropoutno', 'tool_models'),
Expand All @@ -86,10 +103,22 @@ protected function ignored_predicted_classes() {
return array();
}

/**
* get_analyser_class
*
* @return string
*/
public function get_analyser_class() {
return '\\core_analytics\\local\\analyser\\student_enrolments';
}

/**
* is_valid_analysable
*
* @param \core_analytics\analysable $course
* @param bool $fortraining
* @return true|string
*/
public function is_valid_analysable(\core_analytics\analysable $course, $fortraining = true) {
global $DB;

Expand Down Expand Up @@ -145,7 +174,7 @@ public function is_valid_analysable(\core_analytics\analysable $course, $fortrai
* @param int $sampleid
* @param \core_analytics\analysable $course
* @param bool $fortraining
* @return bool
* @return true|string
*/
public function is_valid_sample($sampleid, \core_analytics\analysable $course, $fortraining = true) {
return true;
Expand All @@ -160,7 +189,9 @@ public function is_valid_sample($sampleid, \core_analytics\analysable $course, $
*
* @param int $sampleid
* @param \core_analytics\analysable $course
* @return void
* @param int $starttime
* @param int $endtime
* @return float
*/
protected function calculate_sample($sampleid, \core_analytics\analysable $course, $starttime = false, $endtime = false) {

Expand Down
37 changes: 34 additions & 3 deletions admin/tool/models/classes/analytics/target/no_teaching.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,22 @@ public static function based_on_assumptions() {
return true;
}

/**
* get_name
*
* @return string
*/
public static function get_name() {
return get_string('target:noteachingactivity', 'tool_models');
}

/**
* prediction_actions
*
* @param \core_analytics\prediction $prediction
* @param mixed $includedetailsaction
* @return \core_analytics\prediction_action[]
*/
public function prediction_actions(\core_analytics\prediction $prediction, $includedetailsaction = false) {
global $USER;

Expand Down Expand Up @@ -79,6 +91,11 @@ public function prediction_actions(\core_analytics\prediction $prediction, $incl
return $actions;
}

/**
* classes_description
*
* @return string[]
*/
protected static function classes_description() {
return array(
get_string('labelteachingyes', 'tool_models'),
Expand All @@ -96,10 +113,22 @@ protected function ignored_predicted_classes() {
return array(0);
}

/**
* get_analyser_class
*
* @return string
*/
public function get_analyser_class() {
return '\\core_analytics\\local\\analyser\\site_courses';
}

/**
* is_valid_analysable
*
* @param \core_analytics\analysable $analysable
* @param mixed $fortraining
* @return true|string
*/
public function is_valid_analysable(\core_analytics\analysable $analysable, $fortraining = true) {
// The analysable is the site, so yes, it is always valid.
return true;
Expand All @@ -108,10 +137,10 @@ public function is_valid_analysable(\core_analytics\analysable $analysable, $for
/**
* Only process samples which start date is getting close.
*
* @param mixed $sampleid
* @param int $sampleid
* @param \core_analytics\analysable $analysable
* @param bool $fortraining
* @return void
* @return true|string
*/
public function is_valid_sample($sampleid, \core_analytics\analysable $analysable, $fortraining = true) {

Expand All @@ -132,7 +161,9 @@ public function is_valid_sample($sampleid, \core_analytics\analysable $analysabl
*
* @param int $sampleid
* @param \core_analytics\analysable $analysable
* @return void
* @param int $starttime
* @param int $endtime
* @return float
*/
protected function calculate_sample($sampleid, \core_analytics\analysable $analysable, $starttime = false, $endtime = false) {

Expand Down
2 changes: 2 additions & 0 deletions admin/tool/models/classes/output/form/edit_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace tool_models\output\form;

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot.'/lib/formslib.php');

/**
Expand Down
16 changes: 15 additions & 1 deletion admin/tool/models/classes/output/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,36 @@

namespace tool_models\output;

defined('MOODLE_INTERNAL') || die();

/**
* Typical crappy helper class with tiny functions.
* Helper class with general purpose tiny functions.
*
* @package tool_models
* @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class helper {

/**
* Converts a class full name to a select option key
*
* @param string $class
* @return string
*/
public static function class_to_option($class) {
// Form field is PARAM_ALPHANUMEXT and we are sending fully qualified class names
// as option names, but replacing the backslash for a string that is really unlikely
// to ever be part of a class name.
return str_replace('\\', '2015102400ouuu', $class);
}

/**
* option_to_class
*
* @param string $option
* @return string
*/
public static function option_to_class($option) {
// Really unlikely but yeah, I'm a bad booyyy.
return str_replace('2015102400ouuu', '\\', $option);
Expand Down
11 changes: 11 additions & 0 deletions admin/tool/models/classes/output/models_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@
*/
class models_list implements \renderable, \templatable {

/**
* models
*
* @var \core_analytics\model[]
*/
protected $models = array();

/**
* __construct
*
* @param \core_analytics\model[] $models
* @return void
*/
public function __construct($models) {
$this->models = $models;
}
Expand Down
3 changes: 2 additions & 1 deletion admin/tool/models/classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public function render_evaluate_results($results, $logs = array()) {

if (isset($result->score)) {
// Score.
$output .= $OUTPUT->heading(get_string('accuracy', 'tool_models') . ': ' . round(floatval($result->score), 4) * 100 . '%', 4);
$output .= $OUTPUT->heading(get_string('accuracy', 'tool_models') . ': ' .
round(floatval($result->score), 4) * 100 . '%', 4);
}

if (!empty($result->info)) {
Expand Down
13 changes: 12 additions & 1 deletion admin/tool/models/classes/task/predict_models.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,6 +24,8 @@

namespace tool_models\task;

defined('MOODLE_INTERNAL') || die();

/**
* Predict system models with new data available.
*
Expand All @@ -34,10 +35,20 @@
*/
class predict_models extends \core\task\scheduled_task {

/**
* get_name
*
* @return string
*/
public function get_name() {
return get_string('predictmodels', 'tool_models');
}

/**
* Executes the prediction task.
*
* @return void
*/
public function execute() {
global $OUTPUT, $PAGE;

Expand Down
13 changes: 12 additions & 1 deletion admin/tool/models/classes/task/train_models.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,6 +24,8 @@

namespace tool_models\task;

defined('MOODLE_INTERNAL') || die();

/**
* Train system models with new data available.
*
Expand All @@ -34,10 +35,20 @@
*/
class train_models extends \core\task\scheduled_task {

/**
* get_name
*
* @return string
*/
public function get_name() {
return get_string('trainmodels', 'tool_models');
}

/**
* Executes the prediction task.
*
* @return void
*/
public function execute() {
global $OUTPUT, $PAGE;

Expand Down
12 changes: 11 additions & 1 deletion admin/tool/models/cli/guess_course_start_and_end.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@
$courses->close();


/**
* tool_models_calculate_course_dates
*
* @param stdClass $course
* @param array $options CLI options
* @return void
*/
function tool_models_calculate_course_dates($course, $options) {
global $DB, $OUTPUT;

Expand Down Expand Up @@ -153,7 +160,8 @@ function tool_models_calculate_course_dates($course, $options) {
if ($options['update']) {
format_weeks::update_end_date($course->id);
$course->enddate = $DB->get_field('course', 'enddate', array('id' => $course->id));
$notification .= PHP_EOL . ' ' . get_string('weeksenddateautomaticallyset', 'tool_models') . ': ' . userdate($course->enddate);
$notification .= PHP_EOL . ' ' . get_string('weeksenddateautomaticallyset', 'tool_models') . ': ' .
userdate($course->enddate);
} else {
// We can't provide more info without actually updating it in db.
$notification .= PHP_EOL . ' ' . get_string('weeksenddatedefault', 'tool_models');
Expand Down Expand Up @@ -194,4 +202,6 @@ function tool_models_calculate_course_dates($course, $options) {
echo mtrace($notification);
}

echo mtrace(get_string('success'));

exit(0);
Loading

0 comments on commit 413f19b

Please sign in to comment.