mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-52916 cbe: Refactor competency breakdown report
Redesign this to fit when there are unlimited competencies / users.
This commit is contained in:
parent
47cddb9c1f
commit
21e0dd61e5
@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/str","core/ajax","core/log","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f,g){var h=function(b,c){this._regionSelector=b,this._userCompetencySelector=c,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return h.prototype._handleClick=function(c){var f=a(c.target).closest(this._userCompetencySelector),g=a(f).data("competencyid"),h=a(f).data("courseid"),i=a(f).data("userid");e.debug("Clicked on cell: competencyId="+g+", courseId="+h+", userId="+i),d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_course",args:{userid:i,competencyid:g,courseid:h},done:this._contextLoaded.bind(this),fail:b.exception}])},h.prototype._contextLoaded=function(a){var d=this;f.render("tool_lp/user_competency_summary_in_course",a).done(function(a,e){c.get_string("usercompetencysummary","report_competency").done(function(b){new g(b,a,f.runTemplateJS.bind(f,e),d._refresh.bind(d),!0)}).fail(b.exception)}).fail(b.exception)},h.prototype._refresh=function(){var c=a(this._regionSelector),e=c.data("courseid"),f=c.data("groupid"),g=c.data("onlyactive");d.call([{methodname:"report_competency_data_for_report",args:{courseid:e,groupid:f,onlyactive:g},done:this._pageContextLoaded.bind(this),fail:b.exception}])},h.prototype._pageContextLoaded=function(a){var c=this;f.render("report_competency/report",a).done(function(a,b){f.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},h.prototype._regionSelector=null,h.prototype._userCompetencySelector=null,h});
|
||||
define(["jquery","core/notification","core/str","core/ajax","core/log","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f,g){var h=function(b,c){this._regionSelector=b,this._userCompetencySelector=c,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return h.prototype._handleClick=function(c){var f=a(c.target).closest(this._userCompetencySelector),g=a(f).data("competencyid"),h=a(f).data("courseid"),i=a(f).data("userid");e.debug("Clicked on cell: competencyId="+g+", courseId="+h+", userId="+i),d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_course",args:{userid:i,competencyid:g,courseid:h},done:this._contextLoaded.bind(this),fail:b.exception}])},h.prototype._contextLoaded=function(a){var d=this;f.render("tool_lp/user_competency_summary_in_course",a).done(function(a,e){c.get_string("usercompetencysummary","report_competency").done(function(b){new g(b,a,f.runTemplateJS.bind(f,e),d._refresh.bind(d),!0)}).fail(b.exception)}).fail(b.exception)},h.prototype._refresh=function(){var c=a(this._regionSelector),e=c.data("courseid"),f=c.data("groupid"),g=c.data("userid"),h=c.data("onlyactive");d.call([{methodname:"report_competency_data_for_report",args:{courseid:e,groupid:f,userid:g,onlyactive:h},done:this._pageContextLoaded.bind(this),fail:b.exception}])},h.prototype._pageContextLoaded=function(a){var c=this;f.render("report_competency/report",a).done(function(a,b){f.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},h.prototype._regionSelector=null,h.prototype._userCompetencySelector=null,h});
|
1
report/competency/amd/build/user_course_navigation.min.js
vendored
Normal file
1
report/competency/amd/build/user_course_navigation.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
define(["jquery"],function(a){var b=function(b,c,d,e){this._baseUrl=c,this._userId=d+"",this._courseId=e,this._ignoreFirstUser=!0,a(b).on("change",this._userChanged.bind(this))};return b.prototype._userChanged=function(b){if(this._ignoreFirstUser)return void(this._ignoreFirstUser=!1);var c=a(b.target).val(),d="?user="+c+"&id="+this._courseId;document.location=this._baseUrl+d},b.prototype._userId=null,b.prototype._courseId=null,b.prototype._baseUrl=null,b.prototype._ignoreFirstUser=null,b});
|
@ -83,11 +83,12 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
|
||||
var region = $(this._regionSelector);
|
||||
var courseId = region.data('courseid');
|
||||
var groupId = region.data('groupid');
|
||||
var userId = region.data('userid');
|
||||
var onlyActive = region.data('onlyactive');
|
||||
|
||||
ajax.call([{
|
||||
methodname : 'report_competency_data_for_report',
|
||||
args: { courseid: courseId, groupid: groupId, onlyactive: onlyActive },
|
||||
args: { courseid: courseId, groupid: groupId, userid: userId, onlyactive: onlyActive },
|
||||
done: this._pageContextLoaded.bind(this),
|
||||
fail: notification.exception
|
||||
}]);
|
||||
|
71
report/competency/amd/src/user_course_navigation.js
Normal file
71
report/competency/amd/src/user_course_navigation.js
Normal file
@ -0,0 +1,71 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Module to navigation between users in a course.
|
||||
*
|
||||
* @package report_competency
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define(['jquery'], function($) {
|
||||
|
||||
/**
|
||||
* UserCourseNavigation
|
||||
*
|
||||
* @param {String} The selector of the user element.
|
||||
* @param {String} The base url for the page (no params).
|
||||
* @param {Number} The course id
|
||||
* @param {Number} The user id
|
||||
*/
|
||||
var UserCourseNavigation = function(userSelector, baseUrl, userId, courseId) {
|
||||
this._baseUrl = baseUrl;
|
||||
this._userId = userId + '';
|
||||
this._courseId = courseId;
|
||||
this._ignoreFirstUser = true;
|
||||
|
||||
$(userSelector).on('change', this._userChanged.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* The user was changed in the select list.
|
||||
*
|
||||
* @method _userChanged
|
||||
* @param {Event} e
|
||||
*/
|
||||
UserCourseNavigation.prototype._userChanged = function(e) {
|
||||
if (this._ignoreFirstUser) {
|
||||
this._ignoreFirstUser = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var newUserId = $(e.target).val();
|
||||
var queryStr = '?user=' + newUserId + '&id=' + this._courseId;
|
||||
document.location = this._baseUrl + queryStr;
|
||||
};
|
||||
|
||||
/** @type {Number} The id of the user. */
|
||||
UserCourseNavigation.prototype._userId = null;
|
||||
/** @type {Number} The id of the course. */
|
||||
UserCourseNavigation.prototype._courseId = null;
|
||||
/** @type {String} Plugin base url. */
|
||||
UserCourseNavigation.prototype._baseUrl = null;
|
||||
/** @type {Boolean} Ignore the first change event for users. */
|
||||
UserCourseNavigation.prototype._ignoreFirstUser = null;
|
||||
|
||||
return /** @alias module:report_competency/user_course_navigation */ UserCourseNavigation;
|
||||
|
||||
});
|
@ -33,7 +33,7 @@ use external_function_parameters;
|
||||
use external_multiple_structure;
|
||||
use external_single_structure;
|
||||
use external_value;
|
||||
use tool_lp\external\competency_exporter;
|
||||
use tool_lp\external\competency_summary_exporter;
|
||||
use tool_lp\external\course_summary_exporter;
|
||||
use tool_lp\external\user_competency_exporter;
|
||||
use tool_lp\external\user_summary_exporter;
|
||||
@ -57,6 +57,11 @@ class external extends external_api {
|
||||
'The course id',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$userid = new external_value(
|
||||
PARAM_INT,
|
||||
'The user id',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$groupid = new external_value(
|
||||
PARAM_INT,
|
||||
'The group id',
|
||||
@ -69,6 +74,7 @@ class external extends external_api {
|
||||
);
|
||||
$params = array(
|
||||
'courseid' => $courseid,
|
||||
'userid' => $userid,
|
||||
'groupid' => $groupid,
|
||||
'onlyactive' => $onlyactive,
|
||||
);
|
||||
@ -83,21 +89,25 @@ class external extends external_api {
|
||||
* @param boolean $onlyactive Only show active enrolments
|
||||
* @return \stdClass
|
||||
*/
|
||||
public static function data_for_report($courseid, $groupid, $onlyactive) {
|
||||
public static function data_for_report($courseid, $userid, $groupid, $onlyactive) {
|
||||
global $PAGE;
|
||||
|
||||
$params = self::validate_parameters(
|
||||
self::data_for_report_parameters(),
|
||||
array(
|
||||
'courseid' => $courseid,
|
||||
'userid' => $userid,
|
||||
'groupid' => $groupid,
|
||||
'onlyactive' => $onlyactive
|
||||
)
|
||||
);
|
||||
$context = context_course::instance($courseid);
|
||||
$context = context_course::instance($params['courseid']);
|
||||
self::validate_context($context);
|
||||
if (!is_enrolled($context, $params['userid'], 'tool/lp:coursecompetencygradable')) {
|
||||
throw new coding_exception('invaliduser');
|
||||
}
|
||||
|
||||
$renderable = new output\report($params['courseid'], $params['groupid'], $params['onlyactive']);
|
||||
$renderable = new output\report($params['courseid'], $params['userid'], $params['groupid'], $params['onlyactive']);
|
||||
$renderer = $PAGE->get_renderer('report_competency');
|
||||
|
||||
$data = $renderable->export_for_template($renderer);
|
||||
@ -115,17 +125,13 @@ class external extends external_api {
|
||||
'courseid' => new external_value(PARAM_INT, 'Course id'),
|
||||
'groupid' => new external_value(PARAM_INT, 'Group id'),
|
||||
'onlyactive' => new external_value(PARAM_BOOL, 'Only include active enrolments'),
|
||||
'competencies' => new external_multiple_structure(
|
||||
competency_exporter::get_read_structure()
|
||||
),
|
||||
'user' => user_summary_exporter::get_read_structure(),
|
||||
'course' => course_summary_exporter::get_read_structure(),
|
||||
'pluginbaseurl' => new external_value(PARAM_LOCALURL, 'Url to the tool_lp plugin folder on this Moodle site'),
|
||||
'usercompetencies' => new external_multiple_structure(
|
||||
new external_single_structure(array(
|
||||
'user' => user_summary_exporter::get_read_structure(),
|
||||
'usercompetencies' => new external_multiple_structure(
|
||||
user_competency_exporter::get_read_structure()
|
||||
)
|
||||
'usercompetency' => user_competency_exporter::get_read_structure(),
|
||||
'competency' => competency_summary_exporter::get_read_structure()
|
||||
))
|
||||
)
|
||||
));
|
||||
|
@ -50,4 +50,14 @@ class renderer extends plugin_renderer_base {
|
||||
return parent::render_from_template('report_competency/report', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param user_course_navigation $nav
|
||||
* @return string
|
||||
*/
|
||||
public function render_user_course_navigation(user_course_navigation $nav) {
|
||||
$data = $nav->export_for_template($this);
|
||||
return parent::render_from_template('report_competency/user_course_navigation', $data);
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,13 @@
|
||||
namespace report_competency\output;
|
||||
|
||||
use context_course;
|
||||
use tool_lp\external\competency_exporter;
|
||||
use tool_lp\external\competency_summary_exporter;
|
||||
use tool_lp\external\course_summary_exporter;
|
||||
use tool_lp\external\user_competency_exporter;
|
||||
use tool_lp\external\user_summary_exporter;
|
||||
use tool_lp\user_competency;
|
||||
use renderable;
|
||||
use core_user;
|
||||
use templatable;
|
||||
use renderer_base;
|
||||
use moodle_url;
|
||||
@ -61,22 +62,16 @@ class report implements renderable, templatable {
|
||||
* Construct this renderable.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param int $userid The user id
|
||||
* @param int $groupid The group id
|
||||
* @param bool $onlyactive Only show active (not suspended) students.
|
||||
*/
|
||||
public function __construct($courseid, $groupid, $onlyactive) {
|
||||
public function __construct($courseid, $userid, $groupid, $onlyactive) {
|
||||
$this->courseid = $courseid;
|
||||
$this->groupid = $groupid;
|
||||
$this->userid = $userid;
|
||||
$this->onlyactive = $onlyactive;
|
||||
$this->context = context_course::instance($courseid);
|
||||
// Get all the competencies in this course.
|
||||
$this->competencies = api::list_course_competencies($courseid);
|
||||
|
||||
// Get all the users in this course.
|
||||
// tool/lp:coursecompetencygradable
|
||||
$this->users = get_enrolled_users($this->context, 'tool/lp:coursecompetencygradable', $groupid,
|
||||
'u.*', null, 0, 0, $onlyactive);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,20 +88,6 @@ class report implements renderable, templatable {
|
||||
$data->groupid = $this->groupid;
|
||||
$data->onlyactive = $this->onlyactive;
|
||||
|
||||
$competencies = array();
|
||||
$contextcache = array();
|
||||
foreach ($this->competencies as $coursecompetency) {
|
||||
$competency = $coursecompetency['competency'];
|
||||
if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
|
||||
$contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
|
||||
}
|
||||
$context = $contextcache[$competency->get_competencyframeworkid()];
|
||||
$exporter = new competency_exporter($competency, array('context' => $context));
|
||||
$record = $exporter->export($output);
|
||||
array_push($competencies, $record);
|
||||
}
|
||||
$data->competencies = $competencies;
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $this->courseid));
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$exporter = new course_summary_exporter($course, array('context' => $coursecontext));
|
||||
@ -116,44 +97,55 @@ class report implements renderable, templatable {
|
||||
$data->usercompetencies = array();
|
||||
$scalecache = array();
|
||||
$frameworkcache = array();
|
||||
foreach ($this->users as $user) {
|
||||
$usercompetencies = api::list_user_competencies_in_course($this->courseid, $user->id);
|
||||
|
||||
$user = core_user::get_user($this->userid);
|
||||
|
||||
$exporter = new user_summary_exporter($user);
|
||||
$data->user = $exporter->export($output);
|
||||
$data->usercompetencies = array();
|
||||
$coursecompetencies = api::list_course_competencies($this->courseid);
|
||||
$usercompetencies = api::list_user_competencies_in_course($this->courseid, $user->id);
|
||||
|
||||
foreach ($usercompetencies as $usercompetency) {
|
||||
$onerow = new stdClass();
|
||||
$exporter = new user_summary_exporter($user);
|
||||
$onerow->user = $exporter->export($output);
|
||||
$onerow->usercompetencies = array();
|
||||
|
||||
foreach ($this->competencies as $coursecompetency) {
|
||||
$competency = $coursecompetency['competency'];
|
||||
$usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $competency->get_id()));
|
||||
foreach ($usercompetencies as $uc) {
|
||||
if ($uc->get_competencyid() == $competency->get_id()) {
|
||||
$usercompetency = $uc;
|
||||
break;
|
||||
}
|
||||
$competency = null;
|
||||
foreach ($coursecompetencies as $coursecompetency) {
|
||||
if ($coursecompetency['competency']->get_id() == $usercompetency->get_competencyid()) {
|
||||
$competency = $coursecompetency['competency'];
|
||||
break;
|
||||
}
|
||||
|
||||
// Fetch the scale.
|
||||
$scaleid = $competency->get_scaleid();
|
||||
if ($scaleid === null) {
|
||||
if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
|
||||
$frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
|
||||
}
|
||||
$framework = $frameworkcache[$competency->get_competencyframeworkid()];
|
||||
$scaleid = $framework->get_scaleid();
|
||||
if (!isset($scalecache[$scaleid])) {
|
||||
$scalecache[$competency->get_scaleid()] = $framework->get_scale();
|
||||
}
|
||||
|
||||
} else if (!isset($scalecache[$scaleid])) {
|
||||
$scalecache[$competency->get_scaleid()] = $competency->get_scale();
|
||||
}
|
||||
$scale = $scalecache[$competency->get_scaleid()];
|
||||
|
||||
$exporter = new user_competency_exporter($usercompetency, array('scale' => $scale));
|
||||
$record = $exporter->export($output);
|
||||
array_push($onerow->usercompetencies, $record);
|
||||
}
|
||||
if (!$competency) {
|
||||
continue;
|
||||
}
|
||||
// Fetch the framework.
|
||||
if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
|
||||
$frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
|
||||
}
|
||||
$framework = $frameworkcache[$competency->get_competencyframeworkid()];
|
||||
|
||||
// Fetch the scale.
|
||||
$scaleid = $competency->get_scaleid();
|
||||
if ($scaleid === null) {
|
||||
$scaleid = $framework->get_scaleid();
|
||||
if (!isset($scalecache[$scaleid])) {
|
||||
$scalecache[$competency->get_scaleid()] = $framework->get_scale();
|
||||
}
|
||||
|
||||
} else if (!isset($scalecache[$scaleid])) {
|
||||
$scalecache[$competency->get_scaleid()] = $competency->get_scale();
|
||||
}
|
||||
$scale = $scalecache[$competency->get_scaleid()];
|
||||
|
||||
$exporter = new user_competency_exporter($usercompetency, array('scale' => $scale));
|
||||
$record = $exporter->export($output);
|
||||
$onerow->usercompetency = $record;
|
||||
$exporter = new competency_summary_exporter(null, array('competency' => $competency,
|
||||
'framework' => $framework,
|
||||
'context' => $framework->get_context(),
|
||||
'relatedcompetencies' => array(),
|
||||
'linkedcourses' => array()));
|
||||
$onerow->competency = $exporter->export($output);
|
||||
array_push($data->usercompetencies, $onerow);
|
||||
}
|
||||
|
||||
|
113
report/competency/classes/output/user_course_navigation.php
Normal file
113
report/competency/classes/output/user_course_navigation.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* User navigation class.
|
||||
*
|
||||
* @package report_competency
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace report_competency\output;
|
||||
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use templatable;
|
||||
use context_course;
|
||||
use \tool_lp\external\user_summary_exporter;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* User course navigation class.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_course_navigation implements renderable, templatable {
|
||||
|
||||
/** @var userid */
|
||||
protected $userid;
|
||||
|
||||
/** @var courseid */
|
||||
protected $courseid;
|
||||
|
||||
/** @var baseurl */
|
||||
protected $baseurl;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param $userid
|
||||
* @param $courseid
|
||||
* @param $baseurl
|
||||
*/
|
||||
public function __construct($userid, $courseid, $baseurl) {
|
||||
$this->userid = $userid;
|
||||
$this->courseid = $courseid;
|
||||
$this->baseurl = $baseurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the data.
|
||||
*
|
||||
* @param renderer_base $output
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
global $CFG, $DB, $SESSION, $PAGE;
|
||||
|
||||
$context = context_course::instance($this->courseid);
|
||||
|
||||
$data = new stdClass();
|
||||
$data->userid = $this->userid;
|
||||
$data->courseid = $this->courseid;
|
||||
$data->baseurl = $this->baseurl;
|
||||
|
||||
if (has_capability('tool/lp:coursecompetencymanage', $context)) {
|
||||
$course = $DB->get_record('course', array('id' => $this->courseid));
|
||||
$currentgroup = optional_param('group', null, PARAM_INT);
|
||||
$select = groups_allgroups_course_menu($course, $PAGE->url, true, $currentgroup);
|
||||
// Fetch showactive.
|
||||
$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
|
||||
$showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
|
||||
$showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
|
||||
|
||||
// Fetch current active group.
|
||||
$groupmode = groups_get_course_groupmode($course);
|
||||
$currentgroup = $SESSION->activegroup[$course->id][$groupmode][$course->defaultgroupingid];
|
||||
|
||||
$users = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup,
|
||||
'u.*', null, 0, 0, $showonlyactiveenrol);
|
||||
|
||||
$data->users = array();
|
||||
foreach ($users as $user) {
|
||||
$exporter = new user_summary_exporter($user);
|
||||
$user = $exporter->export($output);
|
||||
if ($user->id == $this->userid) {
|
||||
$user->selected = true;
|
||||
}
|
||||
$data->users[] = $user;
|
||||
}
|
||||
$data->hasusers = true;
|
||||
} else {
|
||||
$data->users = array();
|
||||
$data->hasusers = false;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -31,30 +31,7 @@ $course = $DB->get_record('course', $params, '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
$context = context_course::instance($course->id);
|
||||
$currentgroup = optional_param('group', null, PARAM_INT);
|
||||
$urlparams = array('id' => $id, 'group' => $currentgroup);
|
||||
|
||||
$url = new moodle_url('/report/competency/index.php', $urlparams);
|
||||
$title = get_string('pluginname', 'report_competency');
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$coursename = format_text($course->fullname, false, array('context' => $context));
|
||||
$PAGE->set_heading($coursename);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$output = $PAGE->get_renderer('report_competency');
|
||||
echo $output->header();
|
||||
echo $output->heading($title);
|
||||
|
||||
$select = groups_allgroups_course_menu($course, $url, true, $currentgroup);
|
||||
|
||||
// User cannot see any group.
|
||||
if (empty($select)) {
|
||||
echo $OUTPUT->heading(get_string("notingroup"));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
} else {
|
||||
echo $select;
|
||||
}
|
||||
$currentuser = optional_param('user', null, PARAM_INT);
|
||||
|
||||
// Fetch current active group.
|
||||
$groupmode = groups_get_course_groupmode($course);
|
||||
@ -65,7 +42,60 @@ $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
|
||||
$showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
|
||||
$showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
|
||||
|
||||
$page = new \report_competency\output\report($course->id, $currentgroup, $showonlyactiveenrol);
|
||||
if (!$currentuser) {
|
||||
$users = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup,
|
||||
'u.id', null, 0, 1, $showonlyactiveenrol);
|
||||
|
||||
if (empty($users)) {
|
||||
print_error('noparticipants');
|
||||
}
|
||||
$first = array_pop($users);
|
||||
$currentuser = $first->id;
|
||||
} else {
|
||||
if (!is_enrolled($context, $currentuser, 'tool/lp:coursecompetencygradable')) {
|
||||
print_error('invaliduser');
|
||||
}
|
||||
}
|
||||
|
||||
$urlparams = array('id' => $id, 'group' => $currentgroup, 'user' => $currentuser);
|
||||
|
||||
|
||||
$url = new moodle_url('/report/competency/index.php', $urlparams);
|
||||
$title = get_string('pluginname', 'report_competency');
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($title);
|
||||
$coursename = format_text($course->fullname, false, array('context' => $context));
|
||||
$PAGE->set_heading($coursename);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$output = $PAGE->get_renderer('report_competency');
|
||||
|
||||
$user = core_user::get_user($currentuser);
|
||||
$usercontext = context_user::instance($currentuser);
|
||||
$userheading = array(
|
||||
'heading' => fullname($user),
|
||||
'user' => $user,
|
||||
'usercontext' => $usercontext
|
||||
);
|
||||
echo $output->header();
|
||||
echo $output->context_header($userheading, 3);
|
||||
echo $output->heading($title, 3);
|
||||
|
||||
$select = groups_allgroups_course_menu($course, $url, true, $currentgroup);
|
||||
|
||||
// User cannot see any group.
|
||||
if (empty($select)) {
|
||||
echo $OUTPUT->heading(get_string("notingroup"));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
} else {
|
||||
echo '<p>' . $select . '</p>';
|
||||
}
|
||||
|
||||
$baseurl = new moodle_url('/report/competency/index.php');
|
||||
$nav = new \report_competency\output\user_course_navigation($currentuser, $course->id, $baseurl);
|
||||
echo $output->render($nav);
|
||||
$page = new \report_competency\output\report($course->id, $currentuser, $currentgroup, $showonlyactiveenrol);
|
||||
echo $output->render($page);
|
||||
|
||||
echo $output->footer();
|
||||
|
@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Competency breakdown';
|
||||
$string['competency'] = 'Competency';
|
||||
$string['coursecompetencybreakdownsummary'] = 'A report of all the students in the course, and their progress towards the course competencies';
|
||||
$string['pluginname'] = 'Competency breakdown';
|
||||
$string['rating'] = 'Rating';
|
||||
$string['usercompetencysummary'] = 'User competency summary';
|
||||
|
@ -1,24 +1,18 @@
|
||||
<div data-region="competency-breakdown-report" data-courseid="{{course.id}}" data-groupid="{{groupid}}" data-onlyactive="{{onlyactive}}">
|
||||
<div data-region="competency-breakdown-report" data-courseid="{{course.id}}" data-groupid="{{groupid}}" data-userid="{{user.id}}" data-onlyactive="{{onlyactive}}">
|
||||
<div class="row-fluid">
|
||||
<span class="span6">
|
||||
<table class="table table-bordered">
|
||||
<summary>{{#str}}coursecompetencybreakdownsummary, report_competency{{/str}}</summary>
|
||||
<summary><p>{{#str}}coursecompetencybreakdownsummary, report_competency{{/str}}</p></summary>
|
||||
<tr>
|
||||
<th scope="col"><span class="accesshide">{{#str}}students{{/str}}</span></th>
|
||||
{{#competencies}}
|
||||
<th scope="col">
|
||||
<a href="#" data-action="competency-dialogue" data-id="{{id}}">
|
||||
{{shortname}} - {{idnumber}}
|
||||
</a>
|
||||
</th>
|
||||
{{/competencies}}
|
||||
<th scope="col">{{#str}}competency, report_competency{{/str}}</span></th>
|
||||
<th scope="col">{{#str}}rating, report_competency{{/str}}</span></th>
|
||||
</tr>
|
||||
{{#usercompetencies}}
|
||||
<tr>
|
||||
<th scope="row">
|
||||
{{#user}}
|
||||
{{> tool_lp/user_summary }}
|
||||
{{/user}}
|
||||
</th>
|
||||
{{#usercompetencies}}
|
||||
{{#competency}}
|
||||
<td><a href="#" data-action="competency-dialogue" data-id="{{competency.id}}">{{competency.shortname}} - {{competency.idnumber}}</a></td>
|
||||
{{/competency}}
|
||||
{{#usercompetency}}
|
||||
<td class="alert {{#proficiency}}alert-success{{/proficiency}}"
|
||||
data-user-competency="true"
|
||||
data-userid="{{user.id}}"
|
||||
@ -26,10 +20,11 @@
|
||||
data-courseid="{{course.id}}">
|
||||
{{> report_competency/user_competency_summary}}
|
||||
</td>
|
||||
{{/usercompetencies}}
|
||||
</tr>
|
||||
{{/usercompetency}}
|
||||
{{/usercompetencies}}
|
||||
</table>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{{#js}}
|
||||
require(['tool_lp/competencydialogue'], function(Compdialogue) {
|
||||
|
20
report/competency/templates/user_course_navigation.mustache
Normal file
20
report/competency/templates/user_course_navigation.mustache
Normal file
@ -0,0 +1,20 @@
|
||||
<form class="pull-right well user-competency-course-navigation">
|
||||
{{#hasusers}}
|
||||
<span>
|
||||
<label for="user-nav-{{uniqid}}" class="accesshide">{{#str}}jumptouser, tool_lp{{/str}}</label>
|
||||
<select id="user-nav-{{uniqid}}">
|
||||
{{#users}}
|
||||
<option value="{{id}}" {{#selected}}selected="selected"{{/selected}}>{{fullname}}</option>
|
||||
{{/users}}
|
||||
</select>
|
||||
</span>
|
||||
{{/hasusers}}
|
||||
</form>
|
||||
{{#js}}
|
||||
require(['core/form-autocomplete', 'report_competency/user_course_navigation'], function(autocomplete, nav) {
|
||||
{{#hasusers}}
|
||||
autocomplete.enhance('#user-nav-{{uniqid}}', false, false, '{{#str}}jumptouser, tool_lp{{/str}}');
|
||||
{{/hasusers}}
|
||||
(new nav('#user-nav-{{uniqid}}', '{{baseurl}}', {{userid}}, {{courseid}}));
|
||||
});
|
||||
{{/js}}
|
Loading…
x
Reference in New Issue
Block a user