Skip to content

Commit

Permalink
2.11 (Build: 2018013002)
Browse files Browse the repository at this point in the history
Added usage statistics tab to the report.
Added a usage report permission to allow particular Moodle users access to usage statistics.
Changed H4 tags to H3 to maintain correct heading semantics.
Removed style colours applied directly to heading tags.
  • Loading branch information
jgramp committed Jan 31, 2018
1 parent 477f32e commit 0cac99d
Show file tree
Hide file tree
Showing 14 changed files with 2,091 additions and 46 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ The report requires jQuery to be enabled, otherwise sorting and searching will n

---
Change log:
2.10 (Build: 2017122300)
2.11 (Build: 2018013002)
Added usage statistics tab to the report.
Added a usage report permission to allow particular Moodle users access to usage statistics.
Changed H4 tags to H3 to maintain correct heading semantics.
Removed style colours applied directly to heading tags.

2.10 (Build: 2018013000)
Fixed pop-up self-reflective notes not appearing in front of greyed out background on some themes.

2.9 (Build: 2017112800)
Expand All @@ -41,6 +47,7 @@ Moved some of the css out of the code and into the css file (still more cleaning
Added an index on the log table to speed the queries where the date the feedback is viewed is shown.
Changed the date format to d-m-Y so the full year is shown and isn't ambiguous - e.g. 13-5-2017, instead of 13-5-17.

Change log:
2.8.12 (Build: 2017060600)
Fixed spelling errors in en lang file.
Fixed bug where Turnitin Assignment parts with the marks available changed from 100 show the correct total marks available.
Expand Down
83 changes: 83 additions & 0 deletions classes/event/myfeedbackreport_viewed_usagedash.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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_myfeedback report viewed usage dashoboard event.
*
* @package report_myfeedback
* @author Jessica Gramp <[email protected]> and <[email protected]>
* @author Delvon Forrester <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace report_myfeedback\event;

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

class myfeedbackreport_viewed_usagedash extends \core\event\base {

/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}

/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventreportviewed_usage', 'report_myfeedback');
}

/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the My feedback Usage dashboard.";
}

/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/report/myfeedback/index.php', array('user' => $this->relateduserid));
}

/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}

}
8 changes: 8 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@
'student' => CAP_ALLOW
)
),
'report/myfeedback:usage' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'manager' => CAP_PREVENT
)
)
);
6 changes: 3 additions & 3 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function xmldb_report_myfeedback_upgrade($oldversion) {
}

if ($oldversion == 2016012100) {
$field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$dbman->add_field($table, $field);
$field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$dbman->add_field($table, $field);
}

// Myfeedback savepoint reached.
Expand All @@ -52,6 +52,6 @@ function xmldb_report_myfeedback_upgrade($oldversion) {

// Myfeedback savepoint reached.
upgrade_plugin_savepoint(true, 2017112800, 'report', 'myfeedback');
}
}
return true; //have to be in else get an unknown error
}
30 changes: 26 additions & 4 deletions export.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@
*/

require('../../config.php');

//Because we are using sessions to store the information, if a user opens multiple tabs and tries to export,
//they will just get the data from the last tab they opened.
$data = $_SESSION["exp_sess"];
$userid = $_SESSION['myfeedback_userid'];
$username = $_SESSION['user_name'];
$tutor = $_SESSION['tutor'];
//$tutor = $_SESSION['reportname'];

//arrays to clean up the heading tags passed to the usage reports
$strfind = array(" ", ":", "\r", "\n");
$strreplace = array("_", "", "", "");

$headingtext = get_string('reportfor', 'report_myfeedback').$username."\r\n";
$event = \report_myfeedback\event\myfeedbackreport_download::create(array('context' => context_user::instance($userid), 'relateduserid' => $userid));
$filename = get_string('filename', 'report_myfeedback') . date('YmdHis') . ".csv";// file name for download
Expand All @@ -24,18 +32,32 @@
$event = \report_myfeedback\event\myfeedbackreport_downloadptutor::create(array('context' => context_user::instance($USER->id), 'relateduserid' => $userid));
$filename = get_string('p_tutor_filename', 'report_myfeedback') . date('YmdHis') . ".csv";
$excelheader = get_string('p_tutor_exportheader', 'report_myfeedback') . " \r\n";
}
if ($tutor == 'm') {//Module tutor dashboard
}elseif ($tutor == 'm') {//Module tutor dashboard
$headingtext = get_string('mod_tutor_report', 'report_myfeedback') . " \r\n";
$event = \report_myfeedback\event\myfeedbackreport_downloadmtutor::create(array('context' => context_user::instance($USER->id), 'relateduserid' => $userid));
$filename = get_string('mod_tutor_filename', 'report_myfeedback') . date('YmdHis') . ".csv";
$excelheader = get_string('mod_tutor_exportheader', 'report_myfeedback') . " \r\n";
}
if ($tutor == 'd') {//Departmental admin dashboard
}elseif ($tutor == 'd') {//Departmental admin dashboard
$headingtext = get_string('dept_admin_report', 'report_myfeedback') . " \r\n";
$event = \report_myfeedback\event\myfeedbackreport_downloaddeptadmin::create(array('context' => context_user::instance($USER->id), 'relateduserid' => $userid));
$filename = get_string('dept_admin_filename', 'report_myfeedback') . date('YmdHis') . ".csv";
$excelheader = get_string('dept_admin_exportheader', 'report_myfeedback') . " \r\n";
}elseif ($tutor == 'ustud') {//Usage dashboard for students
$headingtext = ucfirst(get_string('usage', 'report_myfeedback')) . " " . $headingtext;
$filename = str_replace($strfind, $strreplace, $headingtext) . "_" . date('YmdHis') . ".csv";
$excelheader = get_string('usage_student_exportheader', 'report_myfeedback') . " \r\n";
}elseif ($tutor == 'ustaff') {//Usage dashboard for students
$headingtext = ucfirst(get_string('usage', 'report_myfeedback')) . " " . $headingtext;
$filename = str_replace($strfind, $strreplace, $headingtext) . "_" . date('YmdHis') . ".csv";
$excelheader = get_string('usage_staff_exportheader', 'report_myfeedback') . " \r\n";
}elseif ($tutor == 'ustudover') {//Usage dashboard for students
$headingtext = ucfirst(get_string('usage', 'report_myfeedback')) . " " . $headingtext;
$filename = str_replace($strfind, $strreplace, $headingtext) . "_" . date('YmdHis') . ".csv";
$excelheader = get_string('usage_studentoverview_exportheader', 'report_myfeedback') . " \r\n";
}elseif ($tutor == 'ustaffover') {//Usage dashboard for students
$headingtext = ucfirst(get_string('usage', 'report_myfeedback')) . " " . $headingtext;
$filename = str_replace($strfind, $strreplace, $headingtext) . "_" . date('YmdHis') . ".csv";
$excelheader = get_string('usage_staffoverview_exportheader', 'report_myfeedback') . " \r\n";
}

// Trigger a table download
Expand Down
34 changes: 30 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

// This file is part of Moodle - http://moodle.org/
//
Expand Down Expand Up @@ -63,6 +63,8 @@
$progview = (isset($_POST['progselect']) ? $_POST['progselect'] : $dots); // For second level category on Dept admin dashboard
$progmodview = (isset($_POST['progmodselect']) ? $_POST['progmodselect'] : $dots); // For the course on the Dept admin dashboard
$searchuser = (isset($_POST['searchuser']) ? $_POST['searchuser'] : ''); // For the user search input on My students tab
$searchusage = (isset($_POST['searchusage']) ? $_POST['searchusage'] : ''); // For the search input on Usage dashboard

$_SESSION['viewmod'] = $modview;
if ($yearview) {//keep the academic year for the loggen-in session
$_SESSION['viewyear'] = $yearview;
Expand Down Expand Up @@ -124,9 +126,11 @@
//moodle/user:viewalldetails for personal tutor
//report/myfeedback:progadmin for dept admin
//report/myfeedback:student for students
//report/myfeedback:usage to see usage reports
$module_tutor = false;
$personal_tutor = false;
$progadmin = false;
$usage = false;
$prog = false;
$is_student = false;
$ownreport = '';
Expand Down Expand Up @@ -158,10 +162,17 @@
$user->lastname . get_string('progadminview', 'report_myfeedback') . $ownreport;
}

//Added this here because the usage report is not accessing a student so there is no course to get the context
//so the report_heading does not have the dept admin view
if ($report->get_dashboard_capability($USER->id, 'report/myfeedback:usage')) {
$usage = true;
}

if ($student = $report->get_dashboard_capability($USER->id, 'report/myfeedback:student')) {
$is_student = true;
}

//TODO - should we only do this if we are wanting to look at a student's report though? It would be redunant if we're just veiwing our own report, or the usage dashboard.
//This capability is something that everyone who has been enrolled on a course has on that course.
//Here we want to check the courses and see if the logged in user has modtutor or prog admin capability for the user they are trying to look at so they can see their report.
if ($mods = get_user_capability_course('moodle/course:viewparticipants', $userid, $doanything = false, $fields = 'shortname,visible')) {
Expand All @@ -187,7 +198,7 @@
}
}

//If user don't have the moodle capability to see the specific user they can't access it
//If user doesn't have the moodle capability to see the specific user they can't access it
if ($progadmin || $module_tutor || $userid == $USER->id || has_capability('moodle/user:viewdetails', $usercontext)) {
//Has access to the user
} else {
Expand All @@ -212,6 +223,9 @@
if ($thistab == 'progadmin') {
$report_heading = get_string('progadmin_dashboard', 'report_myfeedback') . $ownreport;
}
if ($thistab == 'usage') {
$report_heading = get_string('usage_dashboard', 'report_myfeedback') . $ownreport;
}

echo '<div class="heading">';
echo $OUTPUT->heading($report_heading);
Expand All @@ -233,6 +247,7 @@
if ($prog && !$viewtutee) {
$tabs[] = new tabobject('progadmin', new moodle_url($thispageurl, array('userid' => $userid, 'currenttab' => 'progadmin')), get_string('progadmin_dashboard', 'report_myfeedback'));
}

//If tutor and not viewing a tutee's report
if ($module_tutor && !$viewtutee) {
$tabs[] = new tabobject('mymodules', new moodle_url($thispageurl, array('userid' => $userid, 'currenttab' => 'mymodules')), get_string('tabs_mtutor', 'report_myfeedback'));
Expand All @@ -251,14 +266,17 @@
if ($prog && !$viewtutee) {
$currenttab = optional_param('currenttab', 'progadmin', PARAM_TEXT);
}
if ($usage && !$viewtutee) {
$currenttab = optional_param('currenttab', 'usage', PARAM_TEXT);
}

if ($showstudentstab) {
if ($prog || $module_tutor || $personal_tutor) {
$tabs[] = new tabobject('mytutees', new moodle_url($thispageurl, array('userid' => $userid, 'currenttab' => 'mytutees')), get_string('tabs_mytutees', 'report_myfeedback'));
}
}

if ($viewtutee || $is_student || is_siteadmin() || (!$prog && !$module_tutor && !$personal_tutor)) {
if ($viewtutee || $is_student || is_siteadmin() || (!$prog && !$module_tutor && !$personal_tutor && !usage)) {
$tabs[] = new tabobject('overview', new moodle_url($thispageurl, array('userid' => $userid, 'currenttab' => 'overview')), get_string('tabs_overview', 'report_myfeedback'));
$tabs[] = new tabobject('feedback', new moodle_url($thispageurl, array('userid' => $userid, 'currenttab' => 'feedback')), get_string('tabs_feedback', 'report_myfeedback'));
if ($mytutorid && !$personal_tutor) {
Expand All @@ -267,6 +285,11 @@
$currenttab = optional_param('currenttab', 'overview', PARAM_TEXT);
}

//If usage and not viewing a tutee's report
if ($usage && !$viewtutee) {
$tabs[] = new tabobject('usage', new moodle_url($thispageurl, array('userid' => $userid, 'currenttab' => 'usage')), get_string('usage_dashboard', 'report_myfeedback'));
}

echo $OUTPUT->tabtree($tabs, $currenttab);

switch ($currenttab) {
Expand Down Expand Up @@ -294,6 +317,9 @@
case 'progadmin':
require_once('programmeadmin/index.php');
break;
case 'usage':
require_once('usage/index.php');
break;
default:
break;
}
Expand All @@ -320,4 +346,4 @@
$('#wait').css({'cursor':'default','display':'none'});
$('body').css('cursor', 'default');
});
</script>";
</script>";
Loading

0 comments on commit 0cac99d

Please sign in to comment.