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

Fix: Add missing capabilities and enhance Moodle 4.4 and PHP 8.2 compatibility 1658984705 #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ protected function init() {
$this->data['objecttable'] = 'siyavula';
}

/**
* Replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'siyavula', 'pre-view', 'view.php?id=' . $this->contextinstanceid, $this->objectid,
$this->contextinstanceid);
}

public static function get_objectid_mapping() {
return array('db' => 'siyavula', 'restore' => 'siyavula');
}
Expand Down
48 changes: 48 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

/**
* Siyavula module capability definition
*
* @package mod_siyavula
* @copyright 2021 Solutto Consulting
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

$capabilities = array(

'mod/siyavula:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'guest' => CAP_ALLOW,
'user' => CAP_ALLOW,
)
),

'mod/siyavula:addinstance' => array(
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/course:manageactivities'
),
);
4 changes: 4 additions & 0 deletions lang/en/siyavula.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@
$string['pluginadministration'] = 'Siyavula Toc';
$string['modulename_help'] = 'Siyavula Toc Question';;
$string['grade'] = 'Grade Toc';
$string['siyavulaname_help'] = 'An instructor / teacher can embed a table of contents that allows a student to selection a section from an interactive widget, once done this is the same as the embedded practice filter experience - and is driven by the algorithm on www.siyavula.com.';
$string['siyavula:view'] = 'View the siyavula module';
$string['siyavula:addinstance'] = 'Add a new siyavula module';
$string['subjectnotdefined'] = 'Grade and subject not defined to render';
1 change: 1 addition & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function siyavula_grade_item_update($moduleinstance, $mastery) {
$record->timemodified = time();
$DB->update_record($siyavulagrades, $record);
} else {
$record = new stdClass();
// If not exist, insert.
$record->subject = $mastery->subject;
$record->grade = $mastery->grade;
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'mod_siyavula';
$plugin->release = '0.1.0';
$plugin->version = 2022111800;
$plugin->release = '0.1.1';
$plugin->version = 2022111801;
$plugin->requires = 2019111809;
$plugin->maturity = MATURITY_STABLE;
9 changes: 9 additions & 0 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
require(__DIR__.'/../../config.php');
require_once(__DIR__.'/lib.php');

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

use filter_siyavula\renderables\practice_activity_renderable;
use filter_siyavula\renderables\standalone_activity_renderable;

Expand Down Expand Up @@ -68,6 +70,13 @@

echo $OUTPUT->header();

// Subject and grade not configured.
if (!$moduleinstance->subject_grade_selected) {
echo core\notification::error(get_string('subjectnotdefined', 'siyavula'), false);
echo $OUTPUT->footer();
exit;
}

$info = explode(':', $moduleinstance->subject_grade_selected);
$subject = $info[0];
$grade = $info[1];
Expand Down