Index: lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerActivity.as =================================================================== diff -u -rf8b2fe3dcd100582f6af76e4f06702a779714fbd -rf9e8747f735890453f4d3462ba35f35c8774c4e8 --- lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerActivity.as (.../LearnerActivity.as) (revision f8b2fe3dcd100582f6af76e4f06702a779714fbd) +++ lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerActivity.as (.../LearnerActivity.as) (revision f9e8747f735890453f4d3462ba35f35c8774c4e8) @@ -104,6 +104,8 @@ _tm = ThemeManager.getInstance(); _tip = new ToolTip(); + _dcStartTime = (_parent._parent.getActiveComplex() == this.activity || _parent._parent.getActiveSequence() == this.activity) ? new Date().getTime() : 0; + //Get reference to application and design data model app = ApplicationParent.getInstance(); @@ -202,7 +204,7 @@ */ private function draw(){ - var toolTitle:String + var toolTitle:String; if (actStatus == null || actStatus == undefined){ actStatus = Progress.compareProgressData(learner, _activity.activityID); } @@ -227,18 +229,19 @@ //write text if (actLabel == undefined){ - toolTitle = _activity.title + toolTitle = _activity.title; if (toolTitle.length > 19){ - toolTitle = toolTitle.substr(0, 17)+"..." + toolTitle = toolTitle.substr(0, 17)+"..."; } //title_lbl.text = toolTitle; }else { - toolTitle = actLabel + toolTitle = actLabel; if (toolTitle.length > 19){ - toolTitle = toolTitle.substr(0, 17)+"..." + toolTitle = toolTitle.substr(0, 17)+"..."; } } + title_lbl.text = toolTitle; if(_view instanceof LearnerTabView && !_complex) @@ -321,24 +324,40 @@ if(!_doubleClicking){ Debugger.log('Releasing:'+this,Debugger.GEN,'onRelease','LearnerActivity'); Debugger.log('Is sequence:'+this.activity.isSequenceActivity(),Debugger.GEN,'onRelease','LearnerActivity'); - + var activeComplex = LearnerComplexActivity(this._parent._parent).getActiveComplex(); + var activeSequence = LearnerComplexActivity(this._parent._parent).getActiveSequence(); + if(this.activity.isSequenceActivity()) { // insert sequence design into learner complex activity Debugger.log('parent :'+this._parent._parent, Debugger.CRITICAL,'onRelease','LearnerActivity'); - var activeSequence = LearnerComplexActivity(this._parent._parent).getActiveSequence(); Debugger.log('activeSequence:'+activeSequence, Debugger.CRITICAL,'onRelease','LearnerActivity'); if(LearnerComplexActivity(this._parent._parent).activity.activityUIID == this.activity.parentUIID) { + LearnerComplexActivity(this._parent._parent).setActiveComplex(null); + if(activeSequence == this.activity) { // close current active sequence LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputSequence(null); } else { // open sequence LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputSequence(this.activity); } + } + } else if(this.activity.isOptionsWithSequencesActivity() || this.activity.isOptionalActivity() || this.activity.isParallelActivity()) { + Debugger.log('activeComplex:'+activeComplex, Debugger.CRITICAL,'onRelease','LearnerActivity'); + + if(LearnerComplexActivity(this._parent._parent).activity.activityUIID == this.activity.parentUIID || activeSequence.activityUIID == this.activity.parentUIID) { + if(activeComplex == this.activity) { + // close current active complex + LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputComplex(null); + } else { + // open complex + LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputComplex(this.activity); + } + } } controller.activityRelease(this); @@ -393,9 +412,7 @@ public function getVisibleHeight ():Number { return _visibleHeight; } - - public function get activity():Activity{ return getActivity(); } Index: lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerComplexActivity.as =================================================================== diff -u -rf8b2fe3dcd100582f6af76e4f06702a779714fbd -rf9e8747f735890453f4d3462ba35f35c8774c4e8 --- lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerComplexActivity.as (.../LearnerComplexActivity.as) (revision f8b2fe3dcd100582f6af76e4f06702a779714fbd) +++ lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerComplexActivity.as (.../LearnerComplexActivity.as) (revision f9e8747f735890453f4d3462ba35f35c8774c4e8) @@ -26,6 +26,7 @@ import org.lamsfoundation.lams.common.ui.*; import org.lamsfoundation.lams.common.mvc.*; import org.lamsfoundation.lams.authoring.Activity; +import org.lamsfoundation.lams.authoring.ComplexActivity; import org.lamsfoundation.lams.authoring.SequenceActivity; import org.lamsfoundation.lams.authoring.DesignDataModel; import org.lamsfoundation.lams.authoring.cv.ICanvasActivity; @@ -52,7 +53,7 @@ private var LABEL_W:Number = 130; private var LABEL_H:Number = 22; - private var count:Number; + //private var count:Number; //this is set by the init object private var _controller:AbstractController; @@ -62,10 +63,9 @@ //Set by the init obj private var _activity : Activity; private var _children : Array; - private var _panelHeight : Number; //refs to screen items: - private var container_pnl : Panel; + private var container_pnl:Panel; private var title_lbl:MovieClip; private var labelHolder_mc:MovieClip; //locals @@ -97,7 +97,12 @@ private var _ddm:DesignDataModel; private var app:ApplicationParent; + private var _nested:Boolean; + private var activeSequence:SequenceActivity; + private var activeComplex:ComplexActivity; + + private var delegates:Array; function LearnerComplexActivity () { complexActivity_mc = this; @@ -112,17 +117,18 @@ _visibleHeight = container_pnl._height; _visibleWidth = container_pnl._width; - - MovieClipUtils.doLater(Proxy.create (this, init)); + + init(); } public function init():Void { var styleObj = _tm.getStyleObject('smallLabel'); title_lbl = labelHolder_mc.attachMovie("Label", "actTitle", this.getNextHighestDepth(), {_width:LABEL_W, _height:LABEL_H, autoSize:"center", styleName:styleObj}); children_mc = new Array(); - var childrenArray:Array; + delegates = new Array(); + var childrenArray:Array; childActivities_mc = this; _locked = false; @@ -132,9 +138,8 @@ clickTarget_mc.onRollOut = Proxy.create(this, localOnRollOut); clickTarget_mc.onPress = Proxy.create(this, localOnPress); clickTarget_mc.onRelease = Proxy.create(this, localOnRelease); - clickTarget_mc.onReleaseOutside = Proxy.create(this, localOnReleaseOutside); + clickTarget_mc.onReleaseOutside = Proxy.create(this, localOnReleaseOutside); - if(_activity.activityTypeID == Activity.PARALLEL_ACTIVITY_TYPE){ if(_children[0].orderID < _children[1].orderID){ childrenArray = orderParallelActivities(_children[0],_children[1]); @@ -145,32 +150,65 @@ childrenArray = _children; } - drawChildren(childrenArray, children_mc); + createChildren(childrenArray, children_mc); + clearDelegates(); - childHolder_mc._visible = false; - - MovieClipUtils.doLater(Proxy.create(this, draw, Proxy.create(this, checkIfSequenceActive))); + childHolder_mc._visible = (!_nested) ? false : true; } - private function drawChildren(children:Array, container:Array, _count:Number):Void { - count = (_count != null) ? _count : 0; + private function clearDelegates():Void { + // run delegates + Debugger.log("del length: " + delegates.length, Debugger.CRITICAL, "init", "LearnerComplexActivity"); + + if(delegates.length > 0) { + MovieClipUtils.doLater(Function(delegates.shift())); + } else { + MovieClipUtils.doLater(Proxy.create(this, draw, checkIfSequenceActive)); + return; + } + + MovieClipUtils.doLater(Proxy.create(this, clearDelegates)); + } + + private function createChildren(children:Array, container:Array, callback:Function, index:Number):Void { + + var rIndex:Number = drawChildren(children, container, index); + + if(rIndex != null) delegates.push(Proxy.create(this, createChildren, children, container, callback, rIndex)); + + return; + } + + private function drawChildren(children:Array, container:Array, index:Number):Number { var childCoordY:Number = 0; - for(var i=0; i 0) + childCoordY = (container[container.length-1] instanceof LearnerComplexActivity) ? container[container.length-1]._y + container[container.length-1].getChildrenHeight() : container[container.length-1]._y + 21; // (count*21); + Debugger.log("progStatus: " + progStatus, Debugger.CRITICAL, "drawChildren", "LearnerComplexActivity"); + Debugger.log("childCoordY: " + childCoordY, Debugger.CRITICAL, "drawChildren", "LearnerComplexActivity"); - var learnerAct:LearnerActivity = LearnerActivity(childHolder_mc.createChildAtDepth("LearnerActivity_forComplex", childHolder_mc.getNextHighestDepth(), {_activity:children[i], _controller:_controller, _view:_view, learner:learner, actStatus:progStatus, _complex:true, xPos:this._x, yPos:childCoordY})); + learnerAct = LearnerActivity(childHolder_mc.createChildAtDepth("LearnerActivity_forComplex", childHolder_mc.getNextHighestDepth(), {_activity:children[i], _controller:_controller, _view:_view, learner:learner, actStatus:progStatus, _complex:true, xPos:this._x, yPos:childCoordY})); + Debugger.log('attaching child movieL ' + learnerAct,Debugger.CRITICAL,'drawChildren','LearnerComplexActivity'); //set the positioning co-ords - //learnerAct.activityStatus = progStatus; + if(container.length > 0) + learnerAct._y = (container[container.length-1].nested) ? container[container.length-1]._y + container[container.length-1].getChildrenHeight() : container[container.length-1]._y + 21; + else + learnerAct._y = 0; - learnerAct._y = (count*21); - - childCoordY = this._y + ((count+1)*21) + 29; - learnerAct._visible = true; Debugger.log('x: ' + learnerAct._x + ' y: ' + learnerAct._y, Debugger.CRITICAL, 'drawChildren', 'LearnerComplexActivity'); @@ -184,27 +222,39 @@ } container.push(learnerAct); - count++; if(learnerAct.activity == activeSequence) { if(activeSequence.firstActivityUIID != null) { var actOrder:Array = model.getDesignOrder(activeSequence.firstActivityUIID, true); - drawChildren(actOrder, container, count); + createChildren(actOrder, container, null, null, false); + + return i+1; } - } - - - if(learnerAct.activity.isBranchingActivity() && !isLearnerModule()) { + } else if(learnerAct.activity.isBranchingActivity() && !isLearnerModule()) { Debugger.log('test: ' + (learnerAct.isAttempted || learnerAct.isCompleted), Debugger.CRITICAL, 'drawChildren', 'LearnerComplexActivity'); - if(learnerAct.isAttempted || learnerAct.isCompleted) - drawActiveBranch(learnerAct, container, count); + if(learnerAct.isAttempted || learnerAct.isCompleted) { + drawActiveBranch(learnerAct, container); + + return i+1; + } + } else if(learnerAct.activity == activeComplex) { + var _children:Array = (model instanceof LessonModel) ? model.learningDesignModel.getComplexActivityChildren(activeComplex.activityUIID) : model.ddm.getComplexActivityChildren(activeComplex.activityUIID); + Debugger.log("children length: " + _children.length, Debugger.CRITICAL, "drawChildren", "LearnerComplexActivity"); + + learnerAct = LearnerComplexActivity(childHolder_mc.createChildAtDepth("LearnerComplexActivity_Nested", DepthManager.kTop, {_activity:children[i], _children:_children, _controller:_controller, _view:_view, learner:learner, actStatus:progStatus, _nested:true, _x:0, _y:childCoordY+21})); + container.push(learnerAct); + + return i+1; } + } + return null; + } - private function drawActiveBranch(learnerAct:LearnerActivity, container:Array, count:Number):Void { + private function drawActiveBranch(learnerAct:LearnerActivity, container:Array):Void { var children:Array = model.ddm.getComplexActivityChildren(learnerAct.activity.activityUIID); for(var i=0; i