Index: lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java
===================================================================
diff -u -r3dbf966d900adefc34cdad501d3c392118451cd9 -r27a58f395dec9927221147dac08a0b75213fd354
--- lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 3dbf966d900adefc34cdad501d3c392118451cd9)
+++ lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 27a58f395dec9927221147dac08a0b75213fd354)
@@ -23,6 +23,7 @@
/* $$Id$$ */
package org.lamsfoundation.lams.web;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -61,7 +62,6 @@
import org.lamsfoundation.lams.usermanagement.Organisation;
import org.lamsfoundation.lams.usermanagement.Role;
import org.lamsfoundation.lams.usermanagement.User;
-import org.lamsfoundation.lams.usermanagement.dto.UserBasicDTO;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException;
import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
@@ -268,7 +268,7 @@
@SuppressWarnings("unchecked")
public ActionForward addLesson(ActionMapping mapping, ActionForm form, HttpServletRequest req,
HttpServletResponse res)
- throws IOException, UserAccessDeniedException, JSONException, RepositoryCheckedException {
+ throws IOException, UserAccessDeniedException, JSONException, RepositoryCheckedException {
UserDTO userDTO = getUser();
Integer organisationID = new Integer(WebUtil.readIntParam(req, "organisationID"));
@@ -336,7 +336,7 @@
*/
public ActionForward getFolderContents(ActionMapping mapping, ActionForm form, HttpServletRequest req,
HttpServletResponse res)
- throws UserAccessDeniedException, JSONException, IOException, RepositoryCheckedException {
+ throws UserAccessDeniedException, JSONException, IOException, RepositoryCheckedException {
Integer folderID = WebUtil.readIntParam(req, "folderID", true);
boolean allowInvalidDesigns = WebUtil.readBooleanParam(req, "allowInvalidDesigns", false);
String folderContentsJSON = getWorkspaceManagementService().getFolderContentsJSON(folderID,
@@ -350,6 +350,13 @@
public ActionForward getLearningDesignThumbnail(ActionMapping mapping, ActionForm form, HttpServletRequest req,
HttpServletResponse res) throws JDOMException, IOException {
Long learningDesignId = WebUtil.readLongParam(req, CentralConstants.PARAM_LEARNING_DESIGN_ID);
+ String imagePath = LearningDesignService.getLearningDesignSVGPath(learningDesignId);
+ File imageFile = new File(imagePath);
+ if (!imageFile.canRead()) {
+ res.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return null;
+ }
+
boolean download = WebUtil.readBooleanParam(req, "download", false);
// should the image be downloaded or a part of page?
if (download) {
@@ -363,7 +370,6 @@
res.setContentType("image/svg+xml");
}
- String imagePath = LearningDesignService.getLearningDesignSVGPath(learningDesignId);
FileInputStream input = new FileInputStream(imagePath);
OutputStream output = res.getOutputStream();
IOUtils.copy(input, output);
Index: lams_central/web/includes/javascript/addLesson.js
===================================================================
diff -u -r9bb68cb1df5f57c18e966963fd308e9a82743671 -r27a58f395dec9927221147dac08a0b75213fd354
--- lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision 9bb68cb1df5f57c18e966963fd308e9a82743671)
+++ lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision 27a58f395dec9927221147dac08a0b75213fd354)
@@ -17,6 +17,23 @@
var resized = resizeImage('ldScreenshotAuthor', 477);
toggleCanvasResize(resized ? CANVAS_RESIZE_OPTION_FIT
: CANVAS_RESIZE_OPTION_NONE);
+ }).error(function(){
+ // the LD SVG is missing, try to re-generate it
+ var image = $(this),
+ learningDesignID = $(this).data('learningDesignID');
+
+ // iframe just to load Authoring for a single purpose, generate the SVG
+ $('').appendTo('body').load(function(){
+ // call svgGenerator.jsp code to store LD SVG on the server
+ var frame = $(this),
+ win = frame[0].contentWindow || frame[0].contentDocument;
+ win.GeneralLib.saveLearningDesignImage();
+ frame.remove();
+ // load the image again, avoid caching
+ image.attr('src', LD_THUMBNAIL_URL_BASE + learningDesignID + '&_t=' + new Date().getTime());
+ }).attr('src', LAMS_URL
+ + 'authoring/author.do?method=generateSVG&selectable=false&learningDesignID='
+ + learningDesignID);
});
// generate LD initial tree; folderContents is declared in newLesson.jsp
@@ -61,8 +78,11 @@
$('.ldChoiceDependentCanvasElement').css('display', 'none');
if (event.node.highlightState == 0) {
$('#ldScreenshotLoading').css('display', 'inline');
- $('#ldScreenshotAuthor').attr('src', LD_THUMBNAIL_URL_BASE + event.node.data.learningDesignId);
- $('#ldScreenshotAuthor').css('width', 'auto').css('height', 'auto');
+ $('#ldScreenshotAuthor').data('learningDesignID', event.node.data.learningDesignId)
+ .attr('src', LD_THUMBNAIL_URL_BASE + event.node.data.learningDesignId
+ + '&_t=' + new Date().getTime())
+ .css('width', 'auto')
+ .css('height', 'auto');
} else {
toggleCanvasResize(CANVAS_RESIZE_OPTION_NONE);
}
Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js
===================================================================
diff -u -r3dbf966d900adefc34cdad501d3c392118451cd9 -r27a58f395dec9927221147dac08a0b75213fd354
--- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 3dbf966d900adefc34cdad501d3c392118451cd9)
+++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 27a58f395dec9927221147dac08a0b75213fd354)
@@ -2057,8 +2057,8 @@
// -20 so Chrome does not create unnecessary scrollbars when dropping a tool template to canvas
// +50 so there is space for rubbish bin
- width = Math.max(0, width, canvas.width()) - 20;
- height = Math.max(0, height + (isReadOnlyMode ? 20 : 50), canvas.height()) - 20;
+ width = Math.max(0, width, canvas.width() - 20);
+ height = Math.max(0, height + (isReadOnlyMode ? 20 : 50), canvas.height() - 20);
paper.attr({
'width' : width,
Index: lams_monitoring/web/includes/javascript/monitorLesson.js
===================================================================
diff -u -r3dbf966d900adefc34cdad501d3c392118451cd9 -r27a58f395dec9927221147dac08a0b75213fd354
--- lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision 3dbf966d900adefc34cdad501d3c392118451cd9)
+++ lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision 27a58f395dec9927221147dac08a0b75213fd354)
@@ -6,7 +6,7 @@
flaFormat = false,
// DIV container for lesson/branching SVG
// it gets accessed so many times it's worth to cache it here
- sequenceCanvas = null,
+ sequenceCanvas = $('#sequenceCanvas'),
// info box show timeout
sequenceInfoTimeout = 10000,
// which learner was selected in the search box
@@ -762,30 +762,8 @@
// put bottom layer, LD SVG
sequenceCanvas.html(originalSequenceCanvas);
} else {
- // fetch SVG just once, since it is immutable
- $.ajax({
- dataType : 'text',
- url : LAMS_URL + 'home.do',
- async : false,
- cache : false,
- data : {
- 'method' : 'getLearningDesignThumbnail',
- 'ldId' : ldId
- },
- success : function(response) {
- sequenceCanvasFirstFetch = true;
- originalSequenceCanvas = response;
- // store body dimensions before manipulating HTML
- // otherwise resizing will yield bad results
- var width = $('body').width(),
- height = $('body').height();
- sequenceCanvas = $('#sequenceCanvas')
- // remove previously set padding and dimensions, if any
- .removeAttr('style')
- .html(originalSequenceCanvas);
- resizeSequenceCanvas(width, height);
- }
- });
+ sequenceCanvasFirstFetch = true;
+ loadLearningDesignSVG();
}
// clear all completed learner icons except the door
@@ -890,7 +868,50 @@
});
}
+function loadLearningDesignSVG() {
+ // fetch SVG just once, since it is immutable
+ $.ajax({
+ dataType : 'text',
+ url : LAMS_URL + 'home.do',
+ async : false,
+ cache : false,
+ data : {
+ 'method' : 'getLearningDesignThumbnail',
+ 'ldId' : ldId
+ },
+ success : function(response) {
+ originalSequenceCanvas = response;
+ // store body dimensions before manipulating HTML
+ // otherwise resizing will yield bad results
+ var width = $('body').width(),
+ height = $('body').height();
+ // Remove previously set padding and dimensions, if any.
+ // For some reason sequenceCanvas needs to be assigned again here.
+ sequenceCanvas = $('#sequenceCanvas').removeAttr('style')
+ .html(originalSequenceCanvas);
+ resizeSequenceCanvas(width, height);
+ },
+ error : function(error) {
+ // the LD SVG is missing, try to re-generate it; if it is an another error, fail
+ if (error.status != 404) {
+ return;
+ }
+ // iframe just to load Authoring for a single purpose, generate the SVG
+ $('').appendTo('body').load(function(){
+ // call svgGenerator.jsp code to store LD SVG on the server
+ var frame = $(this),
+ win = frame[0].contentWindow || frame[0].contentDocument;
+ win.GeneralLib.saveLearningDesignImage();
+ frame.remove();
+ // load the image again
+ loadLearningDesignSVG();
+ }).attr('src', LAMS_URL
+ + 'authoring/author.do?method=generateSVG&selectable=false&learningDesignID=' + ldId);
+ }
+ });
+}
+
/**
* Forces given learner to move to activity indicated on SVG by coordinated (drag-drop)
*/
@@ -1363,9 +1384,9 @@
$('#sequenceSearchedLearnerHighlighter').hide();
sequenceSearchedLearner = null;
if (refresh) {
- updateSequenceTab();
+ updateSequenceTab();
+ }
}
-}
/**
@@ -1528,9 +1549,8 @@
* Adjusts sequence canvas (SVG) based on space available in the dialog.
*/
function resizeSequenceCanvas(width, height){
- var sequenceCanvas = $('#sequenceCanvas'),
- // can it be done nicer?
- canvasHeight = height - $('#tabs>ul').height() - $('#sequenceTopButtonsContainer').height()
+ // can the calculation it be done nicer?
+ var canvasHeight = height - $('#tabs>ul').height() - $('#sequenceTopButtonsContainer').height()
- Math.min(20, $('#completedLearnersContainer').height()) - 45,
canvasWidth = width - 15,
svg = $('svg', sequenceCanvas),