Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -r7116e79c883ad42375d9fa3278dec8a84733ea86 -r4f01dc291e2a756de97ba01e790754b3a3d0fecf --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 7116e79c883ad42375d9fa3278dec8a84733ea86) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 4f01dc291e2a756de97ba01e790754b3a3d0fecf) @@ -1351,33 +1351,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) { showDialog("dialogActivity" + activity.toolContentID, { 'height' : Math.max(300, $(window).height() - 30), @@ -1415,12 +1388,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) {