Skip to content

Commit bfe5038

Browse files
Merge pull request #60 from lucaboesch/codingstyle
Coding style
2 parents d1afe6d + c1000c1 commit bfe5038

36 files changed

+527
-375
lines changed

action.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @package mod_pdfannotator
2929
* @copyright 2018 RWTH Aachen (see README.md)
30-
* @authors Rabea de Groot, Anna Heynkes, Friederike Schwager
30+
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
3131
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3232
*/
3333

@@ -151,7 +151,8 @@
151151
$data['height'] = $annotation['height'];
152152
break;
153153
case 'drawing':
154-
$studentdrawingsallowed = $DB->get_field('pdfannotator', 'use_studentdrawing', ['id' => $documentid], $strictness = MUST_EXIST);
154+
$studentdrawingsallowed = $DB->get_field('pdfannotator', 'use_studentdrawing', ['id' => $documentid],
155+
$strictness = MUST_EXIST);
155156
$alwaysdrawingallowed = has_capability('mod/pdfannotator:usedrawing', $context);
156157
if ($studentdrawingsallowed != 1 && !$alwaysdrawingallowed) {
157158
echo json_encode(['status' => 'error', 'reason' => get_string('studentdrawingforbidden', 'pdfannotator')]);
@@ -174,7 +175,8 @@
174175
$data['rectangles'] = $annotation['rectangles'];
175176
break;
176177
case 'textbox':
177-
$studenttextboxesallowed = $DB->get_field('pdfannotator', 'use_studenttextbox', array('id' => $documentid), $strictness = MUST_EXIST);
178+
$studenttextboxesallowed = $DB->get_field('pdfannotator', 'use_studenttextbox', array('id' => $documentid),
179+
$strictness = MUST_EXIST);
178180
$alwaystextboxallowed = has_capability('mod/pdfannotator:usetextbox', $context);
179181
if ($studenttextboxesallowed != 1 && !$alwaystextboxallowed) {
180182
echo json_encode(['status' => 'error', 'reason' => get_string('studenttextboxforbidden', 'pdfannotator')]);
@@ -386,8 +388,6 @@
386388

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

389-
// require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/comment.php');
390-
391391
$myrenderer = $PAGE->get_renderer('mod_pdfannotator');
392392
$templatable = new comment($comments, $cm, $context);
393393

@@ -453,7 +453,7 @@
453453

454454
$commentid = required_param('commentId', PARAM_INT);
455455
$content = required_param('content', PARAM_RAW);
456-
456+
457457
$data = pdfannotator_comment::update($commentid, $content, $editanypost);
458458
echo json_encode($data);
459459
}
@@ -497,7 +497,8 @@
497497
$thiscourse = $pdfannotator->course;
498498
$cmid = get_coursemodule_from_instance('pdfannotator', $thisannotator, $thiscourse, false, MUST_EXIST)->id;
499499

500-
$urlparams = array('action' => 'overviewanswers', 'id' => $cmid, 'page' => 0, 'itemsperpage' => $itemsperpage, 'answerfilter' => 0);
500+
$urlparams = array('action' => 'overviewanswers', 'id' => $cmid, 'page' => 0, 'itemsperpage' => $itemsperpage,
501+
'answerfilter' => 0);
501502
$url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams);
502503
redirect($url->out());
503504
return;
@@ -537,13 +538,14 @@
537538
}
538539

539540
if ($subscriptionid) {
540-
echo json_encode(['status' => 'success', 'annotationid' => $annotationid, 'subscriptionid' => $subscriptionid, 'annotatorid' => $annotatorid]);
541+
echo json_encode(['status' => 'success', 'annotationid' => $annotationid, 'subscriptionid' => $subscriptionid,
542+
'annotatorid' => $annotatorid]);
541543
} else {
542544
echo json_encode(['status' => 'error']);
543545
}
544546
}
545547

546-
/* * ****************************************** Mark a question as closed or an answer as correct ****************************************** */
548+
/* * ****************************************** Mark a question as closed or an answer as correct ******************************* */
547549

548550
if ($action === 'markSolved') {
549551
global $DB;

backup/moodle2/backup_pdfannotator_activity_task.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function define_my_steps() {
7575
* @param string $content some HTML text that eventually contains URLs to the activity instance scripts
7676
* @return string the content with the URLs encoded
7777
*/
78-
static public function encode_content_links($content) {
78+
public static function encode_content_links($content) {
7979

8080
global $CFG, $DB;
8181

backup/moodle2/backup_pdfannotator_stepslib.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,27 @@ protected function define_structure() {
5454

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

5960
$annotations = new backup_nested_element('annotations');
60-
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid', 'data', 'timecreated', 'timemodified', 'modifiedby'));
61+
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid',
62+
'data', 'timecreated', 'timemodified', 'modifiedby'));
6163

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

6567
$comments = new backup_nested_element('comments');
66-
$c = array('pdfannotatorid', 'userid', 'content', 'timecreated', 'timemodified', 'modifiedby', 'visibility', 'isquestion', 'isdeleted', 'ishidden', 'solved');
68+
$c = array('pdfannotatorid', 'userid', 'content', 'timecreated', 'timemodified', 'modifiedby', 'visibility',
69+
'isquestion', 'isdeleted', 'ishidden', 'solved');
6770
$comment = new backup_nested_element('comment', array('id'), $c);
6871

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

7275
$reports = new backup_nested_element('reports');
73-
$report = new backup_nested_element('report', array('id'), array('courseid', 'pdfannotatorid', 'message', 'userid', 'timecreated', 'seen'));
76+
$report = new backup_nested_element('report', array('id'), array('courseid', 'pdfannotatorid', 'message',
77+
'userid', 'timecreated', 'seen'));
7478

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

103108
// Add any subscriptions to this annotation.

backup/moodle2/restore_pdfannotator_activity_task.class.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function define_my_steps() {
5757
* Define the contents in the activity that must be
5858
* processed by the link decoder.
5959
*/
60-
static public function define_decode_contents() {
60+
public static function define_decode_contents() {
6161
$contents = array();
6262

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

7575
$rules[] = new restore_decode_rule('PDFANNOTATORVIEWBYID', '/mod/pdfannotator/view.php?id=$1', 'course_module');
@@ -81,11 +81,11 @@ static public function define_decode_rules() {
8181

8282
/**
8383
* Define the restore log rules that will be applied
84-
* by the {@link restore_logs_processor} when restoring
84+
* by the {@see restore_logs_processor} when restoring
8585
* pdfannotator logs. It must return one array
86-
* of {@link restore_log_rule} objects
86+
* of {@see restore_log_rule} objects
8787
*/
88-
static public function define_restore_log_rules() {
88+
public static function define_restore_log_rules() {
8989
$rules = array();
9090

9191
$rules[] = new restore_log_rule('pdfannotator', 'add', 'view.php?id={course_module}', '{pdfannotator}');
@@ -97,15 +97,15 @@ static public function define_restore_log_rules() {
9797

9898
/**
9999
* Define the restore log rules that will be applied
100-
* by the {@link restore_logs_processor} when restoring
100+
* by the {@see restore_logs_processor} when restoring
101101
* course logs. It must return one array
102-
* of {@link restore_log_rule} objects
102+
* of {@see restore_log_rule} objects
103103
*
104104
* Note this rules are applied when restoring course logs
105105
* by the restore final task, but are defined here at
106106
* activity level. All them are rules not linked to any module instance (cmid = 0)
107107
*/
108-
static public function define_restore_log_rules_for_course() {
108+
public static function define_restore_log_rules_for_course() {
109109
$rules = array();
110110

111111
$rules[] = new restore_log_rule('pdfannotator', 'view all', 'index.php?id={course}', null);

backup/moodle2/restore_pdfannotator_stepslib.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,21 @@ protected function define_structure() {
4545

4646
$userinfo = $this->get_setting_value('userinfo'); // Is 0 //TODO is not used.
4747

48-
$paths[] = new restore_path_element('pdfannotator', '/activity/pdfannotator');
48+
$paths[] = new restore_path_element('pdfannotator',
49+
'/activity/pdfannotator');
4950

50-
$paths[] = new restore_path_element('pdfannotator_annotation', '/activity/pdfannotator/annotations/annotation');
51+
$paths[] = new restore_path_element('pdfannotator_annotation',
52+
'/activity/pdfannotator/annotations/annotation');
5153

52-
$paths[] = new restore_path_element('pdfannotator_subscription', '/activity/pdfannotator/annotations/annotation/subscriptions/subscription');
53-
$paths[] = new restore_path_element('pdfannotator_comment', '/activity/pdfannotator/annotations/annotation/comments/comment');
54+
$paths[] = new restore_path_element('pdfannotator_subscription',
55+
'/activity/pdfannotator/annotations/annotation/subscriptions/subscription');
56+
$paths[] = new restore_path_element('pdfannotator_comment',
57+
'/activity/pdfannotator/annotations/annotation/comments/comment');
5458

55-
$paths[] = new restore_path_element('pdfannotator_vote', '/activity/pdfannotator/annotations/annotation/comments/comment/votes/vote');
56-
$paths[] = new restore_path_element('pdfannotator_report', '/activity/pdfannotator/annotations/annotation/comments/comment/reports/report');
59+
$paths[] = new restore_path_element('pdfannotator_vote',
60+
'/activity/pdfannotator/annotations/annotation/comments/comment/votes/vote');
61+
$paths[] = new restore_path_element('pdfannotator_report',
62+
'/activity/pdfannotator/annotations/annotation/comments/comment/reports/report');
5763

5864
// Return the paths wrapped into standard activity structure.
5965
return $this->prepare_activity_structure($paths);
@@ -143,8 +149,9 @@ protected function process_pdfannotator_report($data) {
143149
$data->commentid = $this->get_new_parentid('pdfannotator_comment');
144150
$data->userid = $this->get_mappingid('user', $data->userid);
145151

146-
// $data->timecreated = $this->apply_date_offset($data->timecreated);
147-
$data->pdfannotatorid = $this->get_mappingid('pdfannotator', $data->pdfannotatorid); // Params: 1. Object class as defined in structure, 2. attribute&/column name.
152+
// $data->timecreated = $this->apply_date_offset($data->timecreated);
153+
$data->pdfannotatorid = $this->get_mappingid('pdfannotator', $data->pdfannotatorid);
154+
// Params: 1. Object class as defined in structure, 2. attribute&/column name.
148155

149156
$newitemid = $DB->insert_record('pdfannotator_reports', $data);
150157
$this->set_mapping('pdfannotator_report', $oldid, $newitemid);

classes/event/report_added.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ public function get_description() {
5454
public function get_url() {
5555
return new \moodle_url('/mod/pdfannotator/view.php', array('id' => $this->other['cmid'], 'action' => 'overview'));
5656
}
57-
}
57+
}

classes/output/answermenu.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class answermenu implements \renderable, \templatable {
3737

3838
/**
3939
* Constructor of renderable for dropdown menu in answerstable.
40-
* @global type $CFG
4140
* @param int $annotationid Id of the annotation the answer belongs to
4241
* @param bool $issubscribed Is the user subscribed to the question?
4342
* @param int $cmid Course module id

0 commit comments

Comments
 (0)