Merge branch 'MDL-59030_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Andrew Nicols 2017-08-29 14:34:59 +08:00
commit 3bb2900cf7
49 changed files with 794 additions and 545 deletions

View File

@ -60,12 +60,22 @@ abstract class community_of_inquiry_activity extends linear {
*/
const INDICATOR_SOCIAL = "social";
/**
* Max cognitive depth level accepted.
*/
const MAX_COGNITIVE_LEVEL = 5;
/**
* Max social breadth level accepted.
*/
const MAX_SOCIAL_LEVEL = 5;
/**
* Returns the activity type. No point in changing this class in children classes.
*
* @var string The activity name (e.g. assign or quiz)
*/
protected final function get_activity_type() {
public final function get_activity_type() {
$class = get_class($this);
$package = stristr($class, "\\", true);
$type = str_replace("mod_", "", $package);
@ -81,7 +91,7 @@ abstract class community_of_inquiry_activity extends linear {
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
throw new \coding_exception('Overwrite get_cognitive_depth_level method to set your activity potential cognitive ' .
'depth level');
}
@ -92,7 +102,7 @@ abstract class community_of_inquiry_activity extends linear {
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
throw new \coding_exception('Overwrite get_social_breadth_level method to set your activity potential social ' .
'breadth level');
}
@ -506,7 +516,7 @@ abstract class community_of_inquiry_activity extends linear {
foreach ($useractivities as $contextid => $cm) {
$potentiallevel = $this->get_cognitive_depth_level($cm);
if (!is_int($potentiallevel) || $potentiallevel > 5 || $potentiallevel < 1) {
if (!is_int($potentiallevel) || $potentiallevel > self::MAX_COGNITIVE_LEVEL || $potentiallevel < 1) {
throw new \coding_exception('Activities\' potential cognitive depth go from 1 to 5.');
}
$scoreperlevel = $scoreperactivity / $potentiallevel;
@ -593,12 +603,19 @@ abstract class community_of_inquiry_activity extends linear {
foreach ($useractivities as $contextid => $cm) {
$potentiallevel = $this->get_social_breadth_level($cm);
if (!is_int($potentiallevel) || $potentiallevel > 2 || $potentiallevel < 1) {
throw new \coding_exception('Activities\' potential social breadth go from 1 to 2.');
if (!is_int($potentiallevel) || $potentiallevel > self::MAX_SOCIAL_LEVEL || $potentiallevel < 1) {
throw new \coding_exception('Activities\' potential social breadth go from 1 to ' .
community_of_inquiry_activity::MAX_SOCIAL_LEVEL . '.');
}
$scoreperlevel = $scoreperactivity / $potentiallevel;
switch ($potentiallevel) {
case 2:
case 3:
case 4:
case 5:
// Core activities social breadth only reaches level 2, until core activities social
// breadth do not reach level 5 we limit it to what we currently support, which is level 2.
// Social breadth level 2 is to view feedback. (Same as cognitive level 3).
if ($this->any_feedback('viewed', $cm, $contextid, $user)) {
@ -650,5 +667,5 @@ abstract class community_of_inquiry_activity extends linear {
*
* @return string
*/
abstract protected function get_indicator_type();
abstract public function get_indicator_type();
}

View File

@ -0,0 +1,89 @@
<?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/>.
/**
* Completion enabled set indicator.
*
* @package core_course
* @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_course\analytics\indicator;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/completionlib.php');
/**
* Completion enabled set indicator.
*
* @package core_course
* @copyright 2016 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class completion_enabled extends \core_analytics\local\indicator\binary {
/**
* get_name
*
* @return new \lang_string
*/
public static function get_name() : \lang_string {
return new \lang_string('indicator:completionenabled', 'moodle');
}
/**
* required_sample_data
*
* @return string[]
*/
public static function required_sample_data() {
// Minimum course although it also accepts course_modules.
return array('course');
}
/**
* Is completion enabled? Work both with courses and activities.
*
* @param int $sampleid
* @param string $sampleorigin
* @param int|false $notusedstarttime
* @param int|false $notusedendtime
* @return float
*/
public function calculate_sample($sampleid, $sampleorigin, $notusedstarttime = false, $notusedendtime = false) {
$course = $this->retrieve('course', $sampleid);
$cm = false;
if ($sampleorigin === 'course_modules') {
$cm = $this->retrieve('course_modules', $sampleid);
}
$completion = new \completion_info($course);
if (!$completion->is_enabled($cm)) {
$value = self::get_min_value();
} else if (!$cm && !$completion->has_criteria()) {
// Course completion enabled with no criteria counts as nothing.
$value = self::get_min_value();
} else {
$value = self::get_max_value();
}
return $value;
}
}

View File

@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die();
/**
* No teacher indicator.
*
* @package core_analytics
* @package core_course
* @copyright 2016 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -0,0 +1,136 @@
<?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/>.
/**
* Potential cognitive depth indicator.
*
* @package core_course
* @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_course\analytics\indicator;
defined('MOODLE_INTERNAL') || die();
use \core_analytics\local\indicator\community_of_inquiry_activity;
/**
* Potential cognitive depth indicator.
*
* It extends linear instead of discrete as there is a linear relation between
* the different cognitive levels activities can reach.
*
* @package core_course
* @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class potential_cognitive_depth extends \core_analytics\local\indicator\linear {
/**
* get_name
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
return new \lang_string('indicator:potentialcognitive', 'moodle');
}
/**
* Specify the required data to process this indicator.
*
* @return string[]
*/
public static function required_sample_data() {
// We require course because, although this indicator can also work with course_modules we can't
// calculate anything without the course.
return array('course');
}
/**
* calculate_sample
*
* @throws \coding_exception
* @param int $sampleid
* @param string $sampleorigin
* @param int|false $notusedstarttime
* @param int|false $notusedendtime
* @return float
*/
public function calculate_sample($sampleid, $sampleorigin, $notusedstarttime = false, $notusedendtime = false) {
if ($sampleorigin === 'course_modules') {
$cm = $this->retrieve('course_modules', $sampleid);
$cminfo = \cm_info::create($cm);
$cognitivedepthindicator = $this->get_cognitive_indicator($cminfo->modname);
$potentiallevel = $cognitivedepthindicator->get_cognitive_depth_level($cminfo);
if ($potentiallevel > community_of_inquiry_activity::MAX_COGNITIVE_LEVEL) {
throw new \coding_exception('Maximum cognitive depth level is ' .
community_of_inquiry_activity::MAX_COGNITIVE_LEVEL . ', ' . $potentiallevel . ' provided by ' .
get_class($this));
}
} else {
$course = $this->retrieve('course', $sampleid);
$modinfo = get_fast_modinfo($course);
$cms = $modinfo->get_cms();
if (!$cms) {
return self::get_min_value();
}
$potentiallevel = 0;
foreach ($cms as $cm) {
if (!$cognitivedepthindicator = $this->get_cognitive_indicator($cm->modname)) {
continue;
}
$level = $cognitivedepthindicator->get_cognitive_depth_level($cm);
if ($level > community_of_inquiry_activity::MAX_COGNITIVE_LEVEL) {
throw new \coding_exception('Maximum cognitive depth level is ' .
community_of_inquiry_activity::MAX_COGNITIVE_LEVEL . ', ' . $level . ' provided by ' . get_class($this));
}
if ($level > $potentiallevel) {
$potentiallevel = $level;
}
}
}
// Values from -1 to 1 range split in 5 parts (the max cognitive depth level).
// Note that we divide by 4 because we start from -1.
$levelscore = round((self::get_max_value() - self::get_min_value()) / 4, 2);
// We substract $levelscore because we want to start from the lower score and there is no cognitive depth level 0.
return self::get_min_value() + ($levelscore * $potentiallevel) - $levelscore;
}
/**
* Returns the cognitive depth class of this indicator.
*
* @param string $modname
* @return \core_analytics\local\indicator\base|false
*/
protected function get_cognitive_indicator($modname) {
$indicators = \core_analytics\manager::get_all_indicators();
foreach ($indicators as $indicator) {
if ($indicator instanceof community_of_inquiry_activity &&
$indicator->get_indicator_type() === community_of_inquiry_activity::INDICATOR_COGNITIVE &&
$indicator->get_activity_type() === $modname) {
return $indicator;
}
}
return false;
}
}

View File

@ -0,0 +1,148 @@
<?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/>.
/**
* Potential social breadth indicator.
*
* @package core_course
* @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_course\analytics\indicator;
defined('MOODLE_INTERNAL') || die();
use \core_analytics\local\indicator\community_of_inquiry_activity;
/**
* Potential social breadth indicator.
*
* It extends linear instead of discrete as there is a linear relation between
* the different social levels activities can reach.
*
* @package core_course
* @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class potential_social_breadth extends \core_analytics\local\indicator\linear {
/**
* get_name
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
return new \lang_string('indicator:potentialsocial', 'moodle');
}
/**
* Specify the required data to process this indicator.
*
* @return string[]
*/
public static function required_sample_data() {
// We require course because, although this indicator can also work with course_modules we can't
// calculate anything without the course.
return array('course');
}
/**
* calculate_sample
*
* @param int $sampleid
* @param string $sampleorigin
* @param int|false $notusedstarttime
* @param int|false $notusedendtime
* @return float
*/
public function calculate_sample($sampleid, $sampleorigin, $notusedstarttime = false, $notusedendtime = false) {
if ($sampleorigin === 'course_modules') {
$cm = $this->retrieve('course_modules', $sampleid);
$cminfo = \cm_info::create($cm);
$socialbreadthindicator = $this->get_social_indicator($cminfo->modname);
$potentiallevel = $socialbreadthindicator->get_social_breadth_level($cminfo);
if ($potentiallevel > community_of_inquiry_activity::MAX_SOCIAL_LEVEL) {
$this->level_not_accepted($potentiallevel);
}
} else {
$course = $this->retrieve('course', $sampleid);
$modinfo = get_fast_modinfo($course);
$cms = $modinfo->get_cms();
if (!$cms) {
return self::get_min_value();
}
$potentiallevel = 0;
foreach ($cms as $cm) {
if (!$socialbreadthindicator = $this->get_social_indicator($cm->modname)) {
continue;
}
$level = $socialbreadthindicator->get_social_breadth_level($cm);
if ($level > community_of_inquiry_activity::MAX_SOCIAL_LEVEL) {
$this->level_not_accepted($level);
}
if ($level > $potentiallevel) {
$potentiallevel = $level;
}
}
}
// Core activities social breadth only reaches level 2, until core activities social
// breadth do not reach level 5 we limit it to what we currently support, which is level 2.
if ($potentiallevel > 2) {
$potentiallevel = 2;
}
// Supporting only social breadth level 1 and 2 the possible values are -1 or 1.
$levelscore = round(self::get_max_value() - self::get_min_value(), 2);
// We substract $levelscore because we want to start from the lower socre and there is no cognitive depth level 0.
return self::get_min_value() + ($levelscore * $potentiallevel) - $levelscore;
}
/**
* Returns the social breadth class of this indicator.
*
* @param string $modname
* @return \core_analytics\local\indicator\base|false
*/
protected function get_social_indicator($modname) {
$indicators = \core_analytics\manager::get_all_indicators();
foreach ($indicators as $indicator) {
if ($indicator instanceof community_of_inquiry_activity &&
$indicator->get_indicator_type() === community_of_inquiry_activity::INDICATOR_SOCIAL &&
$indicator->get_activity_type() === $modname) {
return $indicator;
}
}
return false;
}
/**
* Throw a \coding_exception.
*
* @param int $level
*/
protected function level_not_accepted($level) {
throw new \coding_exception('Activities\' potential social breadth go from 1 to ' .
community_of_inquiry_activity::MAX_SOCIAL_LEVEL . '.');
}
}

View File

@ -0,0 +1,315 @@
<?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/>.
/**
* Unit tests for core_course indicators.
*
* @package core_course
* @category analytics
* @copyright 2017 David Monllaó {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../../completion/criteria/completion_criteria_self.php');
/**
* Unit tests for core_course indicators.
*
* @package core_course
* @category analytics
* @copyright 2017 David Monllaó {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_course_indicators_testcase extends advanced_testcase {
/**
* test_no_teacher
*
* @return void
*/
public function test_no_teacher() {
global $DB;
$this->resetAfterTest(true);
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$coursecontext1 = \context_course::instance($course1->id);
$coursecontext2 = \context_course::instance($course2->id);
$user = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($user->id, $course1->id, 'student');
$this->getDataGenerator()->enrol_user($user->id, $course2->id, 'teacher');
$indicator = new \core_course\analytics\indicator\no_teacher();
$sampleids = array($course1->id => $course1->id, $course2->id => $course2->id);
$data = array(
$course1->id => array(
'context' => $coursecontext1,
'course' => $course1,
),
$course2->id => array(
'context' => $coursecontext2,
'course' => $course2,
));
$indicator->add_sample_data($data);
list($values, $ignored) = $indicator->calculate($sampleids, 'course');
$this->assertEquals($indicator::get_min_value(), $values[$course1->id][0]);
$this->assertEquals($indicator::get_max_value(), $values[$course2->id][0]);
}
/**
* test_completion_enabled
*
* @return void
*/
public function test_completion_enabled() {
global $DB;
$this->resetAfterTest(true);
$course1 = $this->getDataGenerator()->create_course(array('enablecompletion' => 0));
$course2 = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
$course3 = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
// Criteria only for the last one.
$criteriadata = new stdClass();
$criteriadata->id = $course3->id;
$criteriadata->criteria_self = 1;
$criterion = new completion_criteria_self();
$criterion->update_config($criteriadata);
$indicator = new \core_course\analytics\indicator\completion_enabled();
$sampleids = array($course1->id => $course1->id, $course2->id => $course2->id, $course3->id => $course3->id);
$data = array(
$course1->id => array(
'course' => $course1,
),
$course2->id => array(
'course' => $course2,
),
$course3->id => array(
'course' => $course3,
));
$indicator->add_sample_data($data);
// Calculate using course samples.
list($values, $ignored) = $indicator->calculate($sampleids, 'course');
$this->assertEquals($indicator::get_min_value(), $values[$course1->id][0]);
$this->assertEquals($indicator::get_min_value(), $values[$course2->id][0]);
$this->assertEquals($indicator::get_max_value(), $values[$course3->id][0]);
// Calculate using course_modules samples.
$indicator->clear_sample_data();
$data1 = $this->getDataGenerator()->create_module('data', array('course' => $course3->id),
array('completion' => 0));
$data2 = $this->getDataGenerator()->create_module('data', array('course' => $course3->id),
array('completion' => 1));
$sampleids = array($data1->cmid => $data1->cmid, $data2->cmid => $data2->cmid);
$cm1 = $DB->get_record('course_modules', array('id' => $data1->cmid));
$cm2 = $DB->get_record('course_modules', array('id' => $data2->cmid));
$data = array(
$cm1->id => array(
'course' => $course3,
'course_modules' => $cm1,
),
$cm2->id => array(
'course' => $course3,
'course_modules' => $cm2,
));
$indicator->add_sample_data($data);
list($values, $ignored) = $indicator->calculate($sampleids, 'course_modules');
$this->assertEquals($indicator::get_min_value(), $values[$cm1->id][0]);
$this->assertEquals($indicator::get_max_value(), $values[$cm2->id][0]);
}
/**
* test_potential_cognitive
*
* @return void
*/
public function test_potential_cognitive() {
global $DB;
$this->resetAfterTest(true);
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$page = $this->getDataGenerator()->create_module('page', array('course' => $course2->id));
$course3 = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course3->id));
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course3->id));
$course4 = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course4->id));
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course4->id));
$indicator = new \core_course\analytics\indicator\potential_cognitive_depth();
$sampleids = array($course1->id => $course1->id, $course2->id => $course2->id, $course3->id => $course3->id,
$course4->id => $course4->id);
$data = array(
$course1->id => array(
'course' => $course1,
),
$course2->id => array(
'course' => $course2,
),
$course3->id => array(
'course' => $course3,
),
$course4->id => array(
'course' => $course4,
));
$indicator->add_sample_data($data);
list($values, $ignored) = $indicator->calculate($sampleids, 'course');
$this->assertEquals($indicator::get_min_value(), $values[$course1->id][0]);
// General explanation about the points, the max level is 5 so level 1 is -1, level 2 is -0.5, level 3 is 0,
// level 4 is 0.5 and level 5 is 1.
// Page cognitive is level 1 (the lower one).
$this->assertEquals($indicator::get_min_value(), $values[$course2->id][0]);
// The maximum cognitive depth level is 5, assign level is 5 therefore the potential cognitive depth is the max.
$this->assertEquals($indicator::get_max_value(), $values[$course3->id][0]);
// Forum level is 4.
$this->assertEquals(0.5, $values[$course4->id][0]);
// Calculate using course_modules samples.
$course5 = $this->getDataGenerator()->create_course();
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course5->id));
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course5->id));
$sampleids = array($assign->cmid => $assign->cmid, $forum->cmid => $forum->cmid);
$cm1 = $DB->get_record('course_modules', array('id' => $assign->cmid));
$cm2 = $DB->get_record('course_modules', array('id' => $forum->cmid));
$data = array(
$cm1->id => array(
'course' => $course5,
'course_modules' => $cm1,
),
$cm2->id => array(
'course' => $course5,
'course_modules' => $cm2,
));
$indicator->clear_sample_data();
$indicator->add_sample_data($data);
list($values, $ignored) = $indicator->calculate($sampleids, 'course_modules');
// Assign level is 5, the maximum level.
$this->assertEquals($indicator::get_max_value(), $values[$cm1->id][0]);
// Forum level is 4.
$this->assertEquals(0.5, $values[$cm2->id][0]);
}
/**
* test_potential_social
*
* @return void
*/
public function test_potential_social() {
global $DB;
$this->resetAfterTest(true);
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$page = $this->getDataGenerator()->create_module('page', array('course' => $course2->id));
$course3 = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course3->id));
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course3->id));
$course4 = $this->getDataGenerator()->create_course();
$page = $this->getDataGenerator()->create_module('page', array('course' => $course4->id));
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course4->id));
$indicator = new \core_course\analytics\indicator\potential_social_breadth();
$sampleids = array($course1->id => $course1->id, $course2->id => $course2->id, $course3->id => $course3->id,
$course4->id => $course4->id);
$data = array(
$course1->id => array(
'course' => $course1,
),
$course2->id => array(
'course' => $course2,
),
$course3->id => array(
'course' => $course3,
),
$course4->id => array(
'course' => $course4,
));
$indicator->add_sample_data($data);
list($values, $ignored) = $indicator->calculate($sampleids, 'course');
$this->assertEquals($indicator::get_min_value(), $values[$course1->id][0]);
// General explanation about the points, the max level is 2 so level 1 is -1, level 2 is 1.
// Page social is level 1 (the lower level).
$this->assertEquals($indicator::get_min_value(), $values[$course2->id][0]);
// Forum is level 2 and assign is level 2.
$this->assertEquals($indicator::get_max_value(), $values[$course3->id][0]);
// Page is level 1 and assign is level 2, so potential level is the max one.
$this->assertEquals($indicator::get_max_value(), $values[$course4->id][0]);
// Calculate using course_modules samples.
$course5 = $this->getDataGenerator()->create_course();
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course5->id));
$page = $this->getDataGenerator()->create_module('page', array('course' => $course5->id));
$sampleids = array($assign->cmid => $assign->cmid, $page->cmid => $page->cmid);
$cm1 = $DB->get_record('course_modules', array('id' => $assign->cmid));
$cm2 = $DB->get_record('course_modules', array('id' => $page->cmid));
$data = array(
$cm1->id => array(
'course' => $course5,
'course_modules' => $cm1,
),
$cm2->id => array(
'course' => $course5,
'course_modules' => $cm2,
));
$indicator->clear_sample_data();
$indicator->add_sample_data($data);
list($values, $ignored) = $indicator->calculate($sampleids, 'course_modules');
// Assign social is level 2 (the max level).
$this->assertEquals($indicator::get_max_value(), $values[$cm1->id][0]);
// Page social is level 1 (the lower level).
$this->assertEquals($indicator::get_min_value(), $values[$cm2->id][0]);
}
}

View File

@ -1031,8 +1031,14 @@ $string['indicator:anywrite'] = 'Any write action';
$string['indicator:anywrite_help'] = '';
$string['indicator:completeduserprofile'] = 'User profile is completed';
$string['indicator:completeduserprofile_help'] = '';
$string['indicator:completionenabled'] = 'Completion enabled';
$string['indicator:completionenabled_help'] = '';
$string['indicator:noteacher'] = 'There are no teachers';
$string['indicator:noteacher_help'] = '';
$string['indicator:potentialcognitive'] = 'Potential cognitive depth';
$string['indicator:potentialcognitive_help'] = '';
$string['indicator:potentialsocial'] = 'Potential social breadth';
$string['indicator:potentialsocial_help'] = '';
$string['indicator:readactions'] = 'Read actions amount';
$string['indicator:readactions_help'] = '';
$string['indicator:userforumstracking'] = 'User is tracking forums';

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_assign');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 5;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_assign');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_book');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_book');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_chat');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 4;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_chat');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_choice');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
$this->fill_choice_data($cm);
if ($this->choicedata[$cm->instance]->showresults == 0 || $this->choicedata[$cm->instance]->showresults == 4) {

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_choice');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
$this->fill_choice_data($cm);
return 2;
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_data');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 2;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_data');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_feedback');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
$this->fill_publishstats($cm);
if (!empty($this->publishstats[$cm->instance])) {

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_feedback');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
$this->fill_publishstats($cm);
return 2;

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_folder');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_folder');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_forum');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 4;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_forum');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_glossary');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 2;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_glossary');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_imscp');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_imscp');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_label');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_label');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_lesson');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 5;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_lesson');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_lti');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 3;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_lti');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_page');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_page');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_quiz');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 5;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_quiz');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_resource');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_resource');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_scorm');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 3;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_scorm');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_survey');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 2;
}
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_survey');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_url');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_url');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_wiki');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 2;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_wiki');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}

View File

@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_workshop');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 5;
}

View File

@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_workshop');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}