Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add privacy policy #43

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions block_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function specialization() {
* @return bool
*/
public function instance_allow_multiple() {
return !block_progress_on_site_page();
return !block_progress_on_my_page();
}

/**
Expand All @@ -79,7 +79,7 @@ public function instance_allow_multiple() {
* @return bool
*/
public function instance_allow_config() {
return !block_progress_on_site_page();
return !block_progress_on_my_page();
}

/**
Expand Down Expand Up @@ -119,7 +119,7 @@ public function get_content() {
}

// Draw the multi-bar content for the Dashboard and Front page.
if (block_progress_on_site_page()) {
if (block_progress_on_my_page()) {
$courses = enrol_get_my_courses();
$coursenametoshow = get_config('block_progress', 'coursenametoshow') ?: DEFAULT_COURSENAMETOSHOW;
$sql = "SELECT bi.id,
Expand Down
43 changes: 43 additions & 0 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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/>.

/**
* Privacy Subsystem implementation for block_progress.
*
* @package block_progress
* @copyright 2018 Nathan Nguyen <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace block_progress\privacy;

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

/**
* The block_progress plugin does not store any data.
*
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}
10 changes: 8 additions & 2 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ protected function specific_definition($mform) {
global $CFG, $COURSE, $DB, $OUTPUT, $SCRIPT;
$loggingenabled = true;

// Raise the max_execution time to 60 seconds for courses with many modules.
core_php_time_limit::raise(60);

// Also raise memory limit for courses with many modules.
raise_memory_limit(MEMORY_EXTRA);

// The My home version is not configurable.
if (block_progress_on_site_page()) {
if (block_progress_on_my_page()) {
return;
}

Expand Down Expand Up @@ -306,7 +312,7 @@ protected function specific_definition($mform) {
);

foreach ($sections as $i => $section) {
if (count($section->sequence) > 0) {
if ($section->sequence != null && (count($section->sequence) > 0)) {

// Output the section header.
$sectionname = get_string('section').':&nbsp;'.get_section_name($COURSE, $section);
Expand Down
4 changes: 4 additions & 0 deletions lang/en/block_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
$string['folder'] = 'Folder';
$string['forum'] = 'Forum';
$string['glossary'] = 'Glossary';
$string['groupaddnewnote'] = 'Add a common note';
$string['hotpot'] = 'Hot Potatoes';
$string['hsuforum'] = 'Advanced Forum';
$string['hvp'] = 'Interactive Content';
$string['imscp'] = 'IMS Content Package';
$string['journal'] = 'Journal';
$string['lesson'] = 'Lesson';
Expand Down Expand Up @@ -251,3 +253,5 @@
// For My home page.
$string['no_blocks'] = "No Progress Bar blocks are set up for your courses.";
$string['no_courses'] = "You are not enrolled in any courses. Only bars from enrolled courses will be shown.";

$string['privacy:metadata'] = "Progress block does not store any personal data.";
39 changes: 33 additions & 6 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ function block_progress_monitorable_modules() {
'defaultAction' => 'viewed'
),
'forum' => array(
'defaultTime' => 'assesstimefinish',
'actions' => array(
'posted_to' => "SELECT id
FROM {forum_posts}
Expand Down Expand Up @@ -565,6 +566,27 @@ function block_progress_monitorable_modules() {
),
'defaultAction' => 'posted_to'
),
'hvp' => array(
'actions' => array(
'viewed' => array (
'logstore_legacy' => "SELECT id
FROM {log}
WHERE course = :courseid
AND module = 'hvp'
AND action = 'view'
AND cmid = :cmid
AND userid = :userid",
'sql_internal_reader' => "SELECT id
FROM {log}
WHERE courseid = :courseid
AND component = 'mod_hvp'
AND action = 'viewed'
AND objectid = :eventid
AND userid = :userid",
),
),
'defaultAction' => 'viewed'
),
'imscp' => array(
'actions' => array(
'viewed' => array (
Expand Down Expand Up @@ -1563,6 +1585,11 @@ function block_progress_bar($modules, $config, $events, $userid, $instance, $att
'id' => 'progressBarInfo'.$instance.'-'.$userid.'-info');
$content .= HTML_WRITER::start_tag('div', $divoptions);
if (!$simple) {
if (isset($config->showpercentage) && $config->showpercentage == 1) {
$progress = block_progress_percentage($events, $attempts);
$content .= get_string('progress', 'block_progress').': ';
$content .= $progress.'%'.HTML_WRITER::empty_tag('br');
}
$content .= get_string('mouse_over_prompt', 'block_progress');
$content .= ' ';
$attributes = array (
Expand Down Expand Up @@ -1712,7 +1739,7 @@ function block_progress_filter_visibility($events, $userid, $coursecontext, $cou
if ($coursemodule->uservisible != 1 && empty($coursemodule->availableinfo)) {
continue;
}
} else if (!groups_course_module_visible($coursemodule, $userid)) {
} else if (!$coursemodule->uservisible) {
continue;
}
}
Expand All @@ -1728,10 +1755,10 @@ function block_progress_filter_visibility($events, $userid, $coursecontext, $cou
*
* @return bool True when on the My home page.
*/
function block_progress_on_site_page() {
global $SCRIPT, $COURSE;
function block_progress_on_my_page() {
global $SCRIPT;

return $SCRIPT === '/my/index.php' || $COURSE->id == 1;
return $SCRIPT === '/my/index.php';
}

/**
Expand All @@ -1744,7 +1771,7 @@ function block_progress_get_course_context($courseid) {
if (class_exists('context_course')) {
return context_course::instance($courseid);
} else {
return get_context_instance(CONTEXT_COURSE, $courseid);
return context_course::instance($courseid);
}
}

Expand All @@ -1758,7 +1785,7 @@ function block_progress_get_block_context($blockid) {
if (class_exists('context_block')) {
return context_block::instance($blockid);
} else {
return get_context_instance(CONTEXT_BLOCK, $blockid);
return context_block::instance($blockid);
}
}

Expand Down
4 changes: 2 additions & 2 deletions overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
}
if (!empty($CFG->enablenotes) && has_capability('moodle/notes:manage', $context)) {
$displaylist['addnote.php'] = get_string('addnewnote', 'notes');
$displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'notes');
$displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'block_progress');
}
echo html_writer::tag('label', get_string("withselectedusers"), array('for' => 'formactionid'));
echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionid'));
Expand All @@ -339,7 +339,7 @@
}

// Organise access to JS for messaging.
$module = array('name' => 'core_user', 'fullpath' => '/user/module.js');
$module = array('name' => 'core_user', 'fullpath' => '/blocks/progress/user_module.js');
$PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module);

// Organise access to JS for progress bars.
Expand Down
75 changes: 75 additions & 0 deletions user_module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

M.core_user = {};

M.core_user.init_participation = function(Y) {
Y.on('change', function() {
var action = Y.one('#formactionid');
if (action.get('value') == '') {
return;
}
var ok = false;
Y.all('input.usercheckbox').each(function() {
if (this.get('checked')) {
ok = true;
}
});
if (!ok) {
// no checkbox selected
return;
}

if (action.get('value') == 'email') {
var mailto = '';
Y.all('input.usercheckbox').each(function() {
if (this.get('checked')) {
var email = document.getElementById(this.get('name')+'_email').value;
if (mailto.length > 0) {
mailto = mailto+'; ';
}
mailto = mailto+email;
}
});
location.href='mailto:?bcc='+mailto;
document.getElementById('formactionid').selectedIndex = 0;
return;
}

Y.one('#participantsform').submit();
}, '#formactionid');

Y.on('click', function(e) {
// Presence of a show all link indicates we should redirect to
// a page with all users listed and checked, otherwise just check
// those already shown.
var showallink = this.getAttribute('data-showallink');
if (showallink) {
window.location = showallink;
}
Y.all('input.usercheckbox').each(function() {
this.set('checked', 'checked');
});
}, '#checkall, #checkallonpage');

Y.on('click', function(e) {
Y.all('input.usercheckbox').each(function() {
this.set('checked', '');
});
}, '#checknone');
};

M.core_user.init_tree = function(Y, expand_all, htmlid) {
Y.use('yui2-treeview', function(Y) {
var tree = new Y.YUI2.widget.TreeView(htmlid);

tree.subscribe("clickEvent", function(node, event) {
// we want normal clicking which redirects to url
return false;
});

if (expand_all) {
tree.expandAll();
}

tree.render();
});
};
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$plugin->version = 2016081800;
$plugin->version = 2016081801;
$plugin->requires = 2010121000;
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'Version for Moodle 2.0 to 3.1 (final)';
$plugin->release = 'Version for Moodle 2.0 onwards';
$plugin->component = 'block_progress';