Skip to content

Commit

Permalink
Merge pull request #51 from KQMATH/release/0.1.4
Browse files Browse the repository at this point in the history
v0.1.4
  • Loading branch information
andstor authored Jun 6, 2022
2 parents f16fde3 + 91d1f94 commit 8a615be
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 80 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]


## [0.1.4] - 2022-06-06
### Fixed
- Fix Moodle colpliance violations.

## [0.1.3] - 2022-01-15
### Added
- Add help button for question ID field on manual issue registration page. #40
Expand All @@ -28,7 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Backup and Restore API.
- Privacy API is implemented in order to comply with the [General Data Protection Regulation](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) (GDPR).

[Unreleased]: https://github.com/KQMATH/moodle-local_qtracker/compare/v0.1.3...HEAD
[Unreleased]: https://github.com/KQMATH/moodle-local_qtracker/compare/v0.1.4...HEAD
[0.1.4]: https://github.com/KQMATH/moodle-local_qtracker/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/KQMATH/moodle-local_qtracker/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/KQMATH/moodle-local_qtracker/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/KQMATH/moodle-local_qtracker/compare/v0.1.0...v0.1.1
2 changes: 1 addition & 1 deletion classes/external/delete_issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static function execute($issueid) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($issue->get_issue_obj(), 'edit');
local_qtracker_issue_require_capability_on($issue->get_issue_obj(), 'edit');

if (empty($warnings)) {
$deleted = $issue->delete();
Expand Down
4 changes: 2 additions & 2 deletions classes/external/delete_issue_relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public static function execute($parentid, $childid) {
self::validate_context($childcontext);

// Capability checking.
issue_require_capability_on($parent->get_issue_obj(), 'edit');
issue_require_capability_on($child->get_issue_obj(), 'edit');
local_qtracker_issue_require_capability_on($parent->get_issue_obj(), 'edit');
local_qtracker_issue_require_capability_on($child->get_issue_obj(), 'edit');

if (empty($warnings)) {
$deleted = $parent->remove_child($child);
Expand Down
2 changes: 1 addition & 1 deletion classes/external/edit_issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function execute($issueid, $issuetitle, $issuedescription) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($issue->get_issue_obj(), 'edit');
local_qtracker_issue_require_capability_on($issue->get_issue_obj(), 'edit');

if (empty($params['issuetitle'])) {
$warnings[] = array(
Expand Down
2 changes: 1 addition & 1 deletion classes/external/get_issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static function execute($issueid) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($issue->get_issue_obj(), 'view');
local_qtracker_issue_require_capability_on($issue->get_issue_obj(), 'view');

if (empty($warnings)) {
$issuedata['id'] = $issue->get_id();
Expand Down
4 changes: 2 additions & 2 deletions classes/external/get_issue_children.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static function execute($issueid) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($issue->get_issue_obj(), 'view');
local_qtracker_issue_require_capability_on($issue->get_issue_obj(), 'view');


$children = $issue->get_children();
Expand All @@ -108,7 +108,7 @@ public static function execute($issueid) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($child->get_id(), 'view');
local_qtracker_issue_require_capability_on($child->get_id(), 'view');

$renderer = $PAGE->get_renderer('core');
$exporter = new issue_exporter($child->get_issue_obj(), ['context' => $context]);
Expand Down
4 changes: 2 additions & 2 deletions classes/external/get_issue_parents.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static function execute($issueid) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($issue->get_issue_obj(), 'view');
local_qtracker_issue_require_capability_on($issue->get_issue_obj(), 'view');


$parents = $issue->get_parents();
Expand All @@ -110,7 +110,7 @@ public static function execute($issueid) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($parent->get_id(), 'view');
local_qtracker_issue_require_capability_on($parent->get_id(), 'view');

$renderer = $PAGE->get_renderer('core');
$exporter = new issue_exporter($parent->get_issue_obj(), ['context' => $context]);
Expand Down
2 changes: 1 addition & 1 deletion classes/external/get_issues.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function execute($criteria = array(), $from, $limit) {
self::validate_context($context);

// Capability checking.
issue_require_capability_on($issue, 'view');
local_qtracker_issue_require_capability_on($issue, 'view');

$renderer = $PAGE->get_renderer('core');
$exporter = new issue_exporter($issue, ['context' => $context]);
Expand Down
4 changes: 2 additions & 2 deletions classes/external/set_issue_relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public static function execute($parentid, $childid) {
self::validate_context($childcontext);

// Capability checking.
issue_require_capability_on($parent->get_issue_obj(), 'edit');
issue_require_capability_on($child->get_issue_obj(), 'edit');
local_qtracker_issue_require_capability_on($parent->get_issue_obj(), 'edit');
local_qtracker_issue_require_capability_on($child->get_issue_obj(), 'edit');

if (empty($warnings)) {
$added = $parent->supersede_issue($child);
Expand Down
11 changes: 0 additions & 11 deletions classes/issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,6 @@ public function open() {
$DB->update_record('local_qtracker_issue', $this->issue);
}

/**
* Delete this issue.
*
* @return void
*/
public function comment() {

$this->comments;
$DB->update_record('local_qtracker_issue', $this->issue);
}

/**
* Delete this issue and related comments.
*
Expand Down
7 changes: 3 additions & 4 deletions classes/output/issue_registration_block.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public function export_for_template(renderer_base $output) {

$select = new stdClass();
$options = array();
$select->name = "slot";;
$select->label = "Question";
$select->name = "slot";
$select->label = get_string("question");
$select->helpicon = $this->helpicon->export_for_template($output);

foreach ($this->questions as $key => $question) {
Expand All @@ -131,12 +131,11 @@ public function export_for_template(renderer_base $output) {

$data->qubaid = $this->quba->get_id();
$data->action = $url;
$data->tooltip = "This is a tooltip";

$button = new stdClass();
$button->type = "submit";
$button->classes = "col-auto";
$button->label = "Submit new issue";
$button->label = get_string('submitnewissue', 'local_qtracker');
$data->button = $button;
$data->issueids = json_encode($this->issueids);
$data->contextid = $this->contextid;
Expand Down
4 changes: 2 additions & 2 deletions classes/reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function create(int $sourceid, int $targetid, string $reftype) {
$referenceobj = new \stdClass();
$referenceobj->sourceid = $sourceid;
$referenceobj->targetid = $targetid;
if (is_reference_type($reftype)) {
if (local_qtracker_is_reference_type($reftype)) {
$referenceobj->reftype = $reftype;
} else {
throw new coding_exception('Not a valid reference type ' . $reftype);
Expand Down Expand Up @@ -167,7 +167,7 @@ public function delete() {
*/
public function set_reftype($type) {
global $DB;
if (is_reference_type($type)) {
if (local_qtracker_is_reference_type($type)) {
$this->reference->reftype = $type;
$DB->update_record('local_qtracker_reference', $this->reference);
} else {
Expand Down
45 changes: 5 additions & 40 deletions issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

require_once('../../config.php');
require_once($CFG->dirroot . '/local/qtracker/lib.php');
require_once($CFG->dirroot . '/local/qtracker/locallib.php');

global $DB, $OUTPUT, $PAGE, $USER;

Expand Down Expand Up @@ -86,42 +87,6 @@
redirect($issuesurl);
}

/**
* Send comment as message.
*/
function send_comment($course, issue $issue, issue_comment $comment) {
global $DB, $USER, $PAGE;

$htmlemailrenderer = $PAGE->get_renderer('local_qtracker', 'email', 'htmlemail');
$textemailrenderer = $PAGE->get_renderer('local_qtracker', 'email', 'textemail');

$recipient = $DB->get_record('user', array('id' => $issue->get_userid()));
$postsubject = get_string('issueupdatednotify', 'local_qtracker', $issue->get_title());

$data = new issue_comment_email($course, $comment, $USER, $recipient);

$message = new \core\message\message();
$message->component = 'local_qtracker';
$message->name = 'issueresponse';
$message->userfrom = $USER;
$message->userto = $recipient;
$message->subject = $postsubject;
$message->fullmessage = $textemailrenderer->render($data);
$message->fullmessageformat = FORMAT_HTML;
$message->fullmessagehtml = $htmlemailrenderer->render($data);
$message->smallmessage = '';
$message->notification = 1;
$message->replyto = null;

// TODO: make issue.php page handle correctly students viewing comments.
//$contexturl = new \moodle_url('/local/qtracker/issue.php', ['courseid' => $course->id, 'issueid' => $issue->get_id()]);
//$message->contexturl = $contexturl->out();
//$message->contexturlname = $issue->get_title();

return message_send($message);
}


// Process issue actions.
$commentissue = optional_param('commentissue', false, PARAM_BOOL);
$commenttext = optional_param('commenteditor', false, PARAM_RAW);
Expand All @@ -130,7 +95,7 @@ function send_comment($course, issue $issue, issue_comment $comment) {
if ($commentissue) {
$comment = $issue->create_comment($commenttext);
if ($sendmessage) {
if (send_comment($course, $issue, $comment)) {
if (local_qtracker_send_comment($course, $issue, $comment)) {
$comment->mark_mailed();
}
}
Expand All @@ -142,7 +107,7 @@ function send_comment($course, issue $issue, issue_comment $comment) {
if ($commenttext != false) {
$comment = $issue->create_comment($commenttext);
if ($sendmessage) {
if (send_comment($course, $issue, $comment)) {
if (local_qtracker_send_comment($course, $issue, $comment)) {
$comment->mark_mailed();
}
}
Expand All @@ -160,7 +125,7 @@ function send_comment($course, issue $issue, issue_comment $comment) {
$notifycommentid = optional_param('notifycommentid', null, PARAM_INT);
if (!is_null($notifycommentid)) {
$comment = issue_comment::load($notifycommentid);
if (send_comment($course, $issue, $comment)) {
if (local_qtracker_send_comment($course, $issue, $comment)) {
$comment->mark_mailed();
}
redirect($PAGE->url);
Expand All @@ -174,7 +139,7 @@ function send_comment($course, issue $issue, issue_comment $comment) {
}

// Capability checking.
issue_require_capability_on($issue->get_issue_obj(), 'view');
local_qtracker_issue_require_capability_on($issue->get_issue_obj(), 'view');

$renderer = $PAGE->get_renderer('local_qtracker');
$questionissuepage = new question_issue_page($issue, $courseid);
Expand Down
8 changes: 4 additions & 4 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function local_qtracker_extend_navigation_course($navigation, $course, $context)
* @param string $cap 'add', 'edit', 'view'.
* @return boolean this user has the capability $cap for this issue $issue?
*/
function issue_has_capability_on($issueorid, $cap) {
function local_qtracker_issue_has_capability_on($issueorid, $cap) {
global $USER;

if (is_numeric($issueorid)) {
Expand Down Expand Up @@ -113,8 +113,8 @@ function issue_has_capability_on($issueorid, $cap) {
*
* @return boolean this user has the capability $cap for this issue $issue?
*/
function issue_require_capability_on($issue, $cap) {
if (!issue_has_capability_on($issue, $cap)) {
function local_qtracker_issue_require_capability_on($issue, $cap) {
if (!local_qtracker_issue_has_capability_on($issue, $cap)) {
print_error('nopermissions', '', '', $cap);
}
return true;
Expand All @@ -128,7 +128,7 @@ function issue_require_capability_on($issue, $cap) {
*
* @return boolean this user has the capability $cap for this issue $issue?
*/
function is_reference_type(string $type) {
function local_qtracker_is_reference_type(string $type) {
$reftypes = array(LOCAL_QTRACKER_REFERENCE_SUPERSEDED);

if (!in_array($type, $reftypes) ) {
Expand Down
65 changes: 65 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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/>.

/**
* Library of functions for QTracker.
*
* @package local_qtracker
* @author André Storhaug <[email protected]>
* @copyright 2022 NTNU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

use local_qtracker\issue;
use local_qtracker\issue_comment;
use local_qtracker\output\email\issue_comment_email;

/**
* Send comment as message.
*/
function local_qtracker_send_comment($course, issue $issue, issue_comment $comment) {
global $DB, $USER, $PAGE;

$htmlemailrenderer = $PAGE->get_renderer('local_qtracker', 'email', 'htmlemail');
$textemailrenderer = $PAGE->get_renderer('local_qtracker', 'email', 'textemail');

$recipient = $DB->get_record('user', array('id' => $issue->get_userid()));
$postsubject = get_string('issueupdatednotify', 'local_qtracker', $issue->get_title());

$data = new issue_comment_email($course, $comment, $USER, $recipient);

$message = new \core\message\message();
$message->component = 'local_qtracker';
$message->name = 'issueresponse';
$message->userfrom = $USER;
$message->userto = $recipient;
$message->subject = $postsubject;
$message->fullmessage = $textemailrenderer->render($data);
$message->fullmessageformat = FORMAT_HTML;
$message->fullmessagehtml = $htmlemailrenderer->render($data);
$message->smallmessage = '';
$message->notification = 1;
$message->replyto = null;

// TODO: make issue.php page handle correctly students viewing comments.
//$contexturl = new \moodle_url('/local/qtracker/issue.php', ['courseid' => $course->id, 'issueid' => $issue->get_id()]);
//$message->contexturl = $contexturl->out();
//$message->contexturlname = $issue->get_title();

return message_send($message);
}
8 changes: 4 additions & 4 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@
min-height: 360px;
}

.questions-table {
.path-local-qtracker .questions-table {
width: 100%;
}

.flex-grow {
.path-local-qtracker .flex-grow {
flex: 1 0 auto;
}

.resizer {
.path-local-qtracker .resizer {
border-left: 1px solid #dee2e6;
width: 5px;
height: 100%;
Expand All @@ -116,7 +116,7 @@
cursor: w-resize;
}

.questiontext {
.path-local-qtracker .questiontext {
position: relative;
zoom: 1;
padding-left: .3em;
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

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

$plugin->version = 2022011500;
$plugin->version = 2022060600;
$plugin->requires = 2016120500;
$plugin->cron = 0;
$plugin->component = 'local_qtracker';
$plugin->maturity = MATURITY_BETA;
$plugin->release = '0.1.3';
$plugin->release = '0.1.4';

0 comments on commit 8a615be

Please sign in to comment.