Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -r2a60aefd13ef4aac8e67f7e23ff837062aa837d9 -rc296ef202134b9c65d9543e3df0534c6afbbea64 --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 2a60aefd13ef4aac8e67f7e23ff837062aa837d9) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision c296ef202134b9c65d9543e3df0534c6afbbea64) @@ -1409,33 +1409,6 @@ * Open separate window with activity authoring on double click. */ openActivityAuthoring : function(activity){ - // fetch authoring URL for a Tool Activity - if (!activity.authorURL && activity.toolID) { - $.ajax({ - async : true, - cache : false, - url : LAMS_URL + "authoring/createToolContent.do", - dataType : 'json', - data : { - 'toolID' : activity.toolID, - // if toolContentID exists, a new content will not be created, only authorURL will be fetched - 'toolContentID' : activity.toolContentID, - 'contentFolderID' : layout.ld.contentFolderID - }, - success : function(response) { - activity.authorURL = response.authorURL; - if (!activity.toolContentID) { - activity.toolContentID = response.toolContentID; - } - if (!layout.ld.contentFolderID) { - // if LD did not have contentFolderID, it was just generated - // so remember it - layout.ld.contentFolderID = response.contentFolderID; - } - } - }); - } - if (activity.authorURL) { var dialogID = "dialogActivity" + activity.toolContentID; showDialog(dialogID, { @@ -1472,12 +1445,44 @@ }, true); GeneralLib.setModified(true); + return; } + + // if there is not authoring URL, fetch it for a Tool Activity + if (activity.toolID) { + $.ajax({ + async : true, + cache : false, + url : LAMS_URL + "authoring/createToolContent.do", + dataType : 'json', + data : { + 'toolID' : activity.toolID, + // if toolContentID exists, a new content will not be created, only authorURL will be fetched + 'toolContentID' : activity.toolContentID, + 'contentFolderID' : layout.ld.contentFolderID + }, + success : function(response) { + // make sure that response contains valid data + if (response.authorURL) { + activity.authorURL = response.authorURL; + activity.toolContentID = response.toolContentID; + // the response should always return a correct content folder ID, + // but just to make sure use it only when it is needed + if (!layout.ld.contentFolderID) { + layout.ld.contentFolderID = response.contentFolderID; + } + + // this time open it properly + ActivityLib.openActivityAuthoring(activity); + } + } + }); + } }, /** - * Draw each of activity's inboud and outbound transitions again. + * Draw each of activity's inbound and outbound transitions again. */ redrawTransitions : function(activity) { if (activity.transitions) {