Skip to content

Commit b98a9de

Browse files
committed
comment added for marks setting in discussion.php
1 parent d2d9d2c commit b98a9de

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

discussion.php

+4
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@
142142

143143
// Start the side-output.
144144
echo $OUTPUT->header();
145+
146+
// Print a text, if multiple marks are allowed.
147+
moodleoverflow_print_multiplemarks_comment($modulecontext, $post);
148+
145149
echo $OUTPUT->heading(format_string($discussion->name), 1, 'discussionname');
146150

147151
// Guests and users can not subscribe to a discussion.

lang/en/moodleoverflow.php

+3
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@
328328
$string['attachment_help'] = 'You can optionally attach one or more files to a forum post. If you attach an image, it will be displayed after the message.';
329329
$string['allowmultiplemarks'] = 'Multiple marks?';
330330
$string['allowmultiplemarks_help'] = 'A post can be marked as helpful or solved. Within a discussion, only one post can be marked as helpful/solved. Click the checkbox to mark multiple posts as helpful/solved.';
331+
$string['multiplemarkscommentteacherownpost'] = 'Multiple marks are enabled, several posts can be marked as helpful or solved';
332+
$string['multiplemarkscommentstudentownpost'] = 'Multiple marks are enabled, you can mark several posts as helpful';
333+
$string['multiplemarkscommentteacher'] = 'Multiple marks are enabled, several posts can be marked as solved';
331334

332335
// Templates.
333336
$string['reputation'] = 'Reputation';

locallib.php

+30-1
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,35 @@ function moodleoverflow_user_can_post($modulecontext, $posttoreplyto, $considerr
876876
return !$considerreviewstatus || $posttoreplyto->reviewed == 1;
877877
}
878878

879+
/**
880+
* Prints a text, if multiple marks are allowed.
881+
*
882+
* @param stdClass $context The moodleoverflow context.
883+
* @param stdClass $post The post object.
884+
*/
885+
function moodleoverflow_print_multiplemarks_comment($context, $post) {
886+
global $USER;
887+
888+
// Check if the current user is the starter of the discussion.
889+
$ownpost = (isloggedin() && ($USER->id == $post->userid));
890+
891+
// Check if the current user can mark posts as solved.
892+
$canmarksolved = (has_capability('mod/moodleoverflow:marksolved', $context));
893+
$comment = '';
894+
895+
if ($ownpost) {
896+
if ($canmarksolved) {
897+
$comment = get_string('multiplemarkscommentteacherownpost', 'moodleoverflow');
898+
} else {
899+
$comment = get_string('multiplemarkscommentstudentownpost', 'moodleoverflow');
900+
}
901+
}
902+
else if ($canmarksolved) {
903+
$comment = get_string('multiplemarkscommentteacher', 'moodleoverflow');
904+
}
905+
$comment = $comment . '<br>' . '<br>';
906+
echo $comment;
907+
}
879908
/**
880909
* Prints a moodleoverflow discussion.
881910
*
@@ -888,7 +917,7 @@ function moodleoverflow_user_can_post($modulecontext, $posttoreplyto, $considerr
888917
function moodleoverflow_print_discussion($course, $cm, $moodleoverflow, $discussion, $post) {
889918
global $USER;
890919

891-
// Check if the current is the starter of the discussion.
920+
// Check if the current user is the starter of the discussion.
892921
$ownpost = (isloggedin() && ($USER->id == $post->userid));
893922

894923
// Fetch the modulecontext.

0 commit comments

Comments
 (0)