Merge branch 'MDL-54712-master' of git://github.com/junpataleta/moodle

This commit is contained in:
Andrew Nicols 2016-06-14 15:33:49 +08:00 committed by Dan Poltawski
commit 62bc2e84c5
6 changed files with 19 additions and 35 deletions

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/notification","mod_lti/tool_type","mod_lti/events","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g){var h={CARTRIDGE_URL:"#cartridge-url",CONSUMER_KEY:"#registration-key",SHARED_SECRET:"#registration-secret",REGISTRATION_FORM:"#cartridge-registration-form",REGISTRATION_SUBMIT_BUTTON:"#cartridge-registration-submit",REGISTRATION_CANCEL_BUTTON:"#cartridge-registration-cancel"},i=function(){return a(h.REGISTRATION_FORM).attr("data-cartridge-url")},j=function(){return a(h.REGISTRATION_SUBMIT_BUTTON)},k=function(){return a(h.REGISTRATION_CANCEL_BUTTON)},l=function(){return a(h.CONSUMER_KEY).val()},m=function(){return a(h.SHARED_SECRET).val()},n=function(){j().addClass("loading")},o=function(){j().removeClass("loading")},p=function(){return j().hasClass("loading")},q=function(){if(!p()){var b=i();if(""!==b){n();var f=l(),h=m(),j=d.create({cartridgeurl:b,key:f,secret:h});return j.done(function(){g.get_strings([{key:"success",component:"moodle"},{key:"successfullycreatedtooltype",component:"mod_lti"}]).done(function(b){a(document).trigger(e.NEW_TOOL_TYPE),a(document).trigger(e.STOP_CARTRIDGE_REGISTRATION),a(document).trigger(e.REGISTRATION_FEEDBACK,{status:b[0],message:b[1]})}).fail(c.exception)}).fail(function(){g.get_strings([{key:"error",component:"moodle"},{key:"failedtocreatetooltype",component:"mod_lti"}]).done(function(b){a(document).trigger(e.NEW_TOOL_TYPE),a(document).trigger(e.STOP_CARTRIDGE_REGISTRATION),a(document).trigger(e.REGISTRATION_FEEDBACK,{status:b[0],message:b[1],error:!0})}).fail(c.exception)}).always(function(){o()}),j}}},r=function(){var b=a(h.REGISTRATION_FORM);b.submit(function(a){a.preventDefault(),q()});var c=k();c.click(function(b){b.preventDefault(),a(document).trigger(e.STOP_CARTRIDGE_REGISTRATION)}),c.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||(a.keyCode==f.ENTER||a.keyCode==f.SPACE)&&(a.preventDefault(),c.click())})};return{init:function(){r()}}});
define(["jquery","core/ajax","core/notification","mod_lti/tool_type","mod_lti/events","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g){var h={CARTRIDGE_URL:"#cartridge-url",CONSUMER_KEY:"#registration-key",SHARED_SECRET:"#registration-secret",REGISTRATION_FORM:"#cartridge-registration-form",REGISTRATION_SUBMIT_BUTTON:"#cartridge-registration-submit",REGISTRATION_CANCEL_BUTTON:"#cartridge-registration-cancel"},i=function(){return a(h.REGISTRATION_FORM).attr("data-cartridge-url")},j=function(){return a(h.REGISTRATION_SUBMIT_BUTTON)},k=function(){return a(h.REGISTRATION_CANCEL_BUTTON)},l=function(){return a(h.CONSUMER_KEY).val()},m=function(){return a(h.SHARED_SECRET).val()},n=function(){j().addClass("loading")},o=function(){j().removeClass("loading")},p=function(){return j().hasClass("loading")},q=function(){if(!p()){var b=i();if(""!==b){n();var f=l(),h=m(),j=d.create({cartridgeurl:b,key:f,secret:h});return j.done(function(){g.get_string("successfullycreatedtooltype","mod_lti").done(function(b){a(document).trigger(e.NEW_TOOL_TYPE),a(document).trigger(e.STOP_CARTRIDGE_REGISTRATION),a(document).trigger(e.REGISTRATION_FEEDBACK,{message:b})}).fail(c.exception)}).fail(function(){g.get_string("failedtocreatetooltype","mod_lti").done(function(b){a(document).trigger(e.NEW_TOOL_TYPE),a(document).trigger(e.STOP_CARTRIDGE_REGISTRATION),a(document).trigger(e.REGISTRATION_FEEDBACK,{message:b,error:!0})}).fail(c.exception)}).always(function(){o()}),j}}},r=function(){var b=a(h.REGISTRATION_FORM);b.submit(function(a){a.preventDefault(),q()});var c=k();c.click(function(b){b.preventDefault(),a(document).trigger(e.STOP_CARTRIDGE_REGISTRATION)}),c.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||(a.keyCode==f.ENTER||a.keyCode==f.SPACE)&&(a.preventDefault(),c.click())})};return{init:function(){r()}}});

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/events","mod_lti/tool_proxy","mod_lti/tool_type","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g,h,i){var j={EXTERNAL_REGISTRATION_CONTAINER:"#external-registration-page-container",EXTERNAL_REGISTRATION_TEMPLATE_CONTAINER:"#external-registration-template-container",EXTERNAL_REGISTRATION_CANCEL_BUTTON:"#cancel-external-registration",TOOL_TYPE_CAPABILITIES_CONTAINER:"#tool-type-capabilities-container",TOOL_TYPE_CAPABILITIES_TEMPLATE_CONTAINER:"#tool-type-capabilities-template-container",CAPABILITIES_AGREE_CONTAINER:".capabilities-container"},k=function(){return a(j.EXTERNAL_REGISTRATION_CANCEL_BUTTON)},l=function(){return a(j.EXTERNAL_REGISTRATION_CONTAINER)},m=function(){return a(j.EXTERNAL_REGISTRATION_TEMPLATE_CONTAINER)},n=function(){return a(j.TOOL_TYPE_CAPABILITIES_CONTAINER)},o=function(){return a(j.TOOL_TYPE_CAPABILITIES_TEMPLATE_CONTAINER)},p=function(){n().addClass("loading")},q=function(){n().removeClass("loading")},r=function(){k().addClass("loading")},s=function(){k().removeClass("loading")},t=function(){n().addClass("hidden")},u=function(){n().removeClass("hidden")},v=function(){l().addClass("hidden")},w=function(){l().removeClass("hidden")},x=function(a){var b=k();b.attr("data-tool-proxy-id",a)},y=function(){var a=k();return a.attr("data-tool-proxy-id")},z=function(){var a=k();a.removeAttr("data-tool-proxy-id")},A=function(){return y()?!0:!1},B=function(){var a=k();return a.attr("data-tool-proxy-new")&&A()},C=function(){var a=k();return a.attr("data-tool-proxy-new","new")},D=function(){var a=k();return a.removeAttr("data-tool-proxy-new")},E=function(a){var c={methodname:"mod_lti_get_tool_proxy_registration_request",args:{id:a}};return b.call([c])[0]},F=function(){r();var b=a.Deferred();if(B()){var d=y();f["delete"](d).done(function(){b.resolve()}).fail(function(a){b.reject(a)})}else b.resolve();return b.done(function(){L(),s()}).fail(function(b){c.exception(b),L(),s(),i.get_strings([{key:"error",component:"moodle"},{key:"failedtodeletetoolproxy",component:"mod_lti"}]).done(function(b){var c={status:b[0],message:b[1],error:!0};a(document).trigger(e.REGISTRATION_FEEDBACK,c)}).fail(c.exception)}),b},G=function(a){var b=d.render("mod_lti/tool_proxy_registration_form",a);return b.done(function(a,b){var c=m();c.append(a),d.runTemplateJS(b),c.find("form").submit(),w()}).fail(c.exception),b},H=function(a){return g.update({id:a.id,state:g.constants.state.configured})},I=function(b){var f=a.Deferred();return d.render("mod_lti/tool_type_capabilities_agree",b).done(function(a,c){var g=o();v(),u(),d.replaceNodeContents(g,a,c);var h=g.find(j.CAPABILITIES_AGREE_CONTAINER);h.on(e.CAPABILITIES_AGREE,function(){p(),H(b).always(function(){q(),g.empty(),f.resolve()})}),h.on(e.CAPABILITIES_DECLINE,function(){g.empty(),f.resolve()})}).fail(f.reject),f.done(function(){t()}).fail(c.exception),f},J=function(b){var d=a.Deferred();return b&&""!==b?f.create({regurl:b}).done(function(a){C(),d=K(a.id)}).fail(function(b){F(),i.get_string("error","moodle").done(function(c){var d={status:c,message:b.message,error:!0};a(document).trigger(e.REGISTRATION_FEEDBACK,d)}).fail(c.exception),d.reject(b)}):d.resolve(),d},K=function(b){var c=a.Deferred();return x(b),E(b).done(function(a){G(a).done(function(){c.resolve()}).fail(c.fail)}).fail(c.fail),c},L=function(){A()&&z(),D(!1),v();var b=m();b.empty(),a(document).trigger(e.STOP_EXTERNAL_REGISTRATION)},M=function(){a(document).on(e.START_EXTERNAL_REGISTRATION,function(a,b){b&&(b.url&&J(b.url),b.proxyid&&K(b.proxyid))});var b=k();b.click(function(a){a.preventDefault(),F()}),b.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||(a.keyCode==h.ENTER||a.keyCode==h.SPACE)&&(a.preventDefault(),F())}),window.triggerExternalRegistrationComplete=function(b){var d=a.Deferred(),f={status:b.status,message:"",error:!1};if("success"==b.status){if(i.get_strings([{key:"success",component:"moodle"},{key:"successfullycreatedtooltype",component:"mod_lti"}]).done(function(a){f.status=a[0],f.message=a[1]}).fail(c.exception),d.done(function(){L(),a(document).trigger(e.REGISTRATION_FEEDBACK,f),a(document).trigger(e.NEW_TOOL_TYPE)}).fail(c.exception),B()){var h=y();g.getFromToolProxyId(h).done(function(a){if(a&&a.length){var b=a[0];b.hascapabilitygroups?I(b).always(function(){d.resolve()}):d.resolve()}else d.resolve()}).fail(function(){d.resolve()})}}else f.message=b.error,f.error=!0,d.done(function(){F().always(function(){a(document).trigger(e.REGISTRATION_FEEDBACK,f)})}).fail(c.exception),d.resolve();return d}};return{init:function(){M()}}});
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/events","mod_lti/tool_proxy","mod_lti/tool_type","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g,h,i){var j={EXTERNAL_REGISTRATION_CONTAINER:"#external-registration-page-container",EXTERNAL_REGISTRATION_TEMPLATE_CONTAINER:"#external-registration-template-container",EXTERNAL_REGISTRATION_CANCEL_BUTTON:"#cancel-external-registration",TOOL_TYPE_CAPABILITIES_CONTAINER:"#tool-type-capabilities-container",TOOL_TYPE_CAPABILITIES_TEMPLATE_CONTAINER:"#tool-type-capabilities-template-container",CAPABILITIES_AGREE_CONTAINER:".capabilities-container"},k=function(){return a(j.EXTERNAL_REGISTRATION_CANCEL_BUTTON)},l=function(){return a(j.EXTERNAL_REGISTRATION_CONTAINER)},m=function(){return a(j.EXTERNAL_REGISTRATION_TEMPLATE_CONTAINER)},n=function(){return a(j.TOOL_TYPE_CAPABILITIES_CONTAINER)},o=function(){return a(j.TOOL_TYPE_CAPABILITIES_TEMPLATE_CONTAINER)},p=function(){n().addClass("loading")},q=function(){n().removeClass("loading")},r=function(){k().addClass("loading")},s=function(){k().removeClass("loading")},t=function(){n().addClass("hidden")},u=function(){n().removeClass("hidden")},v=function(){l().addClass("hidden")},w=function(){l().removeClass("hidden")},x=function(a){var b=k();b.attr("data-tool-proxy-id",a)},y=function(){var a=k();return a.attr("data-tool-proxy-id")},z=function(){var a=k();a.removeAttr("data-tool-proxy-id")},A=function(){return y()?!0:!1},B=function(){var a=k();return a.attr("data-tool-proxy-new")&&A()},C=function(){var a=k();return a.attr("data-tool-proxy-new","new")},D=function(){var a=k();return a.removeAttr("data-tool-proxy-new")},E=function(a){var c={methodname:"mod_lti_get_tool_proxy_registration_request",args:{id:a}};return b.call([c])[0]},F=function(){r();var b=a.Deferred();if(B()){var d=y();f["delete"](d).done(function(){b.resolve()}).fail(function(a){b.reject(a)})}else b.resolve();return b.done(function(){L(),s()}).fail(function(b){c.exception(b),L(),s(),i.get_string("failedtodeletetoolproxy","mod_lti").done(function(b){var c={message:b,error:!0};a(document).trigger(e.REGISTRATION_FEEDBACK,c)}).fail(c.exception)}),b},G=function(a){var b=d.render("mod_lti/tool_proxy_registration_form",a);return b.done(function(a,b){var c=m();c.append(a),d.runTemplateJS(b),c.find("form").submit(),w()}).fail(c.exception),b},H=function(a){return g.update({id:a.id,state:g.constants.state.configured})},I=function(b){var f=a.Deferred();return d.render("mod_lti/tool_type_capabilities_agree",b).done(function(a,c){var g=o();v(),u(),d.replaceNodeContents(g,a,c);var h=g.find(j.CAPABILITIES_AGREE_CONTAINER);h.on(e.CAPABILITIES_AGREE,function(){p(),H(b).always(function(){q(),g.empty(),f.resolve()})}),h.on(e.CAPABILITIES_DECLINE,function(){g.empty(),f.resolve()})}).fail(f.reject),f.done(function(){t()}).fail(c.exception),f},J=function(b){var c=a.Deferred();return b&&""!==b?f.create({regurl:b}).done(function(a){C(),c=K(a.id)}).fail(function(b){F();var d={message:b.message,error:!0};a(document).trigger(e.REGISTRATION_FEEDBACK,d),c.reject(b)}):c.resolve(),c},K=function(b){var c=a.Deferred();return x(b),E(b).done(function(a){G(a).done(function(){c.resolve()}).fail(c.fail)}).fail(c.fail),c},L=function(){A()&&z(),D(!1),v();var b=m();b.empty(),a(document).trigger(e.STOP_EXTERNAL_REGISTRATION)},M=function(){a(document).on(e.START_EXTERNAL_REGISTRATION,function(a,b){b&&(b.url&&J(b.url),b.proxyid&&K(b.proxyid))});var b=k();b.click(function(a){a.preventDefault(),F()}),b.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||(a.keyCode==h.ENTER||a.keyCode==h.SPACE)&&(a.preventDefault(),F())}),window.triggerExternalRegistrationComplete=function(b){var d=a.Deferred(),f={message:"",error:!1};if("success"==b.status){if(i.get_string("successfullycreatedtooltype","mod_lti").done(function(a){f.message=a}).fail(c.exception),d.done(function(){L(),a(document).trigger(e.REGISTRATION_FEEDBACK,f),a(document).trigger(e.NEW_TOOL_TYPE)}).fail(c.exception),B()){var h=y();g.getFromToolProxyId(h).done(function(a){if(a&&a.length){var b=a[0];b.hascapabilitygroups?I(b).always(function(){d.resolve()}):d.resolve()}else d.resolve()}).fail(function(){d.resolve()})}}else f.message=b.error,f.error=!0,d.done(function(){F().always(function(){a(document).trigger(e.REGISTRATION_FEEDBACK,f)})}).fail(c.exception),d.resolve();return d}};return{init:function(){M()}}});

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/events","mod_lti/keys","mod_lti/tool_type","mod_lti/tool_proxy","core/str"],function(a,b,c,d,e,f,g,h,i){var j={EXTERNAL_REGISTRATION_CONTAINER:"#external-registration-container",EXTERNAL_REGISTRATION_PAGE_CONTAINER:"#external-registration-page-container",CARTRIDGE_REGISTRATION_CONTAINER:"#cartridge-registration-container",CARTRIDGE_REGISTRATION_FORM:"#cartridge-registration-form",ADD_TOOL_FORM:"#add-tool-form",TOOL_LIST_CONTAINER:"#tool-list-container",TOOL_CREATE_BUTTON:"#tool-create-button",REGISTRATION_CHOICE_CONTAINER:"#registration-choice-container",TOOL_URL:"#tool-url"},k=function(){return a(j.TOOL_CREATE_BUTTON)},l=function(){return a(j.TOOL_LIST_CONTAINER)},m=function(){return a(j.EXTERNAL_REGISTRATION_CONTAINER)},n=function(){return a(j.CARTRIDGE_REGISTRATION_CONTAINER)},o=function(){return a(j.REGISTRATION_CHOICE_CONTAINER)},p=function(){return a(j.TOOL_URL).val()},q=function(){m().addClass("hidden")},r=function(){n().addClass("hidden")},s=function(){o().addClass("hidden")},t=function(){r(),s(),m().removeClass("hidden"),v(m())},u=function(a){q(),s(),n().removeClass("hidden"),n().find(j.CARTRIDGE_REGISTRATION_FORM).attr("data-cartridge-url",a),v(n())},v=function(a){var b=a.children().clone(!0,!0);a.empty(),a.append(b)},w=function(){q(),r(),o().removeClass("hidden"),v(o())},x=function(){l().addClass("hidden")},y=function(){l().removeClass("hidden")},z=function(a){var b=a.error?"error":"success";c.addNotification({message:"<h4>"+a.status+"</h4><p>"+a.message+"</p>",type:b})},A=function(a){a.addClass("loading")},B=function(a){a.removeClass("loading")},C=function(){var b=a.Deferred(),e=l();A(e),a.when(g.query(),h.query({orphanedonly:!0})).done(function(a,c){d.render("mod_lti/tool_list",{tools:a,proxies:c}).done(function(a,c){e.empty(),e.append(a),d.runTemplateJS(c),b.resolve()}).fail(b.reject)}).fail(b.reject),b.fail(c.exception).always(function(){B(e)})},D=function(){var b=a.trim(p());if(""===b)return a.Deferred().resolve();var d=k();A(d);var f=g.isCartridge(b);return f.always(function(){B(d)}),f.done(function(c){c.iscartridge?(a(j.TOOL_URL).val(""),a(document).trigger(e.START_CARTRIDGE_REGISTRATION,b)):a(document).trigger(e.START_EXTERNAL_REGISTRATION,{url:b})}),f.fail(function(){i.get_strings([{key:"error",component:"moodle"},{key:"errorbadurl",component:"mod_lti"}]).done(function(b){a(document).trigger(e.REGISTRATION_FEEDBACK,{status:b[0],message:b[1],error:!0})}).fail(c.exception)}),f},E=function(){a(document).on(e.NEW_TOOL_TYPE,function(){C()}),a(document).on(e.START_EXTERNAL_REGISTRATION,function(){t(),a(j.TOOL_URL).val(""),x()}),a(document).on(e.STOP_EXTERNAL_REGISTRATION,function(){y(),w()}),a(document).on(e.START_CARTRIDGE_REGISTRATION,function(a,b){u(b)}),a(document).on(e.STOP_CARTRIDGE_REGISTRATION,function(){n().find(j.CARTRIDGE_REGISTRATION_FORM).removeAttr("data-cartridge-url"),w()}),a(document).on(e.REGISTRATION_FEEDBACK,function(a,b){z(b)});var b=a(j.ADD_TOOL_FORM);b.submit(function(a){a.preventDefault(),D()})};return{init:function(){E(),C()}}});
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/events","mod_lti/keys","mod_lti/tool_type","mod_lti/tool_proxy","core/str"],function(a,b,c,d,e,f,g,h,i){var j={EXTERNAL_REGISTRATION_CONTAINER:"#external-registration-container",EXTERNAL_REGISTRATION_PAGE_CONTAINER:"#external-registration-page-container",CARTRIDGE_REGISTRATION_CONTAINER:"#cartridge-registration-container",CARTRIDGE_REGISTRATION_FORM:"#cartridge-registration-form",ADD_TOOL_FORM:"#add-tool-form",TOOL_LIST_CONTAINER:"#tool-list-container",TOOL_CREATE_BUTTON:"#tool-create-button",REGISTRATION_CHOICE_CONTAINER:"#registration-choice-container",TOOL_URL:"#tool-url"},k=function(){return a(j.TOOL_CREATE_BUTTON)},l=function(){return a(j.TOOL_LIST_CONTAINER)},m=function(){return a(j.EXTERNAL_REGISTRATION_CONTAINER)},n=function(){return a(j.CARTRIDGE_REGISTRATION_CONTAINER)},o=function(){return a(j.REGISTRATION_CHOICE_CONTAINER)},p=function(){return a(j.TOOL_URL).val()},q=function(){m().addClass("hidden")},r=function(){n().addClass("hidden")},s=function(){o().addClass("hidden")},t=function(){r(),s(),m().removeClass("hidden"),v(m())},u=function(a){q(),s(),n().removeClass("hidden"),n().find(j.CARTRIDGE_REGISTRATION_FORM).attr("data-cartridge-url",a),v(n())},v=function(a){var b=a.children().clone(!0,!0);a.empty(),a.append(b)},w=function(){q(),r(),o().removeClass("hidden"),v(o())},x=function(){l().addClass("hidden")},y=function(){l().removeClass("hidden")},z=function(a){var b=a.error?"error":"success";c.addNotification({message:a.message,type:b})},A=function(a){a.addClass("loading")},B=function(a){a.removeClass("loading")},C=function(){var b=a.Deferred(),e=l();A(e),a.when(g.query(),h.query({orphanedonly:!0})).done(function(a,c){d.render("mod_lti/tool_list",{tools:a,proxies:c}).done(function(a,c){e.empty(),e.append(a),d.runTemplateJS(c),b.resolve()}).fail(b.reject)}).fail(b.reject),b.fail(c.exception).always(function(){B(e)})},D=function(){var b=a.trim(p());if(""===b)return a.Deferred().resolve();var d=k();A(d);var f=g.isCartridge(b);return f.always(function(){B(d)}),f.done(function(c){c.iscartridge?(a(j.TOOL_URL).val(""),a(document).trigger(e.START_CARTRIDGE_REGISTRATION,b)):a(document).trigger(e.START_EXTERNAL_REGISTRATION,{url:b})}),f.fail(function(){i.get_string("errorbadurl","mod_lti").done(function(b){a(document).trigger(e.REGISTRATION_FEEDBACK,{message:b,error:!0})}).fail(c.exception)}),f},E=function(){a(document).on(e.NEW_TOOL_TYPE,function(){C()}),a(document).on(e.START_EXTERNAL_REGISTRATION,function(){t(),a(j.TOOL_URL).val(""),x()}),a(document).on(e.STOP_EXTERNAL_REGISTRATION,function(){y(),w()}),a(document).on(e.START_CARTRIDGE_REGISTRATION,function(a,b){u(b)}),a(document).on(e.STOP_CARTRIDGE_REGISTRATION,function(){n().find(j.CARTRIDGE_REGISTRATION_FORM).removeAttr("data-cartridge-url"),w()}),a(document).on(e.REGISTRATION_FEEDBACK,function(a,b){z(b)});var b=a(j.ADD_TOOL_FORM);b.submit(function(a){a.preventDefault(),D()})};return{init:function(){E(),C()}}});

View File

@ -153,23 +153,19 @@ define(['jquery', 'core/ajax', 'core/notification', 'mod_lti/tool_type', 'mod_lt
var promise = toolType.create({cartridgeurl: url, key: consumerKey, secret: sharedSecret});
promise.done(function() {
str.get_strings([{key: 'success', component: 'moodle'},
{key: 'successfullycreatedtooltype', component: 'mod_lti'}]).done(function (s) {
str.get_string('successfullycreatedtooltype', 'mod_lti').done(function (s) {
$(document).trigger(ltiEvents.NEW_TOOL_TYPE);
$(document).trigger(ltiEvents.STOP_CARTRIDGE_REGISTRATION);
$(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, {
status: s[0],
message: s[1]
message: s
});
}).fail(notification.exception);
}).fail(function() {
str.get_strings([{key: 'error', component: 'moodle'},
{key: 'failedtocreatetooltype', component: 'mod_lti'}]).done(function (s) {
str.get_string('failedtocreatetooltype', 'mod_lti').done(function (s) {
$(document).trigger(ltiEvents.NEW_TOOL_TYPE);
$(document).trigger(ltiEvents.STOP_CARTRIDGE_REGISTRATION);
$(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, {
status: s[0],
message: s[1],
message: s,
error: true
});
}).fail(notification.exception);

View File

@ -321,11 +321,9 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/e
notification.exception(failure);
finishExternalRegistration();
stopLoadingCancel();
str.get_strings([{key: 'error', component: 'moodle'},
{key: 'failedtodeletetoolproxy', component: 'mod_lti'}]).done(function (s) {
str.get_string('failedtodeletetoolproxy', 'mod_lti').done(function (s) {
var feedback = {
status: s[0],
message: s[1],
message: s,
error: true
};
$(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, feedback);
@ -461,16 +459,11 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/e
// Clean up.
cancelRegistration();
// Let the user know what the error is.
str.get_string('error', 'moodle')
.done(function (s) {
var feedback = {
status: s,
message: exception.message,
error: true
};
$(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, feedback);
})
.fail(notification.exception);
var feedback = {
message: exception.message,
error: true
};
$(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, feedback);
promise.reject(exception);
});
}
@ -571,16 +564,13 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/e
window.triggerExternalRegistrationComplete = function(data) {
var promise = $.Deferred();
var feedback = {
status: data.status,
message: "",
error: false
};
if (data.status == "success") {
str.get_strings([{key: 'success', component: 'moodle'},
{key: 'successfullycreatedtooltype', component: 'mod_lti'}]).done(function (s) {
feedback.status = s[0];
feedback.message = s[1];
str.get_string('successfullycreatedtooltype', 'mod_lti').done(function (s) {
feedback.message = s;
}).fail(notification.exception);
// Trigger appropriate events when we've completed the necessary requests.

View File

@ -223,7 +223,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/e
var showRegistrationFeedback = function(data) {
var type = data.error ? 'error' : 'success';
notification.addNotification({
message: '<h4>' + data.status + '</h4><p>' + data.message + '</p>',
message: data.message,
type: type
});
};
@ -314,12 +314,10 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/e
});
promise.fail(function () {
str.get_strings([{key: 'error', component: 'moodle'},
{key: 'errorbadurl', component: 'mod_lti'}])
str.get_string('errorbadurl', 'mod_lti')
.done(function (s) {
$(document).trigger(ltiEvents.REGISTRATION_FEEDBACK, {
status: s[0],
message: s[1],
message: s,
error: true
});
})