Skip to content

Commit

Permalink
Coding style adoptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Oct 29, 2021
1 parent d0df3bd commit c1000c1
Show file tree
Hide file tree
Showing 23 changed files with 76 additions and 156 deletions.
6 changes: 2 additions & 4 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README.md)
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down Expand Up @@ -388,8 +388,6 @@

$comments = pdfannotator_comment::read($documentid, $annotationid, $context);

// require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/comment.php');

$myrenderer = $PAGE->get_renderer('mod_pdfannotator');
$templatable = new comment($comments, $cm, $context);

Expand Down Expand Up @@ -455,7 +453,7 @@

$commentid = required_param('commentId', PARAM_INT);
$content = required_param('content', PARAM_RAW);

$data = pdfannotator_comment::update($commentid, $content, $editanypost);
echo json_encode($data);
}
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/backup_pdfannotator_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function define_my_steps() {
* @param string $content some HTML text that eventually contains URLs to the activity instance scripts
* @return string the content with the URLs encoded
*/
static public function encode_content_links($content) {
public static function encode_content_links($content) {

global $CFG, $DB;

Expand Down
15 changes: 10 additions & 5 deletions backup/moodle2/backup_pdfannotator_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,27 @@ protected function define_structure() {

// 2. Define each element separately.
$pdfannotator = new backup_nested_element('pdfannotator', array('id'), array(
'name', 'intro', 'introformat', 'usevotes', 'useprint', 'useprintcomments', 'use_studenttextbox', 'use_studentdrawing', 'useprivatecomments', 'useprotectedcomments', 'timecreated', 'timemodified'));
'name', 'intro', 'introformat', 'usevotes', 'useprint', 'useprintcomments', 'use_studenttextbox', 'use_studentdrawing',
'useprivatecomments', 'useprotectedcomments', 'timecreated', 'timemodified'));

$annotations = new backup_nested_element('annotations');
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid', 'data', 'timecreated', 'timemodified', 'modifiedby'));
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid',
'data', 'timecreated', 'timemodified', 'modifiedby'));

$subscriptions = new backup_nested_element('subscriptions');
$subscription = new backup_nested_element('subscription', array('id'), array('userid'));

$comments = new backup_nested_element('comments');
$c = array('pdfannotatorid', 'userid', 'content', 'timecreated', 'timemodified', 'modifiedby', 'visibility', 'isquestion', 'isdeleted', 'ishidden', 'solved');
$c = array('pdfannotatorid', 'userid', 'content', 'timecreated', 'timemodified', 'modifiedby', 'visibility',
'isquestion', 'isdeleted', 'ishidden', 'solved');
$comment = new backup_nested_element('comment', array('id'), $c);

$votes = new backup_nested_element('votes');
$vote = new backup_nested_element('vote', array('id'), array('userid', 'annotationid'));

$reports = new backup_nested_element('reports');
$report = new backup_nested_element('report', array('id'), array('courseid', 'pdfannotatorid', 'message', 'userid', 'timecreated', 'seen'));
$report = new backup_nested_element('report', array('id'), array('courseid', 'pdfannotatorid', 'message',
'userid', 'timecreated', 'seen'));

// 3. Build the tree (mind the right order!)
$pdfannotator->add_child($annotations);
Expand All @@ -97,7 +101,8 @@ protected function define_structure() {
// Add all annotations specific to this annotator instance.
$annotation->set_source_sql('SELECT a.* FROM {pdfannotator_annotations} a '
. 'JOIN {pdfannotator_comments} c ON a.id = c.annotationid '
. "WHERE a.pdfannotatorid = ? AND c.isquestion = 1 AND (c.visibility = 'public' OR c.visibility = 'anonymous') ",
. "WHERE a.pdfannotatorid = ? AND c.isquestion = 1 AND "
. "(c.visibility = 'public' OR c.visibility = 'anonymous') ",
array('pdfannotatorid' => backup::VAR_PARENTID));

// Add any subscriptions to this annotation.
Expand Down
8 changes: 4 additions & 4 deletions backup/moodle2/restore_pdfannotator_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function define_my_steps() {
* Define the contents in the activity that must be
* processed by the link decoder.
*/
static public function define_decode_contents() {
public static function define_decode_contents() {
$contents = array();

$contents[] = new restore_decode_content('pdfannotator', array('intro'), 'pdfannotator');
Expand All @@ -69,7 +69,7 @@ static public function define_decode_contents() {
* Define the decoding rules for links belonging
* to the activity to be executed by the link decoder
*/
static public function define_decode_rules() {
public static function define_decode_rules() {
$rules = array();

$rules[] = new restore_decode_rule('PDFANNOTATORVIEWBYID', '/mod/pdfannotator/view.php?id=$1', 'course_module');
Expand All @@ -85,7 +85,7 @@ static public function define_decode_rules() {
* pdfannotator logs. It must return one array
* of {@see restore_log_rule} objects
*/
static public function define_restore_log_rules() {
public static function define_restore_log_rules() {
$rules = array();

$rules[] = new restore_log_rule('pdfannotator', 'add', 'view.php?id={course_module}', '{pdfannotator}');
Expand All @@ -105,7 +105,7 @@ static public function define_restore_log_rules() {
* by the restore final task, but are defined here at
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
static public function define_restore_log_rules_for_course() {
public static function define_restore_log_rules_for_course() {
$rules = array();

$rules[] = new restore_log_rule('pdfannotator', 'view all', 'index.php?id={course}', null);
Expand Down
2 changes: 1 addition & 1 deletion classes/event/report_added.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ public function get_description() {
public function get_url() {
return new \moodle_url('/mod/pdfannotator/view.php', array('id' => $this->other['cmid'], 'action' => 'overview'));
}
}
}
4 changes: 2 additions & 2 deletions classes/output/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
namespace mod_pdfannotator\output;
use moodle_url;

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

/**
* Renderable for comments.
*
Expand All @@ -25,8 +27,6 @@
* @author Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();

class comment implements \renderable, \templatable {

private $comments = [];
Expand Down
2 changes: 1 addition & 1 deletion classes/output/printview.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ public function export_for_template(\renderer_base $output) {
return $data;
}

}
}
2 changes: 1 addition & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,4 @@ public static function empty_or_delete_comment($comment) {
}
}

}
}
6 changes: 3 additions & 3 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README.md)
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand All @@ -36,6 +36,6 @@


/**
* Prefix needed for encode64 imaged
* Prefix needed for encode64 images
*/
define('IMAGE_PREFIX', 'data:image/png;base64,');
define('IMAGE_PREFIX', 'data:image/png;base64,');
4 changes: 2 additions & 2 deletions controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README.md)
* @author Anna Heynkes, Friederike Schwager
* @author Anna Heynkes, Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down Expand Up @@ -570,4 +570,4 @@
$mform->display();
}
return;
}
}
2 changes: 1 addition & 1 deletion db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();
defined('MOODLE_INTERNAL') || die();
2 changes: 1 addition & 1 deletion db/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
'capability' => 'mod/pdfannotator:getforwardedquestions', // Teacher capability.
)

);
);
85 changes: 0 additions & 85 deletions forward_form.php
Original file line number Diff line number Diff line change
@@ -1,88 +1,3 @@
<<<<<<< HEAD
<?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/>.
/**
* @package mod_pdfannotator
* @copyright 2019 RWTH Aachen (see README.md)
* @author Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
*/
defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir . '/formslib.php');

/**
* Description of reportform
*
* @author Admin
*/
class pdfannotator_forward_form extends moodleform {

public function definition() {
global $CFG;

$mform = $this->_form; // Don't forget the underscore!
// Pass contextual parameters to the form (via set_data() in controller.php)
// Course module id.
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
// Course id.
$mform->addElement('hidden', 'course');
$mform->setType('course', PARAM_INT);
// Pdf id.
$mform->addElement('hidden', 'pdfannotatorid');
$mform->setType('pdfannotatorid', PARAM_INT);
// Pdfname.
$mform->addElement('hidden', 'pdfname');
$mform->setType('pdfname', PARAM_TEXT);
// Comment id.
$mform->addElement('hidden', 'commentid');
$mform->setType('commentid', PARAM_INT);
// Action = 'forwardquestion'.
$mform->addElement('hidden', 'action');
$mform->setType('action', PARAM_ALPHA);

// Display question.
$comment = $this->_customdata['comment'];
$mform->addElement('static', 'description', get_string('question', 'pdfannotator'), $comment->content);

// Select recipients.
$recipients = $this->_customdata['recipients'];

// 'selectgroups' instead of 'select' because the required-rule didn't work properly with a multi-select.
$select = $mform->addElement('selectgroups', 'recipients', get_string('recipient', 'pdfannotator'));
$select->addOptGroup('', $recipients);
$select->setMultiple(true);
$mform->addHelpButton('recipients', 'recipient', 'pdfannotator');
$mform->addRule('recipients', get_string('recipientrequired', 'pdfannotator'), 'required', null, 'client');

// Textarea for message to the recipient.
$mform->addElement('textarea', 'message', get_string('messageforwardform', 'pdfannotator'), 'wrap="virtual" rows="5" cols="109"');

// Add submit and cancel buttons.
$this->add_action_buttons($cancel = true, get_string('send', 'pdfannotator'));
}

public function display() {
$this->_form->display();
}

}
=======
<?php
// This file is part of Moodle - http://moodle.org/
//
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@

echo html_writer::table($table);

echo $OUTPUT->footer();
echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion lang/en/pdfannotator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README.md)
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
*/
Expand Down
22 changes: 14 additions & 8 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README.md)
* @author Ahmad Obeid, Rabea de Groot, Anna Heynkes
* @author Ahmad Obeid, Rabea de Groot, Anna Heynkes
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
Expand All @@ -28,12 +28,18 @@
*/
function pdfannotator_supports($feature) {
switch($feature) {
case FEATURE_GROUPS: return true;
case FEATURE_GROUPINGS: return true;
case FEATURE_MOD_INTRO: return true;
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
case FEATURE_BACKUP_MOODLE2: return true;
case FEATURE_SHOW_DESCRIPTION: return true;
case FEATURE_GROUPS:
return true;
case FEATURE_GROUPINGS:
return true;
case FEATURE_MOD_INTRO:
return true;
case FEATURE_COMPLETION_TRACKS_VIEWS:
return true;
case FEATURE_BACKUP_MOODLE2:
return true;
case FEATURE_SHOW_DESCRIPTION:
return true;

default:
return null;
Expand Down Expand Up @@ -608,7 +614,7 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart,
$printposts = array();
$context = context_course::instance($courseid);
foreach ($posts as $post) {
if(!pdfannotator_can_see_comment($post, $context)) {
if (!pdfannotator_can_see_comment($post, $context)) {
continue;
}
$printposts[] = $post;
Expand Down
4 changes: 2 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README)
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down Expand Up @@ -1805,4 +1805,4 @@ function pdfannotator_count_answers($annotationid, $context) {
$count++;
}
return $count;
}
}
Loading

0 comments on commit c1000c1

Please sign in to comment.