Index: lams_central/web/author2.jsp
===================================================================
diff -u -rdec21a402fc7b42adcf84c15b644228d46a140c7 -rcb22fc8bbf9e4678f8769262d02d86ba5a4ee75b
--- lams_central/web/author2.jsp (.../author2.jsp) (revision dec21a402fc7b42adcf84c15b644228d46a140c7)
+++ lams_central/web/author2.jsp (.../author2.jsp) (revision cb22fc8bbf9e4678f8769262d02d86ba5a4ee75b)
@@ -43,8 +43,16 @@
- Open
+
- - Save as...
+ - Save as
+ - Export
Index: lams_central/web/css/authoring.css
===================================================================
diff -u -rdec21a402fc7b42adcf84c15b644228d46a140c7 -rcb22fc8bbf9e4678f8769262d02d86ba5a4ee75b
--- lams_central/web/css/authoring.css (.../authoring.css) (revision dec21a402fc7b42adcf84c15b644228d46a140c7)
+++ lams_central/web/css/authoring.css (.../authoring.css) (revision cb22fc8bbf9e4678f8769262d02d86ba5a4ee75b)
@@ -169,7 +169,7 @@
/**** Main authoring styles ****/
div#toolbar {
- width: 1003px;
+ width: 1035px;
padding: 3px;
height: 27px;
}
@@ -272,7 +272,7 @@
#canvas {
overflow: auto;
- width: 844px;
+ width: 900px;
height: 720px;
vertical-align: top;
}
\ No newline at end of file
Index: lams_central/web/includes/javascript/authoring/authoringActivity.js
===================================================================
diff -u -rdec21a402fc7b42adcf84c15b644228d46a140c7 -rcb22fc8bbf9e4678f8769262d02d86ba5a4ee75b
--- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision dec21a402fc7b42adcf84c15b644228d46a140c7)
+++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision cb22fc8bbf9e4678f8769262d02d86ba5a4ee75b)
@@ -576,7 +576,7 @@
}
// remove the activity from parent activity
- if (activity.parentActivity) {
+ if (activity.parentActivity && activity.parentActivity instanceof DecorationLib.Container) {
activity.parentActivity.childActivities.splice(layout.parentActivity.childActivities.indexOf(activity), 1);
}
@@ -597,10 +597,10 @@
* Draws a transition between two activities.
*/
addTransition : function(fromActivity, toActivity, redraw, id, uiid, branchData) {
- if (toActivity.parentActivity){
+ if (toActivity.parentActivity && toActivity.parentActivity instanceof DecorationLib.Container){
toActivity = toActivity.parentActivity;
}
- if (fromActivity.parentActivity){
+ if (fromActivity.parentActivity && fromActivity.parentActivity instanceof DecorationLib.Container){
fromActivity = fromActivity.parentActivity;
}
if (toActivity instanceof ActivityLib.FloatingActivity
@@ -776,7 +776,7 @@
object.items.fitButton.show();
$.each(childActivities, function(){
- if (!this.parentActivity) {
+ if (!this.parentActivity || !(this.parentActivity instanceof DecorationLib.Container)) {
ActivityLib.addSelectEffect(this, false);
}
});
@@ -893,7 +893,7 @@
dropActivity : function(activity, x, y) {
if (!(activity instanceof DecorationLib.Container)) {
// check if it was removed from an Optional or Floating Activity
- if (activity.parentActivity) {
+ if (activity.parentActivity && activity.parentActivity instanceof DecorationLib.Container) {
var childActivities = DecorationLib.getChildActivities(activity.parentActivity.items.shape);
if ($.inArray(activity, childActivities) == -1) {
activity.parentActivity.draw();
Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js
===================================================================
diff -u -rdec21a402fc7b42adcf84c15b644228d46a140c7 -rcb22fc8bbf9e4678f8769262d02d86ba5a4ee75b
--- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision dec21a402fc7b42adcf84c15b644228d46a140c7)
+++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision cb22fc8bbf9e4678f8769262d02d86ba5a4ee75b)
@@ -827,7 +827,8 @@
});
if (paperWidth > paper.width || paperHeight > paper.height) {
- resizePaper(paperWidth, paperHeight);
+ // add some height for rubbish bin
+ resizePaper(paperWidth, paperHeight + 70);
} else {
HandlerLib.resetCanvasMode(true);
}
@@ -853,7 +854,8 @@
title = title.trim(),
description = CKEDITOR.instances['ldDescriptionFieldDescription'].getData(),
// final success/failure of the save
- result = false;
+ result = false,
+ error = null;
$.each(layout.activities, function(){
if (this.parentActivity && (this.parentActivity instanceof ActivityLib.BranchingActivity
@@ -888,6 +890,11 @@
}
orderID++;
+ if (childActivity.transitions.from.length == 0) {
+ // we need to carry on to assign parent to all remaining child activities
+ error = 'One of branches does not have a transition to the end point';
+ break;
+ }
childActivity = childActivity.transitions.from[0].toActivity;
}
});
@@ -897,6 +904,11 @@
}
});
+ if (error) {
+ alert(error);
+ return false;
+ }
+
if (layout.floatingActivity){
layoutActivities.push(layout.floatingActivity);
}
@@ -1066,6 +1078,11 @@
}
});
+ if (error) {
+ alert(error);
+ return false;
+ }
+
// iterate over labels and regions
$.each(layout.labels.concat(layout.regions), function(){
var box = this.items.shape.getBBox(),
@@ -1253,12 +1270,16 @@
// draw rubbish bin on canvas
var binPath = Raphael.parsePathString(layout.defs.bin);
- binPath = Raphael.transformPath(binPath, Raphael.format('t {0} {1}', width, height - 50));
+ binPath = Raphael.transformPath(binPath, Raphael.format('t {0} {1}', width - 5, height - 50));
layout.items.bin = paper.path(binPath);
HandlerLib.resetCanvasMode(true);
}
+
+/**
+ * Tells that current sequence was modified and not saved.
+ */
function setModified(modified) {
layout.modified = modified;
if (modified) {
@@ -1268,6 +1289,15 @@
} else {
$('#previewButton').attr('disabled', null)
.button('option', 'disabled', false);
+
$('#ldDescriptionFieldModified').text('');
}
+
+ if (modified || layout.activities.length == 0) {
+ $('#exportButton').attr('disabled', 'disabled')
+ .css('opacity', 0.2);
+ } else {
+ $('#exportButton').attr('disabled', null)
+ .css('opacity', 1);
+ }
}
\ No newline at end of file
Index: lams_central/web/includes/javascript/authoring/authoringMenu.js
===================================================================
diff -u -rdec21a402fc7b42adcf84c15b644228d46a140c7 -rcb22fc8bbf9e4678f8769262d02d86ba5a4ee75b
--- lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision dec21a402fc7b42adcf84c15b644228d46a140c7)
+++ lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision cb22fc8bbf9e4678f8769262d02d86ba5a4ee75b)
@@ -396,16 +396,13 @@
/ layout.conf.arrangeHorizontalSpace),
// the initial max length of subsequences is limited by paper space
subsequenceMaxLength = maxColumns,
- // check how many rows current paper can hold
- maxRows = Math.floor((paper.height - layout.conf.arrangeVerticalPadding)
- / layout.conf.arrangeVerticalSpace),
// a shallow copy of activities array without inner activities
activitiesCopy = [],
// just to speed up processing when there are only activities with no transitions left
onlyDetachedLeft = false;
$.each(layout.activities, function(){
- if (!this.parentActivity){
+ if (!this.parentActivity || !(this.parentActivity instanceof DecorationLib.Container)){
activitiesCopy.push(this);
}
});
@@ -439,13 +436,6 @@
// main loop; iterate over whatever is left in the array
while (activitiesCopy.length > 0) {
- // resize paper vertically, if needed
- if (row > maxRows) {
- maxRows++;
- resizePaper(paper.width, layout.conf.arrangeVerticalPadding
- + maxRows * layout.conf.arrangeVerticalSpace);
- }
-
// look for activities with transitions first; detached ones go to the very end
var activity = null;
if (!onlyDetachedLeft) {
@@ -562,7 +552,7 @@
// learn where a tall Optional Activity has its end
// and later start drawing activities lower than in the next row
- if (activity instanceof ActivityLib.OptionalActivity && activity.childActivities.length > 1) {
+ if (activity instanceof DecorationLib.Container && activity.childActivities.length > 1) {
var activityEndY = activity.items.shape.getBBox().y2;
if (!forceRowY || activityEndY > forceRowY) {
forceRowY = activityEndY;
@@ -637,19 +627,25 @@
};
if (layout.floatingActivity) {
- row++;
- if (row >= maxRows) {
- resizePaper(paper.width, layout.conf.arrangeVerticalPadding
- + layout.floatingActivity.items.shape.getBBox().height
- + row * layout.conf.arrangeVerticalSpace);
+ if (column > 0) {
+ // if the last activity was in the last column, there is no need for another row
+ row++;
+ column = 0;
}
- column = 0;
var x = layout.conf.arrangeHorizontalPadding,
y = layout.conf.arrangeVerticalPadding - 30 + row * layout.conf.arrangeVerticalSpace;
layout.floatingActivity.draw(x, y);
}
+ // are there more rows that current paper can hold?
+ if (row >= Math.floor((paper.height - layout.conf.arrangeVerticalPadding)
+ / layout.conf.arrangeVerticalSpace)) {
+ // some extra height for rubbish bin
+ resizePaper(paper.width, layout.conf.arrangeVerticalPadding + 70
+ + row * layout.conf.arrangeVerticalSpace);
+ }
+
// redraw transitions one by one
$.each(layout.activities, function(){
$.each(this.transitions.from.slice(), function(){
@@ -818,6 +814,40 @@
ldDescriptionHideTip
});
$('#ldDescriptionHideTip').toggle();
+ },
+
+
+ importLearningDesign : function(){
+ var importWindow = window.open(LAMS_URL + 'authoring/importToolContent.do?method=import','Import',
+ 'width=800,height=298,resize=yes,status=yes,scrollbar=no,menubar=no,toolbar=no'),
+ currentLearningDesignID = null,
+ regEx = /learningDesignID=(\d+)/g,
+ // since window.onload does not really work after submitting a form inside the window,
+ // this trick checks periodically for changes
+ loadCheckInterval = setInterval(function(){
+ if (!importWindow){
+ // window was closed
+ clearInterval(loadCheckInterval);
+ return;
+ }
+ var body = $('body', importWindow.document).html(),
+ match = regEx.exec(body);
+ // check if ID was found and it's not the same as previously
+ if (match && match[1] != currentLearningDesignID) {
+ currentLearningDesignID = match[1];
+ openLearningDesign(currentLearningDesignID);
+ }
+ }, 1000);
+ },
+
+
+ exportLearningDesign : function(){
+ if (layout.modified || layout.activities.length == 0) {
+ return;
+ }
+
+ window.open(LAMS_URL + 'authoring/exportToolContent.do?learningDesignID=46','Export',
+ 'width=712,height=298,resize=yes,status=yes,scrollbar=no,menubar=no,toolbar=no');
}
/*
Index: lams_central/web/main.jsp
===================================================================
diff -u -rdec21a402fc7b42adcf84c15b644228d46a140c7 -rcb22fc8bbf9e4678f8769262d02d86ba5a4ee75b
--- lams_central/web/main.jsp (.../main.jsp) (revision dec21a402fc7b42adcf84c15b644228d46a140c7)
+++ lams_central/web/main.jsp (.../main.jsp) (revision cb22fc8bbf9e4678f8769262d02d86ba5a4ee75b)
@@ -246,7 +246,7 @@