Merge branch 'MDL-75351' of https://github.com/timhunt/moodle
This commit is contained in:
+4
-4
@@ -3,9 +3,9 @@ define("qbank_comment/comment",["exports","core/fragment","core/str","core/modal
|
||||
* 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
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_fragment=_interopRequireDefault(_fragment),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_modal_events=_interopRequireDefault(_modal_events),_modal_factory=_interopRequireDefault(_modal_factory),_notification=_interopRequireDefault(_notification);_exports.init=questionSelector=>{let target=document.querySelector(questionSelector),questionId=target.getAttribute("data-questionid"),courseID=target.getAttribute("data-courseid");target.addEventListener("click",(()=>{((questionId,courseID,contextId)=>{let args={questionid:questionId,courseid:courseID};_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:Str.get_string("commentheader","qbank_comment"),body:_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args),large:!0}).then((modal=>{let root=modal.getRoot();return root.on(_modal_events.default.bodyRendered,(function(){document.querySelectorAll("div.comment-area a")[0].style.display="none"})),root.on("change","#question_comment_version_dropdown",(function(e){args.questionid=e.target.value,modal.setBody(_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args))})),Str.get_strings([{key:"addcomment",component:"qbank_comment"},{key:"close",component:"qbank_comment"}]).then((strings=>{modal.setButtonText("save",strings[0]),modal.setButtonText("cancel",strings[1])})).fail(_notification.default.exception),root.on(_modal_events.default.cancel,(function(){location.reload(),modal.hide()})),root.on(_modal_events.default.save,(function(e){e.preventDefault();const submitlink=document.querySelectorAll("div.comment-area a")[0],textarea=document.querySelectorAll("div.comment-area textarea")[0];textarea.value!=textarea.getAttribute("aria-label")&&""!=textarea.value&&submitlink.click()})),root.on("click",'button[data-action="hide"]',(()=>{location.reload(),modal.hide()})),modal.show(),modal})).fail(_notification.default.exception)})(questionId,courseID,1)}))}}));
|
||||
* @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
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_fragment=_interopRequireDefault(_fragment),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_modal_events=_interopRequireDefault(_modal_events),_modal_factory=_interopRequireDefault(_modal_factory),_notification=_interopRequireDefault(_notification);_exports.init=questionSelector=>{const target=document.querySelector(questionSelector);target.addEventListener("click",(()=>{((questionId,courseID,contextId)=>{let args={questionid:questionId,courseid:courseID};_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:Str.get_string("commentheader","qbank_comment"),body:_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args),large:!0}).then((modal=>{let root=modal.getRoot();return root.on(_modal_events.default.bodyRendered,(function(){document.querySelectorAll("div.comment-area a")[0].style.display="none"})),root.on("change","#question_comment_version_dropdown",(function(e){args.questionid=e.target.value,modal.setBody(_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args))})),Str.get_strings([{key:"addcomment",component:"qbank_comment"},{key:"close",component:"qbank_comment"}]).then((strings=>{modal.setButtonText("save",strings[0]),modal.setButtonText("cancel",strings[1])})).fail(_notification.default.exception),root.on(_modal_events.default.cancel,(function(){location.reload(),modal.hide()})),root.on(_modal_events.default.save,(function(e){e.preventDefault();const submitlink=document.querySelectorAll("div.comment-area a")[0],textarea=document.querySelectorAll("div.comment-area textarea")[0];textarea.value!=textarea.getAttribute("aria-label")&&""!=textarea.value&&submitlink.click()})),root.on("click",'button[data-action="hide"]',(()=>{location.reload(),modal.hide()})),modal.show(),modal})).fail(_notification.default.exception)})(target.dataset.questionid,target.dataset.courseid,target.dataset.contextid)}))}}));
|
||||
|
||||
//# sourceMappingURL=comment.min.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -17,9 +17,9 @@
|
||||
* Column selector js.
|
||||
*
|
||||
* @module qbank_comment/comment
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
||||
* @author Safat Shahin <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import Fragment from 'core/fragment';
|
||||
@@ -104,12 +104,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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -55,11 +55,12 @@ class comment_count_column extends column_base {
|
||||
*/
|
||||
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 = [];
|
||||
@@ -72,6 +73,7 @@ class comment_count_column extends column_base {
|
||||
'data-target' => $target,
|
||||
'data-questionid' => $question->id,
|
||||
'data-courseid' => $this->qbank->course->id,
|
||||
'data-contextid' => $syscontext->id,
|
||||
];
|
||||
}
|
||||
echo \html_writer::tag('a', $commentcount, $attributes);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user