MDL-49609 mod_lti: Fixes for problems found in testing
* Load contentitem_return doc before processing
* Also use new AMD modal instead of the YUI one.
* Remove conversion of text columns in union queries
- Since the value column in lti_types_config was changed to a
text type, there is no need to use $DB->sql_compare_text()
for the lti_types columns involved in the union queries in
lti_get_type_config().
This commit is contained in:
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/str","core/templates","mod_lti/form-field","core/yui"],function(a,b,c,d,e){var f,g={init:function(a,e){var g="";c.get_string("selectcontent","lti").then(function(b){g=b;var c={url:a,postData:e};return d.render("mod_lti/contentitem",c)}).then(function(a,c){f=new M.core.dialogue({modal:!0,headerContent:g,bodyContent:a,draggable:!0,width:"800px",height:"600px"}),f.show(),f.after("visibleChange",function(a){a.prevVal&&!a.newVal&&(this.destroy(),b.fetchNotifications())},f),d.runTemplateJS(c)}).fail(b.exception)}},h=[new e("name",e.TYPES.TEXT,(!1),""),new e("introeditor",e.TYPES.EDITOR,(!1),""),new e("toolurl",e.TYPES.TEXT,(!0),""),new e("securetoolurl",e.TYPES.TEXT,(!0),""),new e("instructorchoiceacceptgrades",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendname",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendemailaddr",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorcustomparameters",e.TYPES.TEXT,(!0),""),new e("icon",e.TYPES.TEXT,(!0),""),new e("secureicon",e.TYPES.TEXT,(!0),""),new e("launchcontainer",e.TYPES.SELECT,(!0),0)];return window.processContentItemReturnData=function(b){f&&f.hide();var c;for(c in h){var d=h[c],e=null;"undefined"!==a.type(b[d.name])&&(e=b[d.name]),d.setFieldValue(e)}},g});
|
||||
define(["jquery","core/notification","core/str","core/templates","mod_lti/form-field","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){var h,i={init:function(a,e){var i="";c.get_string("selectcontent","lti").then(function(c){i=c;var j={url:a,postData:e},k=d.render("mod_lti/contentitem",j);h?(h.setBody(k),h.show()):f.create({title:i,body:k,large:!0}).done(function(a){h=a,h.show(),a.getRoot().on(g.hidden,function(){a.setBody(""),b.fetchNotifications()})})})}},j=[new e("name",e.TYPES.TEXT,(!1),""),new e("introeditor",e.TYPES.EDITOR,(!1),""),new e("toolurl",e.TYPES.TEXT,(!0),""),new e("securetoolurl",e.TYPES.TEXT,(!0),""),new e("instructorchoiceacceptgrades",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendname",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendemailaddr",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorcustomparameters",e.TYPES.TEXT,(!0),""),new e("icon",e.TYPES.TEXT,(!0),""),new e("secureicon",e.TYPES.TEXT,(!0),""),new e("launchcontainer",e.TYPES.SELECT,(!0),0)];return window.processContentItemReturnData=function(b){h&&h.hide();var c;for(c in j){var d=j[c],e=null;"undefined"!==a.type(b[d.name])&&(e=b[d.name]),d.setFieldValue(e)}},i});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define([],function(){return{init:function(a){window!=top&&parent.processContentItemReturnData(a)}}});
|
||||
define(["jquery"],function(a){return{init:function(b){a(window).ready(function(){window!=top&&parent.processContentItemReturnData(b)})}}});
|
||||
@@ -26,8 +26,17 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since 3.2
|
||||
*/
|
||||
define(['jquery', 'core/notification', 'core/str', 'core/templates', 'mod_lti/form-field', 'core/yui'],
|
||||
function($, notification, str, templates, FormField) {
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'core/notification',
|
||||
'core/str',
|
||||
'core/templates',
|
||||
'mod_lti/form-field',
|
||||
'core/modal_factory',
|
||||
'core/modal_events'
|
||||
],
|
||||
function($, notification, str, templates, FormField, ModalFactory, ModalEvents) {
|
||||
var dialogue;
|
||||
var contentItem = {
|
||||
/**
|
||||
@@ -44,35 +53,35 @@ define(['jquery', 'core/notification', 'core/str', 'core/templates', 'mod_lti/fo
|
||||
url: url,
|
||||
postData: postData
|
||||
};
|
||||
return templates.render('mod_lti/contentitem', context);
|
||||
|
||||
}).then(function(html, js) {
|
||||
// Set dialog's body content.
|
||||
dialogue = new M.core.dialogue({
|
||||
modal: true,
|
||||
headerContent: dialogueTitle,
|
||||
bodyContent: html,
|
||||
draggable: true,
|
||||
width: '800px',
|
||||
height: '600px'
|
||||
});
|
||||
var body = templates.render('mod_lti/contentitem', context);
|
||||
if (dialogue) {
|
||||
// Set dialogue body.
|
||||
dialogue.setBody(body);
|
||||
// Display the dialogue.
|
||||
dialogue.show();
|
||||
} else {
|
||||
ModalFactory.create({
|
||||
title: dialogueTitle,
|
||||
body: body,
|
||||
large: true
|
||||
}).done(function(modal) {
|
||||
dialogue = modal;
|
||||
|
||||
// Show dialog.
|
||||
dialogue.show();
|
||||
// Display the dialogue.
|
||||
dialogue.show();
|
||||
|
||||
// Destroy after hiding.
|
||||
dialogue.after('visibleChange', function(e) {
|
||||
// Going from visible to hidden.
|
||||
if (e.prevVal && !e.newVal) {
|
||||
this.destroy();
|
||||
// Fetch notifications.
|
||||
notification.fetchNotifications();
|
||||
}
|
||||
}, dialogue);
|
||||
// On hide handler.
|
||||
modal.getRoot().on(ModalEvents.hidden, function () {
|
||||
// Empty modal contents when it's hidden.
|
||||
modal.setBody('');
|
||||
|
||||
templates.runTemplateJS(js);
|
||||
|
||||
}).fail(notification.exception);
|
||||
// Fetch notifications.
|
||||
notification.fetchNotifications();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since 3.2
|
||||
*/
|
||||
define([], function() {
|
||||
define(['jquery'], function($) {
|
||||
return {
|
||||
/**
|
||||
* Init function.
|
||||
@@ -31,10 +31,13 @@ define([], function() {
|
||||
* @param {string} returnData The returned data.
|
||||
*/
|
||||
init: function(returnData) {
|
||||
if (window != top) {
|
||||
// Send return data to be processed by the parent window.
|
||||
parent.processContentItemReturnData(returnData);
|
||||
}
|
||||
// Make sure the window has loaded before we perform processing.
|
||||
$(window).ready(function() {
|
||||
if (window != top) {
|
||||
// Send return data to be processed by the parent window.
|
||||
parent.processContentItemReturnData(returnData);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1344,15 +1344,15 @@ function lti_get_type_config($typeid) {
|
||||
FROM {lti_types_config}
|
||||
WHERE typeid = :typeid1
|
||||
UNION ALL
|
||||
SELECT 'toolurl' AS name, " . $DB->sql_compare_text('baseurl', 1333) . " AS value
|
||||
SELECT 'toolurl' AS name, baseurl AS value
|
||||
FROM {lti_types}
|
||||
WHERE id = :typeid2
|
||||
UNION ALL
|
||||
SELECT 'icon' AS name, " . $DB->sql_compare_text('icon', 1333) . " AS value
|
||||
SELECT 'icon' AS name, icon AS value
|
||||
FROM {lti_types}
|
||||
WHERE id = :typeid3
|
||||
UNION ALL
|
||||
SELECT 'secureicon' AS name, " . $DB->sql_compare_text('secureicon', 1333) . " AS value
|
||||
SELECT 'secureicon' AS name, secureicon AS value
|
||||
FROM {lti_types}
|
||||
WHERE id = :typeid4";
|
||||
|
||||
|
||||
@@ -76,13 +76,11 @@
|
||||
|
||||
// Adjust iframe's width to the fit the container's width.
|
||||
var containerWidth = $('div.contentitem-container').width();
|
||||
$('#contentitem-page-iframe').attr('width', containerWidth);
|
||||
$('#contentitem-page-iframe').width(containerWidth + 'px');
|
||||
|
||||
var dialogueContentDiv = $('div.contentitem-container').parent();
|
||||
var dialogueContainer = dialogueContentDiv.parent();
|
||||
// Adjust iframe's height to container's height - 55px (dialogue title bar + top/bottom margins).
|
||||
var containerHeight = dialogueContainer.height() - 55;
|
||||
$('#contentitem-page-iframe').attr('height', containerHeight);
|
||||
// Adjust iframe's height to 75% of the width.
|
||||
var containerHeight = containerWidth * 0.75;
|
||||
$('#contentitem-page-iframe').height(containerHeight + 'px');
|
||||
});
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
Reference in New Issue
Block a user