Skip to content

Commit

Permalink
Merge branch 'MDL-75351_400' of https://github.com/timhunt/moodle int…
Browse files Browse the repository at this point in the history
…o MOODLE_400_STABLE
  • Loading branch information
junpataleta committed Oct 4, 2022
2 parents 3eba3dc + 9cd4814 commit 4d9a42c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions question/bank/comment/amd/build/comment.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion question/bank/comment/amd/build/comment.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions question/bank/comment/amd/src/comment.js
Expand Up @@ -17,9 +17,9 @@
* Column selector js.
*
* @module qbank_comment/comment
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

import Fragment from 'core/fragment';
Expand Down Expand Up @@ -99,12 +99,9 @@ const commentEvent = (questionId, courseID, contextId) => {
* @param {string} questionSelector the question comment identifier.
*/
export const init = (questionSelector) => {
let target = document.querySelector(questionSelector);
let contextId = 1;
let questionId = target.getAttribute('data-questionid'),
courseID = target.getAttribute('data-courseid');
const target = document.querySelector(questionSelector);
target.addEventListener('click', () => {
// Call for the event listener to listed for clicks in any comment count row.
commentEvent(questionId, courseID, contextId);
commentEvent(target.dataset.questionid, target.dataset.courseid, target.dataset.contextid);
});
};
4 changes: 3 additions & 1 deletion question/bank/comment/classes/comment_count_column.php
Expand Up @@ -55,11 +55,12 @@ public function get_title(): string {
*/
protected function display_content($question, $rowclasses): void {
global $DB, $PAGE;
$syscontext = \context_system::instance();
$args = [
'component' => 'qbank_comment',
'commentarea' => 'question',
'itemid' => $question->id,
'contextid' => 1
'contextid' => $syscontext->id,
];
$commentcount = $DB->count_records('comments', $args);
$attributes = [];
Expand All @@ -72,6 +73,7 @@ protected function display_content($question, $rowclasses): void {
'data-target' => $target,
'data-questionid' => $question->id,
'data-courseid' => $this->qbank->course->id,
'data-contextid' => $syscontext->id,
];
}
echo \html_writer::tag('a', $commentcount, $attributes);
Expand Down
2 changes: 1 addition & 1 deletion question/bank/comment/lib.php
Expand Up @@ -84,7 +84,7 @@ function qbank_comment_preview_display($question, $courseid): string {
&& core\plugininfo\qbank::is_plugin_enabled('qbank_comment')) {
\comment::init($PAGE);
$args = new \stdClass;
$args->contextid = 1; // Static data to bypass comment sql as context is not needed.
$args->contextid = context_system::instance()->id; // Static data to bypass comment sql as context is not needed.
$args->courseid = $courseid;
$args->area = 'question';
$args->itemid = $question->id;
Expand Down

0 comments on commit 4d9a42c

Please sign in to comment.