FLAT_NEWEST_FIRST: -1
};
+ /**
+ * Moodle formats taken from the FORMAT_* constants declared in lib/weblib.php.
+ * @type {Object}
+ */
+ var CONTENT_FORMATS = {
+ MOODLE: 0
+ };
/**
* Show the loading icon for the submit button.
*
var allButtons = submitButton.parent().find(Selectors.post.inpageReplyButton);
var form = submitButton.parents(Selectors.post.inpageReplyForm).get(0);
var message = form.elements.post.value.trim();
+ // For now, we consider the inline reply post written using the FORMAT_MOODLE (because a textarea is displayed).
+ // In the future, other formats should be supported, letting users to use their preferred editor and format.
+ var messageformat = CONTENT_FORMATS.MOODLE;
+ // The message post will be converted from messageformat to FORMAT_HTML.
+ var tohtml = true;
var postid = form.elements.reply.value;
var subject = form.elements.subject.value;
var currentRoot = submitButton.parents(Selectors.post.forumContent);
showSubmitButtonLoadingIcon(submitButton);
allButtons.prop('disabled', true);
- Repository.addDiscussionPost(postid, subject, message, isprivatereply)
+ Repository.addDiscussionPost(postid, subject, message, messageformat, isprivatereply, tohtml)
.then(function(context) {
var message = context.messages.reduce(function(carry, message) {
if (message.type == 'success') {
return {
init: function(root) {
registerEventListeners(root);
- }
+ },
+ CONTENT_FORMATS: CONTENT_FORMATS
};
});
return Ajax.call([request])[0];
};
- var addDiscussionPost = function(postid, subject, message, isprivatereply) {
+ var addDiscussionPost = function(postid, subject, message, messageformat, isprivatereply, tohtml) {
var request = {
methodname: 'mod_forum_add_discussion_post',
args: {
postid: postid,
message: message,
+ messageformat: messageformat,
subject: subject,
options: [{
name: "private",
value: isprivatereply,
+ }, {
+ name: "tohtml",
+ value: tohtml,
}]
}
};