Skip to content

Resolved Code Checker Errors. #50

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

Open
wants to merge 4 commits into
base: MOODLE_401_STABLE
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
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Open Forum Activity
Open forums enhance Moodle Forums by providing teachers and students with quick,
simple views into the forums and their discussions. Allowing users to sort and search
discussions easily and in multiple layouts is key to Advanced Forums increased usability.
Read tracking is a feature in Advanced forums that highlights unread posts,
making it even easier to manage a forum. This saves the student time in viewing and
responding to posts, and saves the teacher time in finding the posts that are most
relevant to the class. Teachers are empowered to create anonymous interactions with

Open forums enhance Moodle Forums by providing teachers and students with quick,
simple views into the forums and their discussions. Allowing users to sort and search
discussions easily and in multiple layouts is key to Advanced Forums increased usability.
Read tracking is a feature in Advanced forums that highlights unread posts,
making it even easier to manage a forum. This saves the student time in viewing and
responding to posts, and saves the teacher time in finding the posts that are most
relevant to the class. Teachers are empowered to create anonymous interactions with
students while still being able to provide accurate grading with advanced grading methods.

![local_hsuforum](https://moodle.org/pluginfile.php/50/local_plugins/plugin_description/399/recent%20posts.png)
Expand All @@ -16,11 +17,33 @@ schools and organizations by supporting the software that educators use to manag
learners in virtual classrooms.

## Installation

Extract the contents of the plugin into _/wwwroot/mod_ then visit `admin/upgrade.php` or use the CLI script to upgrade your site.

For more information about the configuration and usage, please see http://docs.moodle.org/dev/Advanced_Forum

## Flag

### The `hsuforum_digestmailtime` flag.

### The `hsuforum_allowforcedreadtracking` flag.

### The `hsuforum_enabletimedposts` flag.

### The `hsuforum_digestmailtimelast` flag.

### The `mod_hsuforum_grading_interface` flag.

### The `hsuforum_replytouser` flag.

### The `hsuforum_subscription` flag.

## Task

### `cron_task` scheduled task .

## License

Copyright (c) 2021 Open LMS (https://www.openlms.net)

This program is free software: you can redistribute it and/or modify it under
Expand All @@ -33,4 +56,4 @@ 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
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
1 change: 0 additions & 1 deletion backup/moodle1/lib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
3 changes: 1 addition & 2 deletions backup/moodle2/backup_hsuforum_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -70,7 +69,7 @@ public function get_comment_file_annotation_info() {
static public function encode_content_links($content) {
global $CFG;

$base = preg_quote($CFG->wwwroot,"/");
$base = preg_quote($CFG->wwwroot,"/",);

// Link to the list of forums
$search="/(".$base."\/mod\/hsuforum\/index.php\?id\=)([0-9]+)/";
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/backup_hsuforum_settingslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/backup_hsuforum_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/restore_hsuforum_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
3 changes: 1 addition & 2 deletions backup/moodle2/restore_hsuforum_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -275,7 +274,7 @@ protected function after_restore() {
$sd->reveal = 0;
$sdid = hsuforum_add_discussion($sd, null, null, $this->task->get_userid());
// Mark the post as mailed
$DB->set_field ('hsuforum_posts','mailed', '1', array('discussion' => $sdid));
$DB->set_field ('hsuforum_posts','mailed', '1', array('discussion' => $sdid,));
// Copy all the files from mod_foum/intro to mod_hsuforum/post
$fs = get_file_storage();
$files = $fs->get_area_files($this->task->get_contextid(), 'mod_hsuforum', 'intro');
Expand Down
8 changes: 4 additions & 4 deletions classes/controller/edit_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function reply_action() {
'message' => $message,
'messageformat' => $messageformat,
'reveal' => $reveal,
'mailnow' => $mailnow
'mailnow' => $mailnow,
);
if (!empty($subject)) {
$data['subject'] = $subject;
Expand Down Expand Up @@ -175,7 +175,7 @@ public function add_discussion_action() {
'reveal' => $reveal,
'timestart' => $timestart,
'timeend' => $timeend,
'mailnow' => $mailnow
'mailnow' => $mailnow,
);
return $this->discussionservice->handle_add_discussion($course, $cm, $forum, $context, $options, $posttomygroups);
} catch (\Exception $e) {
Expand Down Expand Up @@ -238,7 +238,7 @@ public function update_post_action() {
'reveal' => $reveal,
'privatereply' => $privatereply,
'timestart' => $timestart,
'timeend' => $timeend
'timeend' => $timeend,
));
} catch (\Exception $e) {
return new json_response($e);
Expand Down Expand Up @@ -281,7 +281,7 @@ public function edit_post_form_action() {
'isdiscussion' => true,
'timestart' => $discussion->timestart,
'timeend' => $discussion->timeend,
'offset' => $offset
'offset' => $offset,
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion classes/controller/kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function generate_response($callback) {
$buffer = trim(ob_get_contents());
ob_end_clean();

if (!empty($response) and !empty($buffer)) {
if (!empty($response) && !empty($buffer)) {
throw new \coding_exception('Mixed return output and buffer output', "Buffer: $buffer");
} else if (!empty($buffer)) {
$response = $buffer;
Expand Down
4 changes: 2 additions & 2 deletions classes/message/inbound/reply_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function process_message(\stdClass $record, \stdClass $messagedata) {
} else {
$groupmode = $course->groupmode;
}
if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $modcontext)) {
if ($groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $modcontext)) {
if ($discussion->groupid == -1) {
$canpost = false;
} else {
Expand Down Expand Up @@ -253,7 +253,7 @@ public function process_message(\stdClass $record, \stdClass $messagedata) {
'discussionid' => $discussion->id,
'forumid' => $forum->id,
'forumtype' => $forum->type,
)
),
);
$event = \mod_hsuforum\event\post_created::create($params);
$event->add_record_snapshot('hsuforum_posts', $addpost);
Expand Down
4 changes: 2 additions & 2 deletions classes/output/big_search_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct($course) {
$this->forumoptions = array_map(function($option) use ($forumoptions) {
return [
'value' => $option,
'name' => $forumoptions[$option]
'name' => $forumoptions[$option],
];
}, array_keys($forumoptions));
}
Expand Down Expand Up @@ -200,7 +200,7 @@ public function export_for_template(renderer_base $output) {
foreach ($tags as $tag) {
$data->tagoptions[] = ['value' => $tag->rawname,
'text' => $tag->fieldname,
'selected' => in_array($tag->rawname, $this->tags)
'selected' => in_array($tag->rawname, $this->tags),
];
}

Expand Down
9 changes: 4 additions & 5 deletions classes/post_form.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -52,7 +51,7 @@ public static function attachment_options($forum) {
'maxbytes' => $maxbytes,
'maxfiles' => $forum->maxattachments,
'accepted_types' => '*',
'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK
'return_types' => FILE_INTERNAL | FILE_CONTROLLED_LINK,
);
}

Expand All @@ -72,7 +71,7 @@ public static function editor_options(context_module $context, $postid) {
'maxbytes' => $maxbytes,
'trusttext'=> true,
'return_types'=> FILE_INTERNAL | FILE_EXTERNAL,
'subdirs' => file_area_contains_subdirs($context, 'mod_hsuforum', 'post', $postid)
'subdirs' => file_area_contains_subdirs($context, 'mod_hsuforum', 'post', $postid),
);
}

Expand Down Expand Up @@ -149,7 +148,7 @@ function definition() {
$mform->addHelpButton('pinned', 'discussionpinned', 'hsuforum');
}

if (!empty($forum->anonymous) and $post->userid == $USER->id and has_capability('mod/hsuforum:revealpost', $modcontext)) {
if (!empty($forum->anonymous) && $post->userid == $USER->id && has_capability('mod/hsuforum:revealpost', $modcontext)) {
$mform->addElement('advcheckbox', 'reveal', get_string('reveal', 'hsuforum'));
$mform->addHelpButton('reveal', 'reveal', 'hsuforum');
}
Expand All @@ -158,7 +157,7 @@ function definition() {
$mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'hsuforum'));
}

if (!empty($forum->allowprivatereplies) and !empty($post->parent) and has_capability('mod/hsuforum:allowprivate', $modcontext)) {
if (!empty($forum->allowprivatereplies) && !empty($post->parent) && has_capability('mod/hsuforum:allowprivate', $modcontext)) {
if ($post->userid != $USER->id) {
$mform->addElement('hidden', 'privatereply', 0);
$mform->setType('privatereply', PARAM_INT);
Expand Down
4 changes: 2 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static function get_metadata(collection $items) : collection {
'userid' => 'privacy:metadata:hsuforum_queue:userid',
'discussionid' => 'privacy:metadata:hsuforum_queue:discussionid',
'postid' => 'privacy:metadata:hsuforum_queue:postid',
'timemodified' => 'privacy:metadata:hsuforum_queue:timemodified'
'timemodified' => 'privacy:metadata:hsuforum_queue:timemodified',
], 'privacy:metadata:hsuforum_queue');

// The 'hsuforum_read' table stores data about which forum posts have been read by each user.
Expand Down Expand Up @@ -561,7 +561,7 @@ protected static function export_discussion_data(int $userid, array $mappings) {
'pinned' => transform::yesno((bool)$discussion->pinned),
'timemodified' => transform::datetime($discussion->timemodified),
'usermodified' => transform::datetime($discussion->usermodified),
'creator_was_you' => transform::yesno($discussion->userid == $userid)
'creator_was_you' => transform::yesno($discussion->userid == $userid),
];

$discussionarea = static::get_discussion_area($discussion);
Expand Down
2 changes: 1 addition & 1 deletion classes/renderables/advanced_editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function get_data($draftid = 0){
'editor' => $editor,
'options' => $options,
'fpoptions' => $fpoptions,
'draftitemid' => $draftitemid
'draftitemid' => $draftitemid,
];
}
}
4 changes: 2 additions & 2 deletions classes/search/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function uses_file_indexing() {
public function get_search_fileareas() {
$fileareas = array(
'attachment',
'post'
'post',
);

return $fileareas;
Expand Down Expand Up @@ -315,7 +315,7 @@ protected function get_discussion($discussionid) {
protected function get_contexts_to_reindex_extra_sql() {
return [
'JOIN {hsuforum_discussions} fd ON fd.course = cm.course AND fd.forum = cm.instance',
'MAX(fd.timemodified) DESC'
'MAX(fd.timemodified) DESC',
];
}

Expand Down
2 changes: 1 addition & 1 deletion classes/service/discussion_service.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function trigger_discussion_created($course, \context_module $context, $c
'objectid' => $discussion->id,
'other' => array(
'forumid' => $forum->id,
)
),
);
$event = discussion_created::create($params);
$event->add_record_snapshot('hsuforum_discussions', $discussion);
Expand Down
8 changes: 4 additions & 4 deletions classes/service/form_service.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ protected function file_prepare_draft_area(&$draftitemid, $contextid, $component
$draftitemid = file_get_unused_draft_itemid();
}
$file_record = array('contextid'=>$usercontext->id, 'component'=>'user', 'filearea'=>'draft', 'itemid'=>$draftitemid);
if (!is_null($itemid) and $files = $fs->get_area_files($contextid, $component, $filearea, $itemid)) {
if (!is_null($itemid) && $files = $fs->get_area_files($contextid, $component, $filearea, $itemid)) {
foreach ($files as $file) {
if ($file->is_directory() and $file->get_filepath() === '/') {
if ($file->is_directory() && $file->get_filepath() === '/') {
// we need a way to mark the age of each draft area,
// by not copying the root dir we force it to be created automatically with current timestamp
continue;
}
if (!$options['subdirs'] and ($file->is_directory() or $file->get_filepath() !== '/')) {
if (!$options['subdirs'] && ($file->is_directory() or $file->get_filepath() !== '/')) {
continue;
}

Expand Down Expand Up @@ -215,7 +215,7 @@ public function edit_discussion_form($cm, $discussion, $post, $draftid) {
'groupid' => ($discussion->groupid == -1) ? 0 : $discussion->groupid,
'itemid' => $itemid,
'timestart' => $discussion->timestart,
'timeend' => $discussion->timeend
'timeend' => $discussion->timeend,
));
}
}
6 changes: 3 additions & 3 deletions classes/service/post_service.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function require_can_edit_post($forum, \context_module $context, $discuss
global $CFG, $USER;

if (!($forum->type == 'news' && !$post->parent && $discussion->timestart > time())) {
if (((time() - $post->created) > $CFG->maxeditingtime) and
if (((time() - $post->created) > $CFG->maxeditingtime) &&
!has_capability('mod/hsuforum:editanypost', $context)
) {
throw new \moodle_exception('maxtimehaspassed', 'hsuforum', '', format_time($CFG->maxeditingtime));
Expand Down Expand Up @@ -374,7 +374,7 @@ public function trigger_post_created($course, \context_module $context, $cm, $fo
'discussionid' => $discussion->id,
'forumid' => $forum->id,
'forumtype' => $forum->type,
)
),
);
$event = post_created::create($params);
$event->add_record_snapshot('hsuforum_posts', $post);
Expand All @@ -400,7 +400,7 @@ public function trigger_post_updated(\context_module $context, $forum, $discussi
'discussionid' => $discussion->id,
'forumid' => $forum->id,
'forumtype' => $forum->type,
)
),
);

if ($post->userid !== $USER->id) {
Expand Down
Loading