Index: lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerActivity.as =================================================================== diff -u -r26d82b53f36d547721cd9e7f565004a644590c3b -re4ee9834b56ccd57cf1a8548cec5d58338a39cd3 --- lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerActivity.as (.../LearnerActivity.as) (revision 26d82b53f36d547721cd9e7f565004a644590c3b) +++ lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerActivity.as (.../LearnerActivity.as) (revision e4ee9834b56ccd57cf1a8548cec5d58338a39cd3) @@ -22,28 +22,39 @@ */ import org.lamsfoundation.lams.common.*; -import org.lamsfoundation.lams.common.util.*; -import org.lamsfoundation.lams.common.ui.*; import org.lamsfoundation.lams.common.dict.*; import org.lamsfoundation.lams.common.mvc.*; +import org.lamsfoundation.lams.common.style.*; +import org.lamsfoundation.lams.common.util.*; +import org.lamsfoundation.lams.common.ui.*; + import org.lamsfoundation.lams.learner.ls.*; + import org.lamsfoundation.lams.monitoring.mv.*; import org.lamsfoundation.lams.monitoring.mv.tabviews.LearnerTabView; + import org.lamsfoundation.lams.authoring.Activity; +import org.lamsfoundation.lams.authoring.ComplexActivity; import org.lamsfoundation.lams.authoring.GateActivity; import org.lamsfoundation.lams.authoring.SequenceActivity; -import org.lamsfoundation.lams.authoring.ComplexActivity; -import org.lamsfoundation.lams.common.style.*; import com.polymercode.Draw; + import mx.managers.* import mx.containers.*; import mx.events.* import mx.utils.* import mx.controls.* /** -* LearnerActivity - +* LearnerActivity +* +* This class represets and controls the display of a simple tool or system activity in the Learner's progress bar. +* The Progress Bar is displayed in the Learner application and in the Monitor application (Learner tab). +* +* A simple movieclip is displayed in the progess bar using an icon to identify the status of the activity in the progress bar. +* This class can also be nested within a LCA (Learner Complex Activity) at multiple levels. +* */ class LearnerActivity extends MovieClip { @@ -63,12 +74,12 @@ //this is set by the init object private var _controller:AbstractController; private var _view:AbstractView; - private var _tm:ThemeManager; - //TODO:This should be ToolActivity - private var _activity:Activity; + private var _activity:Activity; //TODO:This should be ToolActivity private var _isSelected:Boolean; + private var app:ApplicationParent; + private var _tm:ThemeManager; private var _tip:ToolTip; //locals @@ -97,9 +108,11 @@ private var _line_bottom:MovieClip; private var _line_top:MovieClip; + // Identifies if the activity is a child of a complex activity and therefore nested inside a LCA and the level it is nested at. private var _complex:Boolean; private var _level:Number; + /* Constructor */ function LearnerActivity(){ Debugger.log("_activity:"+_activity.title,4,'Constructor','LearnerActivity'); Debugger.log("actStatus:"+ actStatus,4,'Constructor','LearnerActivity'); @@ -131,6 +144,10 @@ } + /** + * Setup and draw the component. + * + */ public function init(initObj):Void{ var styleObj = _tm.getStyleObject('smallLabel'); var _autosize:String; @@ -187,17 +204,20 @@ draw(); } + /** + * Clear this component. + * + */ + public function destroy():Void { title_lbl.removeMovieClip(); this._visible = false; this.removeMovieClip(); } /** - * Does the work of laying out the screen assets. - * Depending on type of Activity different bits will be shown - * @usage - * @return + * Does the work of laying out the screen assets, displaying the title label and setting the progress icon. + * */ private function draw(){ @@ -232,6 +252,9 @@ } Debugger.log("parent level: " + _parent._parent.level, Debugger.CRITICAL, "draw", "LearnerActivity"); + + // Using a dash to indicate level depth when nested inside a LCA + if(_parent._parent.level > 0) { for(var i=0; i<(_parent._parent.level + _parent._parent.complexLevel); i++) toolTitle = "-" + toolTitle; @@ -240,18 +263,25 @@ if(level > 0) for(var i=0; i 18){ toolTitle = toolTitle.substr(0, 16)+"..."; } title_lbl.text = toolTitle; + // Continue drawing the next activity in the design if on top level. if(_view instanceof LearnerTabView && !_complex) LearnerTabView(_view).drawNext(); } + /** + * Display the tooltip. + * + */ + public function showToolTip(btnObj, ttMessage:String):Void{ Debugger.log("showToolTip invoked", Debugger.CRITICAL, "showToolTip", "LearnerActivity"); var appData = getAppData(); @@ -282,10 +312,20 @@ } + /** + * Hide the tooltip. + * + */ + public function hideToolTip():Void{ _tip.CloseToolTip(); } + /** + * Handles the rollOver event and displays a tooltip for the activity. + * + */ + private function onRollOver(){ if (actStatus == "completed_mc"){ showToolTip(this.clickTarget_mc, Dictionary.getValue("completed_act_tooltip")); @@ -323,11 +363,21 @@ } } + /** + * Handles the rollOut event and removes the tooltip. + * + */ + private function onRollOut(){ hideToolTip(); } + /** + * Handles the onPress (doubleClick) event. + * DoubleClick will open the activity's learner/monitor page. + */ + public function onPress():Void{ var c = (_controller instanceof LessonController) ? LessonController(_controller) : MonitorController(_controller); @@ -349,6 +399,11 @@ } + /** + * Handles the onRelease event. + * Assists with setting active sequence/complex activities of a LCA when the component is manually selected to be opened/closed. + * + */ public function onRelease():Void{ var c = (_controller instanceof LessonController) ? LessonController(_controller) : MonitorController(_controller); @@ -368,39 +423,39 @@ var activeComplex = LearnerComplexActivity(_parent._parent).complexMap.get(this.activity.activityUIID); var activeSequence = LearnerComplexActivity(_parent._parent).sequenceMap.get(this.activity.activityUIID); - if(this.activity.isSequenceActivity()) { - // insert sequence design into learner complex activity - Debugger.log('parent :'+this._parent._parent, Debugger.CRITICAL,'onRelease','LearnerActivity'); - - Debugger.log('activeSequence:'+activeSequence, Debugger.CRITICAL,'onRelease','LearnerActivity'); - - if(LearnerComplexActivity(this._parent._parent).activity.activityUIID == this.activity.parentUIID) { + if(this.activity.isSequenceActivity()) { + Debugger.log('parent :'+this._parent._parent, Debugger.CRITICAL,'onRelease','LearnerActivity'); + Debugger.log('activeSequence:'+activeSequence, Debugger.CRITICAL,'onRelease','LearnerActivity'); + + if(LearnerComplexActivity(this._parent._parent).activity.activityUIID == this.activity.parentUIID) { + + LearnerComplexActivity(this._parent._parent).setActiveComplex(null); //**** - LearnerComplexActivity(this._parent._parent).setActiveComplex(null); //**** + if(activeSequence) { + // close current active sequence + LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputSequence(null, true); + } else { + // open sequence + LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputSequence(this.activity, true); + } - if(activeSequence) { - // close current active sequence - LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputSequence(null, true); - } else { - // open sequence - LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputSequence(this.activity, true); - } - + } + } else if(this.activity.isOptionsWithSequencesActivity() || this.activity.isOptionalActivity() || this.activity.isParallelActivity() || this.activity.isBranchingActivity()) { + Debugger.log('activeComplex:'+activeComplex, Debugger.CRITICAL,'onRelease','LearnerActivity'); + + if(model.findParent(this.activity, LearnerComplexActivity(this._parent._parent).activity) || (activeSequence.activityUIID == this.activity.parentUIID)) { + if(activeComplex != null) { + // close current active complex + LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputComplex(null, null, true); + } else { + // open complex + LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputComplex(this.activity, this.level, true); } - } else if(this.activity.isOptionsWithSequencesActivity() || this.activity.isOptionalActivity() || this.activity.isParallelActivity() || this.activity.isBranchingActivity()) { - Debugger.log('activeComplex:'+activeComplex, Debugger.CRITICAL,'onRelease','LearnerActivity'); - if(model.findParent(this.activity, LearnerComplexActivity(this._parent._parent).activity) || (activeSequence.activityUIID == this.activity.parentUIID)) { - if(activeComplex != null) { - // close current active complex - LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputComplex(null, null, true); - } else { - // open complex - LearnerComplexActivity(this._parent._parent).removeAllChildrenAndInputComplex(this.activity, this.level, true); - } - } } + } - c.activityRelease(this); + c.activityRelease(this); + } } @@ -447,7 +502,6 @@ return _visibleWidth; } - /** * * @usage Index: lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerComplexActivity.as =================================================================== diff -u -rae2ae6ffbf52cc9c75522c976f16fb9bcf8db198 -re4ee9834b56ccd57cf1a8548cec5d58338a39cd3 --- lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerComplexActivity.as (.../LearnerComplexActivity.as) (revision ae2ae6ffbf52cc9c75522c976f16fb9bcf8db198) +++ lams_flash/src/common/flash/org/lamsfoundation/lams/common/LearnerComplexActivity.as (.../LearnerComplexActivity.as) (revision e4ee9834b56ccd57cf1a8548cec5d58338a39cd3) @@ -20,56 +20,69 @@ * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ */ -import org.lamsfoundation.lams.common.*; +import org.lamsfoundation.lams.common.*; +import org.lamsfoundation.lams.common.dict.*; +import org.lamsfoundation.lams.common.mvc.*; +import org.lamsfoundation.lams.common.style.*; import org.lamsfoundation.lams.common.util.*; -import org.lamsfoundation.lams.common.dict.*; 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.DesignDataModel; +import org.lamsfoundation.lams.authoring.SequenceActivity; import org.lamsfoundation.lams.authoring.cv.ICanvasActivity; -import org.lamsfoundation.lams.learner.ls.*; + import org.lamsfoundation.lams.learner.Application; -import org.lamsfoundation.lams.monitoring.mv.MonitorModel; +import org.lamsfoundation.lams.learner.ls.*; + import org.lamsfoundation.lams.monitoring.mv.MonitorController; +import org.lamsfoundation.lams.monitoring.mv.MonitorModel; import org.lamsfoundation.lams.monitoring.mv.tabviews.LearnerTabView; -import org.lamsfoundation.lams.monitoring.mv.tabviews.LessonTabView; -import org.lamsfoundation.lams.common.style. *; +import org.lamsfoundation.lams.monitoring.mv.tabviews.LessonTabView; import mx.controls. *; import mx.managers. *; /** -* CanvasOptionalActivity -* This is the UI / view representation of a complex (Optional) activity +* LearnerComplexActivity +* +* This class represents and controls the complex activity presentation in the Learner Progress Bar. +* The Progress Bar is displayed in the Learner application and in the Monitor application (Learner tab). +* +* A complex activity can have multiple children, this class displays the children of the complex activity (_activity) in a linear/vertical +* way with only the single level shown in the progress component. However, for any children of a complex type another instance of this class is +* nested to represent and control this child activity. +* +* This class is designed to handle multiple complex children and uses two local variables to identify the active ones for a Sequence Activity +* (_activeSequence) and Complex Activity (_activeComplex). +* +* */ class LearnerComplexActivity extends MovieClip implements ICanvasActivity { - private var CHILD_OFFSET_X : Number = 8; - private var CHILD_OFFSET_Y : Number = 57; - private var CHILD_INCRE : Number = 60; + private var CHILD_OFFSET_X:Number = 8; + private var CHILD_OFFSET_Y:Number = 57; + private var CHILD_INCRE:Number = 60; private var LABEL_W:Number = 130; private var LABEL_H:Number = 22; - //this is set by the init object + // Set by the init obj private var _controller:AbstractController; private var _view:AbstractView; private var _tip:ToolTip; - //Set by the init obj - private var _activity : Activity; - private var _children : Array; + // Set by the init obj - the complex/sequence activity and children array + private var _activity:Activity; + private var _children:Array; //refs to screen items: private var container_pnl:MovieClip; private var title_lbl:MovieClip; private var labelHolder_mc:MovieClip; - //locals private var actStatus:String; private var childActivities_mc : MovieClip; private var complexActivity_mc : MovieClip; @@ -98,20 +111,24 @@ private var _ddm:DesignDataModel; private var app:ApplicationParent; + // Identify if activity is nested inside another active LCA and at the depth level private var _nested:Boolean; private var _level:Number; private var _complexLevel:Number; + // Current active sequence/complex activities private var _activeSequence:SequenceActivity; private var _activeComplex:ComplexActivity; + // Map tracking of open, nested sequence/complex activities. private var activeSequenceMap:Hashtable; private var activeComplexMap:Hashtable; private var delegates:Array; private var _manualSelect:Boolean; private var lockedRefresh:Boolean; - + + /* Constructor */ function LearnerComplexActivity () { complexActivity_mc = this; @@ -141,6 +158,11 @@ init(); } + + /** + * Setup the components labels and events and start processing the children. + * + */ public function init():Void { var styleObj = _tm.getStyleObject('smallLabel'); @@ -157,6 +179,7 @@ showStatus(false); + // click target events clickTarget_mc.onRollOver = Proxy.create(this, localOnRollOver); clickTarget_mc.onRollOut = Proxy.create(this, localOnRollOut); clickTarget_mc.onPress = Proxy.create(this, localOnPress); @@ -173,15 +196,19 @@ childrenArray = _children; } + // draw the children and any nested LCA's createChildren(childrenArray); clearDelegates(); childHolder_mc._visible = (!_nested) ? false : true; } + /** + * Run through and call all the functions pushed to the delegates array for processing. + * Used to control the order of drawing the children when nested LCA's are open/active. + */ + private function clearDelegates():Void { - - // run delegates if(delegates.length > 0) { MovieClipUtils.doLater(Function(delegates.shift())); } else { @@ -192,15 +219,35 @@ MovieClipUtils.doLater(Proxy.create(this, clearDelegates)); } + /** + * Drawing the children activites in this complex object. + * + * @param _children Array of children activities + * @param index Index position to start iteration + */ + private function createChildren(_children:Array, index:Number):Void { var rIndex:Number = drawChildren(_children, index); + // rIndex returns not null the function needs to be set for later processing at the array position it had to halt. if(rIndex != null) delegates.push(Proxy.create(this, createChildren, _children, rIndex)); return; } + /** + * Main function for drawing the MovieClip to represent the chldren activity. Complex type children will create a nested LCA. + * Identifies when a active/open sequence (of Optional Sequence for example) is reached and halts for later processing, to control + * drawing order and timing. + * + * @param _children Array of children activities + * @param index Index position to start iteration + * + * @return The index location where the function had to halt due to inserting of a sequence or LCA (complex activity). + * + */ + private function drawChildren(_children:Array, index:Number):Number { var childCoordY:Number = 0; @@ -288,8 +335,10 @@ } /** - * @deprecated - */ + * Not currently in use due to a nested LCA being used to display the active Branch sequence. + * + * @deprecated + */ private function drawActiveBranch(learnerAct:LearnerActivity):Void { var _cChildren:Array = model.ddm.getComplexActivityChildren(learnerAct.activity.activityUIID); @@ -306,29 +355,27 @@ } } } + + /** + * Progress status of the complex activity. + * + * @usage + * @param isVisible + * @return + */ private function showStatus(isVisible:Boolean) { completed_mc._visible = isVisible; current_mc._visible = isVisible; attempted_mc._visible = isVisible; todo_mc._visible = isVisible; } - - public function get activity():Activity { - return getActivity(); - } - - public function set activity(a:Activity) { - setActivity(a); - } - - public function getActivity():Activity { - return _activity; - } - - public function setActivity(a:Activity) { - _activity = a; - } + + /** + * Refresh and redraw the complex component. + * + * @param _clear Set no active sequence/complex activities + */ public function refresh(_clear:Boolean) { if(lockedRefresh) return; @@ -345,6 +392,7 @@ delegates = new Array(); + // Not setting an activity active manually (mouse click) then check progress information for further branching or sequence activity updates. if(!_manualSelect) { checkIfBranchActive(); checkIfSequenceActive(); @@ -354,14 +402,25 @@ } + /** + * Checking if the Learner is currently attempting or completed a Branch. + * + */ + private function checkIfBranchActive():Void { for(var i=0; i