Index: lams_flash/src/central/flash/LoadQue.as =================================================================== diff -u -rd7823922f404944822957e6c051bc0f1335a76de -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/LoadQue.as (.../LoadQue.as) (revision d7823922f404944822957e6c051bc0f1335a76de) +++ lams_flash/src/central/flash/LoadQue.as (.../LoadQue.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,239 +1,239 @@ - -/** -****************************************** - - @class: LoadQue Class - @author: Kenneth Bunch (krb0723@hotmail.com) - - IMPLEMENTS - ASBroadcaster - - PUBLIC METHODS - addItem - clear - start - - PRIVATE METHODS - $preloadNext - $loadItem - $onItemData - $onTotalData - - EVENT - onItemData - onTotalData - onLoadFailure - onLoad - -****************************************** -*/ - - -/** - @class LoadQue -*/ - -import mx.events.* -import mx.utils.* - -class LoadQue { - - var _$que; - var _$root; - var _$index; - var _$currItem; - var _$interval; - var _$container; - var addEventListener:Function; - var dispatchEvent:Function; - //var broadcastMessage:Function; - - function LoadQue(container) { - this._$root = container; - this._$que = new Array(); - this._$container = new LoadVars(); - this._$index = 0; - this._$currItem = null; - this._$interval = null; - - EventDispatcher.initialize(this); - - this.addEventListener("onItemData", container); - this.addEventListener("onTotalData", container); - this.addEventListener("onLoadFailure", container); - this.addEventListener("onLoad", container); - } - - /** - @method (PRIVATE): $preloadNext - - @description - - preloads the next item in the que - */ - private function $preloadNext(){ - - var controller; - - controller = this; - this._$currItem = this._$que[this._$index++]; - this._$container.load(this._$currItem.url); - // monitor load of item - clearInterval(this._$interval); - // monitor immediately - this.$onItemData(); - // monitor on interval - this._$interval = setInterval(this, "$onItemData", 100); - // handle success or failure of complete load - this._$container.onLoad = function(bSuccess){ - controller.$onLoad(bSuccess); - }; - } - - - /** - @method (PRIVATE): $onItemData - - @description - - handles data as it is received for an item - */ - private function $onItemData(){ - - var itemPercent; - - itemPercent =Math.round(( this._$container.getBytesLoaded() / this._$container.getBytesTotal() )*100); - - if(!isNaN(itemPercent)){ - dispatchEvent({target:this, type:"onItemData", iPercent:itemPercent, sID:this._$currItem.id}); - //this.broadcastMessage("onItemData", itemPercent, this._$currItem.id); - } - } - - - /** - @method (PRIVATE): $onTotalData - - @description - - handles data as each item is completely loaded - */ - private function $onTotalData(){ - - var totalPercent; - - // report total percent loaded - totalPercent = Math.round((this._$index/this._$que.length) * 100); - - if (!isNaN(totalPercent)){ - dispatchEvent({target:this, type:"onTotalData", iPercent:totalPercent}); - //this.broadcastMessage("onTotalData", totalPercent); - } - }; - - - /** - @method (PRIVATE): $onLoad - - @description - - fired when all data for an item is loaded - */ - private function $onLoad(bSuccess){ - - clearInterval(this._$interval); - - if (bSuccess){ - // broadcast that item was loaded - this.$onItemData(); - // load the item - if (this._$currItem.item != null){ - this.$loadItem(); - } - } else { - // report non loaded items - dispatchEvent({target:this, type:"onLoadFailure", sID:this._$currItem.id}); - //this.broadcastMessage("onLoadFailure", this._$currItem.id); - } - - this.$onTotalData(); - - // que next or report completed preload - if ( this._$que.length > (this._$index) ){ - this.$preloadNext(); - } else{ - dispatchEvent({target:this, type:"onLoad"}); - //this.broadcastMessage("onLoad"); - } - } - - - /** - @method (PRIVATE): $loadItem - - @description - - loads current item into container - */ - public function $loadItem() { - // load item into assigned holder - if (typeof this._$currItem.item == "movieclip"){ - this._$currItem.item.loadMovie(this._$currItem.url); - } else if(this._$currItem.item instanceof Sound) { - this._$currItem.item.loadSound(this._$currItem.url,false) - } else { - this._$currItem.item.load(this._$currItem.url); - } - } - - /** - @method (PUBLIC): addItem - - @param : sUrl - - url of item to load - @param : [oTarget, sID] - - [OPTIONAL] target to load item into OR id to associate with item - @param : [sID] - - [OPTIONAL] id to be associated with item - - @description - - adds items to preload into movie - method is overload and can be passed args in the following combos - addItem(sUrl); - addItem(sUrl, oTarget); - addItem(sUrl, sID); - addItem(sUrl, oTarget, sID); - */ - public function addItem(sUrl){ - - var target, idString; - if (arguments.length < 3){ - target = (typeof arguments[1] != "string") ? arguments[1] : null; - idString = (typeof arguments[1] == "string") ? arguments[1] : this._$que.length+1; - } else{ - target = arguments[1]; - idString = (typeof arguments[2] != null) ? arguments[2] : this._$que.length+1; - } - this._$que.push({url:sUrl, item:target, id:idString}); - } - - - /** - @method (PUBLIC): clear - - @description - - clears the que - */ - public function clear(){ - - this._$que = new Array(); - this._$index = 0; - } - - /** - @method (PUBLIC): start - - @description - - starts loading the elements of the que - */ - public function start(){ - - this.$preloadNext(); - } - + +/** +****************************************** + + @class: LoadQue Class + @author: Kenneth Bunch (krb0723@hotmail.com) + + IMPLEMENTS + ASBroadcaster + + PUBLIC METHODS + addItem + clear + start + + PRIVATE METHODS + $preloadNext + $loadItem + $onItemData + $onTotalData + + EVENT + onItemData + onTotalData + onLoadFailure + onLoad + +****************************************** +*/ + + +/** + @class LoadQue +*/ + +import mx.events.* +import mx.utils.* + +class LoadQue { + + var _$que; + var _$root; + var _$index; + var _$currItem; + var _$interval; + var _$container; + var addEventListener:Function; + var dispatchEvent:Function; + //var broadcastMessage:Function; + + function LoadQue(container) { + this._$root = container; + this._$que = new Array(); + this._$container = new LoadVars(); + this._$index = 0; + this._$currItem = null; + this._$interval = null; + + EventDispatcher.initialize(this); + + this.addEventListener("onItemData", container); + this.addEventListener("onTotalData", container); + this.addEventListener("onLoadFailure", container); + this.addEventListener("onLoad", container); + } + + /** + @method (PRIVATE): $preloadNext + + @description + - preloads the next item in the que + */ + private function $preloadNext(){ + + var controller; + + controller = this; + this._$currItem = this._$que[this._$index++]; + this._$container.load(this._$currItem.url); + // monitor load of item + clearInterval(this._$interval); + // monitor immediately + this.$onItemData(); + // monitor on interval + this._$interval = setInterval(this, "$onItemData", 100); + // handle success or failure of complete load + this._$container.onLoad = function(bSuccess){ + controller.$onLoad(bSuccess); + }; + } + + + /** + @method (PRIVATE): $onItemData + + @description + - handles data as it is received for an item + */ + private function $onItemData(){ + + var itemPercent; + + itemPercent =Math.round(( this._$container.getBytesLoaded() / this._$container.getBytesTotal() )*100); + + if(!isNaN(itemPercent)){ + dispatchEvent({target:this, type:"onItemData", iPercent:itemPercent, sID:this._$currItem.id}); + //this.broadcastMessage("onItemData", itemPercent, this._$currItem.id); + } + } + + + /** + @method (PRIVATE): $onTotalData + + @description + - handles data as each item is completely loaded + */ + private function $onTotalData(){ + + var totalPercent; + + // report total percent loaded + totalPercent = Math.round((this._$index/this._$que.length) * 100); + + if (!isNaN(totalPercent)){ + dispatchEvent({target:this, type:"onTotalData", iPercent:totalPercent}); + //this.broadcastMessage("onTotalData", totalPercent); + } + }; + + + /** + @method (PRIVATE): $onLoad + + @description + - fired when all data for an item is loaded + */ + private function $onLoad(bSuccess){ + + clearInterval(this._$interval); + + if (bSuccess){ + // broadcast that item was loaded + this.$onItemData(); + // load the item + if (this._$currItem.item != null){ + this.$loadItem(); + } + } else { + // report non loaded items + dispatchEvent({target:this, type:"onLoadFailure", sID:this._$currItem.id}); + //this.broadcastMessage("onLoadFailure", this._$currItem.id); + } + + this.$onTotalData(); + + // que next or report completed preload + if ( this._$que.length > (this._$index) ){ + this.$preloadNext(); + } else{ + dispatchEvent({target:this, type:"onLoad"}); + //this.broadcastMessage("onLoad"); + } + } + + + /** + @method (PRIVATE): $loadItem + + @description + - loads current item into container + */ + public function $loadItem() { + // load item into assigned holder + if (typeof this._$currItem.item == "movieclip"){ + this._$currItem.item.loadMovie(this._$currItem.url); + } else if(this._$currItem.item instanceof Sound) { + this._$currItem.item.loadSound(this._$currItem.url,false) + } else { + this._$currItem.item.load(this._$currItem.url); + } + } + + /** + @method (PUBLIC): addItem + + @param : sUrl + - url of item to load + @param : [oTarget, sID] + - [OPTIONAL] target to load item into OR id to associate with item + @param : [sID] + - [OPTIONAL] id to be associated with item + + @description + - adds items to preload into movie + method is overload and can be passed args in the following combos + addItem(sUrl); + addItem(sUrl, oTarget); + addItem(sUrl, sID); + addItem(sUrl, oTarget, sID); + */ + public function addItem(sUrl){ + + var target, idString; + if (arguments.length < 3){ + target = (typeof arguments[1] != "string") ? arguments[1] : null; + idString = (typeof arguments[1] == "string") ? arguments[1] : this._$que.length+1; + } else{ + target = arguments[1]; + idString = (typeof arguments[2] != null) ? arguments[2] : this._$que.length+1; + } + this._$que.push({url:sUrl, item:target, id:idString}); + } + + + /** + @method (PUBLIC): clear + + @description + - clears the que + */ + public function clear(){ + + this._$que = new Array(); + this._$index = 0; + } + + /** + @method (PUBLIC): start + + @description + - starts loading the elements of the que + */ + public function start(){ + + this.$preloadNext(); + } + } \ No newline at end of file Index: lams_flash/src/central/flash/main.as =================================================================== diff -u -r470bd43cd17fa6128a767fec948850a5815c1c55 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/main.as (.../main.as) (revision 470bd43cd17fa6128a767fec948850a5815c1c55) +++ lams_flash/src/central/flash/main.as (.../main.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,104 +1,104 @@ -import org.lamsfoundation.lams.authoring.Application; -import org.lamsfoundation.lams.common.util.StringUtils; - -_global.myRoot = this; -this._lockroot = true; - -//Temp values to be removed / repplaced at deployment -/**/ -if(StringUtils.isEmpty(serverURL)){ - _root.serverURL = "http://localhost:8080/lams/"; - Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(userID)){ - _root.userID = 4; - Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(version)){ - _root.version = "undefined"; - Debugger.log('version is not defined.', Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(mode)){ - _root.mode = 1; - Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(layout)){ - _root.layout = "normal"; - Debugger.log('Mode is not defined, using default:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(direction)){ - _root.direction = "LTR"; - Debugger.log('Direction is not defined, using default:'+_root.direction,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(learningDesignID)){ - _root.learningDesignID = null; - Debugger.log('LearningDesignID is not defined, using default:'+_root.learningDesignID,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(lang)){ - _root.lang = "en"; -} - -if(StringUtils.isEmpty(country)){ - _root.country = undefined; -} - -if(StringUtils.isEmpty(build)){ - _root.build = "2.0"; -} - -if(StringUtils.isEmpty(uniqueID)){ - _root.uniqueID = 0; - Debugger.log('Unique ID is not defined.',Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(langDate)){ - _root.langDate = "01-01-1970"; -} - -if(StringUtils.isEmpty(actColour)){ - _root.actColour = "true"; -} - -if(StringUtils.isEmpty(requestSrc)) { - _root.requestSrc = null; -} - -if(StringUtils.isEmpty(isMac)) { - _root.isMac = false; -} - -if(StringUtils.isEmpty(extlmsid)) { - _root.extlmsid = null; -} - -if(StringUtils.isEmpty(customCSV)) { - _root.customCSV = null; -} - -//Set stage alignment to top left and prevent scaling -Stage.align = "TL"; -Stage.scaleMode = "noScale"; - -//Start the application, passing in the top level clip, i.e. _root -var app:Application = Application.getInstance(); -app.main(this); - -//------------------------------Local connection to JSPs for progress data ------------------------------ -var receive_lc = new LocalConnection(); -//-------------------------------------- Functions to setProgress data, called by the LocalConnection object in learner JSPs -receive_lc.setImportDesign = function(learningDesignID, refresh) { - Debugger.log(arguments.toString(), 'importUpdate_lc.setImportDesign'); - app.getCanvas().openDesignByImport(learningDesignID); - myRoot.refresh; -}; -var success = receive_lc.connect("importUpdate_lc_" + uniqueID); - -//Make app listener for stage resize events -Stage.addListener(app); +import org.lamsfoundation.lams.authoring.Application; +import org.lamsfoundation.lams.common.util.StringUtils; + +_global.myRoot = this; +this._lockroot = true; + +//Temp values to be removed / repplaced at deployment +/**/ +if(StringUtils.isEmpty(serverURL)){ + _root.serverURL = "http://localhost:8080/lams/"; + Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(userID)){ + _root.userID = 4; + Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(version)){ + _root.version = "undefined"; + Debugger.log('version is not defined.', Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(mode)){ + _root.mode = 1; + Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(layout)){ + _root.layout = "normal"; + Debugger.log('Mode is not defined, using default:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(direction)){ + _root.direction = "LTR"; + Debugger.log('Direction is not defined, using default:'+_root.direction,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(learningDesignID)){ + _root.learningDesignID = null; + Debugger.log('LearningDesignID is not defined, using default:'+_root.learningDesignID,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(lang)){ + _root.lang = "en"; +} + +if(StringUtils.isEmpty(country)){ + _root.country = undefined; +} + +if(StringUtils.isEmpty(build)){ + _root.build = "2.0"; +} + +if(StringUtils.isEmpty(uniqueID)){ + _root.uniqueID = 0; + Debugger.log('Unique ID is not defined.',Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(langDate)){ + _root.langDate = "01-01-1970"; +} + +if(StringUtils.isEmpty(actColour)){ + _root.actColour = "true"; +} + +if(StringUtils.isEmpty(requestSrc)) { + _root.requestSrc = null; +} + +if(StringUtils.isEmpty(isMac)) { + _root.isMac = false; +} + +if(StringUtils.isEmpty(extlmsid)) { + _root.extlmsid = null; +} + +if(StringUtils.isEmpty(customCSV)) { + _root.customCSV = null; +} + +//Set stage alignment to top left and prevent scaling +Stage.align = "TL"; +Stage.scaleMode = "noScale"; + +//Start the application, passing in the top level clip, i.e. _root +var app:Application = Application.getInstance(); +app.main(this); + +//------------------------------Local connection to JSPs for progress data ------------------------------ +var receive_lc = new LocalConnection(); +//-------------------------------------- Functions to setProgress data, called by the LocalConnection object in learner JSPs +receive_lc.setImportDesign = function(learningDesignID, refresh) { + Debugger.log(arguments.toString(), 'importUpdate_lc.setImportDesign'); + app.getCanvas().openDesignByImport(learningDesignID); + myRoot.refresh; +}; +var success = receive_lc.connect("importUpdate_lc_" + uniqueID); + +//Make app listener for stage resize events +Stage.addListener(app); Index: lams_flash/src/central/flash/main2.as =================================================================== diff -u -rdeab1a0aef578ae38f893dd99735fd61cbb85936 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/main2.as (.../main2.as) (revision deab1a0aef578ae38f893dd99735fd61cbb85936) +++ lams_flash/src/central/flash/main2.as (.../main2.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,98 +1,98 @@ -import org.lamsfoundation.lams.learner.Application; -import org.lamsfoundation.lams.common.util.StringUtils; -import com.macromedia.javascript.JavaScriptProxy; -import org.lamsfoundation.lams.common.util.Debugger; - -// Temp values to be removed / repplaced at deployment -_global.myRoot = this; - -if(StringUtils.isEmpty(lcId)){ - Debugger.log('lcId is not defined, actionscript will not be able to communicate with javascript',Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(presenceServerUrl)){ - _root.presenceServerUrl = "192.168.1.1"; - Debugger.log('presenceServerUrl is not defined, using defualt:'+_root.presenceServerUrl ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(serverURL)){ - _root.serverURL = "http://localhost:8080/lams/"; - Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(userID)){ - _root.userID = 4; - Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(firstName)){ - _root.firstName = "firstName"; - Debugger.log('firstName is not defined, using defualt:'+_root.firstName ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(lastName)){ - _root.lastName = "lastName"; - Debugger.log('lastName is not defined, using defualt:'+_root.lastName ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(mode)){ - _root.mode = 1; - Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(lessonID)){ - _root.lessonID = 1; - Debugger.log('Lesson ID is not defined, using defualt:'+_root.lessonID,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(uniqueID)){ - _root.uniqueID = 0; - Debugger.log('Unique ID is not defined.',Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(langDate)){ - _root.langDate = "01-01-1970"; -} - -Debugger.log("PRESENCE: connection info from controlFrame - " + userID + " " + firstName + " " + lastName + " " + presenceServerUrl, Debugger.MED,'main','ROOT'); - -//Set stage alignment to top left and prent scaling -Stage.align = "TL"; -Stage.scaleMode = "noScale"; - - -//Start the application, passing in the top level clip, i.e. _root -var app:Application = Application.getInstance(); -app.main(this); - -//Local connection to JSPs for progress data -var receive_lc = new LocalConnection(); -//Functions to setProgress data, called by the LocalConnection object in learner JSPs -receive_lc.setProgressData = function(attempted, completed, current, lessonID, version, refresh) { - Debugger.log(arguments.toString(), Debugger.CRITICAL, 'learnerProgress_lc.setProgressData', 'ROOT'); - app.refreshProgress(attempted, completed, current, lessonID, version); - myRoot.refresh = refresh; -}; - -var success = receive_lc.connect("learnerProgress_lc_" + uniqueID); - -//Declaration of proxy object for javascript integration kit -var proxy:JavaScriptProxy = new JavaScriptProxy(_root.lcId, this); -_root.proxy = proxy; - -function sendMessageToFlash(msg:String){ - Debugger.log("PRESENCE: from javascript - " + msg, Debugger.MED, 'sendMessageToFlash', 'ROOT'); -} - -function attemptRegistration(){ - Debugger.log("PRESENCE: registration caught in main", Debugger.MED, 'sendMessageToFlash', 'ROOT'); - app.getPresence().attemptRegistration(); -} - -function sendUsersToFlash(users:Array){ - Debugger.log('PRESENCE: ' + users, Debugger.MED, 'sendUsersToFlash', 'ROOT'); - app.getPresence().setupDataGrid(users); -} - -//Make app listener for stage resize events -Stage.addListener(app); +import org.lamsfoundation.lams.learner.Application; +import org.lamsfoundation.lams.common.util.StringUtils; +import com.macromedia.javascript.JavaScriptProxy; +import org.lamsfoundation.lams.common.util.Debugger; + +// Temp values to be removed / repplaced at deployment +_global.myRoot = this; + +if(StringUtils.isEmpty(lcId)){ + Debugger.log('lcId is not defined, actionscript will not be able to communicate with javascript',Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(presenceServerUrl)){ + _root.presenceServerUrl = "192.168.1.1"; + Debugger.log('presenceServerUrl is not defined, using defualt:'+_root.presenceServerUrl ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(serverURL)){ + _root.serverURL = "http://localhost:8080/lams/"; + Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(userID)){ + _root.userID = 4; + Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(firstName)){ + _root.firstName = "firstName"; + Debugger.log('firstName is not defined, using defualt:'+_root.firstName ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(lastName)){ + _root.lastName = "lastName"; + Debugger.log('lastName is not defined, using defualt:'+_root.lastName ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(mode)){ + _root.mode = 1; + Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(lessonID)){ + _root.lessonID = 1; + Debugger.log('Lesson ID is not defined, using defualt:'+_root.lessonID,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(uniqueID)){ + _root.uniqueID = 0; + Debugger.log('Unique ID is not defined.',Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(langDate)){ + _root.langDate = "01-01-1970"; +} + +Debugger.log("PRESENCE: connection info from controlFrame - " + userID + " " + firstName + " " + lastName + " " + presenceServerUrl, Debugger.MED,'main','ROOT'); + +//Set stage alignment to top left and prent scaling +Stage.align = "TL"; +Stage.scaleMode = "noScale"; + + +//Start the application, passing in the top level clip, i.e. _root +var app:Application = Application.getInstance(); +app.main(this); + +//Local connection to JSPs for progress data +var receive_lc = new LocalConnection(); +//Functions to setProgress data, called by the LocalConnection object in learner JSPs +receive_lc.setProgressData = function(attempted, completed, current, lessonID, version, refresh) { + Debugger.log(arguments.toString(), Debugger.CRITICAL, 'learnerProgress_lc.setProgressData', 'ROOT'); + app.refreshProgress(attempted, completed, current, lessonID, version); + myRoot.refresh = refresh; +}; + +var success = receive_lc.connect("learnerProgress_lc_" + uniqueID); + +//Declaration of proxy object for javascript integration kit +var proxy:JavaScriptProxy = new JavaScriptProxy(_root.lcId, this); +_root.proxy = proxy; + +function sendMessageToFlash(msg:String){ + Debugger.log("PRESENCE: from javascript - " + msg, Debugger.MED, 'sendMessageToFlash', 'ROOT'); +} + +function attemptRegistration(){ + Debugger.log("PRESENCE: registration caught in main", Debugger.MED, 'sendMessageToFlash', 'ROOT'); + app.getPresence().attemptRegistration(); +} + +function sendUsersToFlash(users:Array){ + Debugger.log('PRESENCE: ' + users, Debugger.MED, 'sendUsersToFlash', 'ROOT'); + app.getPresence().setupDataGrid(users); +} + +//Make app listener for stage resize events +Stage.addListener(app); Index: lams_flash/src/central/flash/main_addseq.as =================================================================== diff -u -rd7823922f404944822957e6c051bc0f1335a76de -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/main_addseq.as (.../main_addseq.as) (revision d7823922f404944822957e6c051bc0f1335a76de) +++ lams_flash/src/central/flash/main_addseq.as (.../main_addseq.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,57 +1,57 @@ -import org.lamsfoundation.lams.wizard.Application; -import org.lamsfoundation.lams.common.util.StringUtils; - -//Temp values to be removed / repplaced at deployment -/**/ -if(StringUtils.isEmpty(serverURL)){ - //_root.serverURL = "http://dolly.uklams.net:8080/lams/"; - //_root.serverURL = "http://shaun.melcoe.mq.edu.au:8080/lams/"; - _root.serverURL = "http://localhost:8080/lams/"; - Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(userID)){ - _root.userID = 4; - Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(mode)){ - _root.mode = 2; - Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(courseID)){ - _root.courseID = undefined; // Playpen (test) - Debugger.log('CourseID is not defined, using defualt:'+_root.courseID,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(classID)){ - _root.classID = undefined; // Playpen (test) - Debugger.log('ClassID is not defined, using defualt:'+_root.classID,Debugger.CRITICAL,'main','ROOT'); -} - - -if(StringUtils.isEmpty(build)){ - _root.build = 2.0; - Debugger.log('Build is not defined, using defualt:'+_root.build,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(langDate)){ - _root.langDate = "01-01-1970"; -} - -//Set stage alignment to top left and prent scaling -Stage.align = "TL"; -Stage.scaleMode = "noScale"; - - -//Start the application, passing in the top level clip, i.e. _root -var app:Application = Application.getInstance(); -app.main(this); - -//Make app listener for stage resize events -Stage.addListener(app); - - - - +import org.lamsfoundation.lams.wizard.Application; +import org.lamsfoundation.lams.common.util.StringUtils; + +//Temp values to be removed / repplaced at deployment +/**/ +if(StringUtils.isEmpty(serverURL)){ + //_root.serverURL = "http://dolly.uklams.net:8080/lams/"; + //_root.serverURL = "http://shaun.melcoe.mq.edu.au:8080/lams/"; + _root.serverURL = "http://localhost:8080/lams/"; + Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(userID)){ + _root.userID = 4; + Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(mode)){ + _root.mode = 2; + Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(courseID)){ + _root.courseID = undefined; // Playpen (test) + Debugger.log('CourseID is not defined, using defualt:'+_root.courseID,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(classID)){ + _root.classID = undefined; // Playpen (test) + Debugger.log('ClassID is not defined, using defualt:'+_root.classID,Debugger.CRITICAL,'main','ROOT'); +} + + +if(StringUtils.isEmpty(build)){ + _root.build = 2.0; + Debugger.log('Build is not defined, using defualt:'+_root.build,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(langDate)){ + _root.langDate = "01-01-1970"; +} + +//Set stage alignment to top left and prent scaling +Stage.align = "TL"; +Stage.scaleMode = "noScale"; + + +//Start the application, passing in the top level clip, i.e. _root +var app:Application = Application.getInstance(); +app.main(this); + +//Make app listener for stage resize events +Stage.addListener(app); + + + + Index: lams_flash/src/central/flash/main_monitoring.as =================================================================== diff -u -rd7823922f404944822957e6c051bc0f1335a76de -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/main_monitoring.as (.../main_monitoring.as) (revision d7823922f404944822957e6c051bc0f1335a76de) +++ lams_flash/src/central/flash/main_monitoring.as (.../main_monitoring.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,65 +1,65 @@ -import org.lamsfoundation.lams.monitoring.Application; -import org.lamsfoundation.lams.common.util.StringUtils; -import org.lamsfoundation.lams.common.util.Debugger; -//Temp values to be removed / repplaced at deployment -/**/ -if(StringUtils.isEmpty(serverURL)){ - //_root.serverURL = "http://dolly.uklams.net:8080/lams/"; - _root.serverURL = "http://localhost:8080/lams/"; - Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(userID)){ - _root.userID = 4; - Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); -} -Debugger.log('lesson launch is set as:'+_root.lessonLaunch ,Debugger.CRITICAL,'main','ROOT'); - -if (StringUtils.isEmpty(lessonLaunch)){ - _root.lessonLaunch = false; - Debugger.log('lesson launch is set as:'+_root.lessonLaunch ,Debugger.CRITICAL,'mainin if condition','ROOT'); -} -if (StringUtils.isEmpty(editOnFly)){ - _root.editOnFly = false; - Debugger.log('editOnFly is set as:'+_root.editOnFly ,Debugger.CRITICAL,'mainin if condition','ROOT'); -} -if(StringUtils.isEmpty(mode)){ - _root.mode = 1; - Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(version)){ - _root.version = "undefined"; - Debugger.log('version is not defined.', Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(lessonID)){ - _root.lessonID = 1; - Debugger.log('LessonID is not defined, using defualt:'+_root.lessonID,Debugger.CRITICAL,'main','ROOT'); -} - -if(StringUtils.isEmpty(langDate)){ - _root.langDate = "01-01-1970"; -} - -if(StringUtils.isEmpty(actColour)){ - _root.actColour = "true"; -} - -_root.monitoringURL = "monitoring/monitoring.do?method=" - -//Set stage alignment to top left and prent scaling -Stage.align = "TL"; -Stage.scaleMode = "noScale"; - - -//Start the application, passing in the top level clip, i.e. _root -var app:Application = Application.getInstance(); -app.main(this); - -//Make app listener for stage resize events -Stage.addListener(app); - - - - +import org.lamsfoundation.lams.monitoring.Application; +import org.lamsfoundation.lams.common.util.StringUtils; +import org.lamsfoundation.lams.common.util.Debugger; +//Temp values to be removed / repplaced at deployment +/**/ +if(StringUtils.isEmpty(serverURL)){ + //_root.serverURL = "http://dolly.uklams.net:8080/lams/"; + _root.serverURL = "http://localhost:8080/lams/"; + Debugger.log('serverURL is not defined, using defualt:'+_root.serverURL ,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(userID)){ + _root.userID = 4; + Debugger.log('userID is not defined, using defualt:'+_root.userID ,Debugger.CRITICAL,'main','ROOT'); +} +Debugger.log('lesson launch is set as:'+_root.lessonLaunch ,Debugger.CRITICAL,'main','ROOT'); + +if (StringUtils.isEmpty(lessonLaunch)){ + _root.lessonLaunch = false; + Debugger.log('lesson launch is set as:'+_root.lessonLaunch ,Debugger.CRITICAL,'mainin if condition','ROOT'); +} +if (StringUtils.isEmpty(editOnFly)){ + _root.editOnFly = false; + Debugger.log('editOnFly is set as:'+_root.editOnFly ,Debugger.CRITICAL,'mainin if condition','ROOT'); +} +if(StringUtils.isEmpty(mode)){ + _root.mode = 1; + Debugger.log('Mode is not defined, using defualt:'+_root.mode,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(version)){ + _root.version = "undefined"; + Debugger.log('version is not defined.', Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(lessonID)){ + _root.lessonID = 1; + Debugger.log('LessonID is not defined, using defualt:'+_root.lessonID,Debugger.CRITICAL,'main','ROOT'); +} + +if(StringUtils.isEmpty(langDate)){ + _root.langDate = "01-01-1970"; +} + +if(StringUtils.isEmpty(actColour)){ + _root.actColour = "true"; +} + +_root.monitoringURL = "monitoring/monitoring.do?method=" + +//Set stage alignment to top left and prent scaling +Stage.align = "TL"; +Stage.scaleMode = "noScale"; + + +//Start the application, passing in the top level clip, i.e. _root +var app:Application = Application.getInstance(); +app.main(this); + +//Make app listener for stage resize events +Stage.addListener(app); + + + + Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Activity.as =================================================================== diff -u -r5b44cd0646c0ee06e57059948a5d5f730040f431 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Activity.as (.../Activity.as) (revision 5b44cd0646c0ee06e57059948a5d5f730040f431) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Activity.as (.../Activity.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,805 +1,805 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.authoring.br.CanvasBranchView; -import org.lamsfoundation.lams.common.dict.* -import org.lamsfoundation.lams.common.* -import org.lamsfoundation.lams.common.util.* - -/* -*Activity Data storage class. USed as a base class for extending to be Tool, Gate and Complex -*

-* 
-/**
-	 * static final variables indicating the type of activities
-	 * available for a LearningDesign 
-	******************************************************************
-	public static var TOOL_ACTIVITY_TYPE:Number = 1;
-	public static var GROUPING_ACTIVITY_TYPE:Number = 2;
-	public static var NO_GATE_ACTIVITY_TYPE:Number = 30
-	public static var SYNCH_GATE_ACTIVITY_TYPE:Number = 3;
-	public static var SCHEDULE_GATE_ACTIVITY_TYPE:Number = 4;
-	public static var PERMISSION_GATE_ACTIVITY_TYPE:Number = 5;
-	public static var PARALLEL_ACTIVITY_TYPE:Number = 6;
-	public static var OPTIONAL_ACTIVITY_TYPE:Number = 7;
-	public static var SEQUENCE_ACTIVITY_TYPE:Number = 8;
-	public static var SYSTEM_GATE_ACTIVITY_TYPE:Number = 9;
-	public static var CHOSEN_BRANCHING_ACTIVITY_TYPE:Number = 10;
-	public static var GROUP_BRANCHING_ACTIVITY_TYPE:Number = 11;
-	public static var TOOL_BRANCHING_ACTIVITY_TYPE:Number = 12;
-	public static var OPTIONS_WITH_SEQUENCES_TYPE:Number = 13; 
-	
-	/******************************************************************
-	
-	/**
-	* static final variables indicating the the category of activities
-    *******************************************************************
-	public static var CATEGORY_SYSTEM:Number = 1;
-	public static var CATEGORY_COLLABORATION:Number = 2;
-	public static var CATEGORY_ASSESSMENT:Number = 3;
-	public static var CATEGORY_CONTENT:Number = 4;
-	public static var CATEGORY_SPLIT:Number = 5;
-	/******************************************************************
-	
-	
-	/**
-	 * static final variables indicating the grouping_support of activities
-	 *******************************************************************
-	 public static var GROUPING_SUPPORT_NONE:Number = 1;
-	 public static var GROUPING_SUPPORT_OPTIONAL:Number = 2;
-	 public static var GROUPING_SUPPORT_REQUIRED:Number = 3;
-	/******************************************************************
-
-* 
-* -* @author DC -* @version 2.1 -*/ -class org.lamsfoundation.lams.authoring.Activity { - - /* - //--------------------------------------------------------------------- - // Class Level Constants - //--------------------------------------------------------------------- - /** - * static final variables indicating the type of activities - * available for a LearningDesign - ******************************************************************/ - public static var TOOL_ACTIVITY_TYPE:Number = 1; - public static var GROUPING_ACTIVITY_TYPE:Number = 2; - public static var NO_GATE_ACTIVITY_TYPE:Number = 30 - public static var SYNCH_GATE_ACTIVITY_TYPE:Number = 3; - public static var SCHEDULE_GATE_ACTIVITY_TYPE:Number = 4; - public static var PERMISSION_GATE_ACTIVITY_TYPE:Number = 5; - public static var PARALLEL_ACTIVITY_TYPE:Number = 6; - public static var OPTIONAL_ACTIVITY_TYPE:Number = 7; - public static var SEQUENCE_ACTIVITY_TYPE:Number = 8; - public static var SYSTEM_GATE_ACTIVITY_TYPE:Number = 9; - public static var CHOSEN_BRANCHING_ACTIVITY_TYPE:Number = 10; - public static var GROUP_BRANCHING_ACTIVITY_TYPE:Number = 11; - public static var TOOL_BRANCHING_ACTIVITY_TYPE:Number = 12; - public static var OPTIONS_WITH_SEQUENCES_TYPE:Number = 13; - - /******************************************************************/ - - /** - * static final variables indicating the the category of activities - *******************************************************************/ - public static var CATEGORY_SYSTEM:Number = 1; - public static var CATEGORY_COLLABORATION:Number = 2; - public static var CATEGORY_ASSESSMENT:Number = 3; - public static var CATEGORY_CONTENT:Number = 4; - public static var CATEGORY_SPLIT:Number = 5; - /******************************************************************/ - - - /** - * static final variables indicating the grouping_support of activities - *******************************************************************/ - public static var GROUPING_SUPPORT_NONE:Number = 1; - public static var GROUPING_SUPPORT_OPTIONAL:Number = 2; - public static var GROUPING_SUPPORT_REQUIRED:Number = 3; - /******************************************************************/ - - //Activity Properties: - // * indicates required field - //--------------------------------------------------------------------- - // Instance variables - //--------------------------------------------------------------------- - - private var _objectType:String; //* - private var _activityTypeID:Number; //* - - - private var _activityID:Number; - private var _activityCategoryID:Number; //* - - private var _activityUIID:Number; //* - - private var _learningLibraryID:Number; //* - - private var _learningDesignID:Number; - private var _libraryActivityID:Number; - - private var _parentActivityID:Number; - private var _parentUIID:Number; - - - private var _orderID:Number; - - private var _groupingID:Number; - private var _groupingUIID:Number; - private var _isActivitySelected:String - - - private var _title:String; //* - private var _description:String; //* - private var _helpText:String; - private var _xCoord:Number; - private var _yCoord:Number; - private var _libraryActivityUIImage:String; - private var _applyGrouping:Boolean; - private var _activityToolContentID:Number; - - private var _runOffline:Boolean; - private var _defineLater:Boolean; - private var _createDateTime:Date; - - private var _groupingSupportType:Number; //* - - private var _stopAfterActivity:Boolean; - private var _readOnly:Boolean; - - private var _viewID:Boolean; - - private var _branchView:CanvasBranchView; - - /** - * Constructor - * - * Creates an activity with the minimum of fields. - * - * @param activityUIID - */ - function Activity(activityUIID:Number){ - Debugger.log('activityUIID:'+activityUIID,Debugger.GEN,'constructor','Activity'); - _activityUIID = activityUIID; - - //defaults - _objectType = "Activity"; - _applyGrouping = false; - _stopAfterActivity = false; - _runOffline = false; - _defineLater = false; - _readOnly = false; - _createDateTime = new Date(); - _branchView = null; - - } - - //static class level methods - - /** - * Created an array of activity types to be can be used as a dataprovider - * @usage - * @return - */ - public static function getGateActivityTypes():Array{ - var types:Array = []; - types.addItem({label: Dictionary.getValue('synch_act_lbl'), data: SYNCH_GATE_ACTIVITY_TYPE}); - types.addItem({label: Dictionary.getValue('sched_act_lbl'), data: SCHEDULE_GATE_ACTIVITY_TYPE}); - types.addItem({label: Dictionary.getValue('perm_act_lbl'), data: PERMISSION_GATE_ACTIVITY_TYPE}); - return types; - } - - /** - * Created an array of activity types to be can be used as a dataprovider - * @usage - * @return - */ - public static function getBranchingActivityTypes():Array{ - var types:Array = []; - types.addItem({label: Dictionary.getValue('chosen_branch_act_lbl'), data: CHOSEN_BRANCHING_ACTIVITY_TYPE}); - types.addItem({label: Dictionary.getValue('group_branch_act_lbl'), data: GROUP_BRANCHING_ACTIVITY_TYPE}); - types.addItem({label: Dictionary.getValue('tool_branch_act_lbl'), data: TOOL_BRANCHING_ACTIVITY_TYPE}); - return types; - } - - - //helper methods - - public function isGateActivity():Boolean{ - if (_activityTypeID == SYNCH_GATE_ACTIVITY_TYPE){ - return true; - }else if(_activityTypeID == SCHEDULE_GATE_ACTIVITY_TYPE){ - return true - }else if (_activityTypeID == PERMISSION_GATE_ACTIVITY_TYPE){ - return true; - }else if (_activityTypeID == SYSTEM_GATE_ACTIVITY_TYPE){ - return true; - }else{ - return false; - } - } - - public function isSystemGateActivity():Boolean{ - return _activityTypeID == SYSTEM_GATE_ACTIVITY_TYPE; - } - - public function isGroupActivity():Boolean{ - return (_activityTypeID == GROUPING_ACTIVITY_TYPE); - } - - public function isOptionalActivity():Boolean{ - return (_activityTypeID == OPTIONAL_ACTIVITY_TYPE); - } - - public function isOptionsWithSequencesActivity():Boolean { - return (_activityTypeID == OPTIONS_WITH_SEQUENCES_TYPE); - } - - public function isOptionalSequenceActivity(parent:Activity):Boolean { - return (this.isSequenceActivity() && parent.isOptionsWithSequencesActivity()); - } - - public function isParallelActivity():Boolean{ - return (_activityTypeID == PARALLEL_ACTIVITY_TYPE); - } - - public function isBranchingActivity():Boolean{ - return (_activityTypeID == CHOSEN_BRANCHING_ACTIVITY_TYPE || - _activityTypeID == GROUP_BRANCHING_ACTIVITY_TYPE || - _activityTypeID == TOOL_BRANCHING_ACTIVITY_TYPE); - } - - public function isSequenceActivity():Boolean{ - return _activityTypeID == SEQUENCE_ACTIVITY_TYPE; - } - - /** - * Populates all the fields in this activity from a dto object contaning the following fields - * NB: This is not very clever, if the field in the dto is blank then the value is overwritten in the class... - *
-
-			//activity properties:
-			_activityTypeID = dto.activityTypeID;
-			_activityID = dto.activityID;
-			_activityCategoryID = dto.activityCategoryID;
-			_activityUIID = dto.activityUIID;
-			_learningLibraryID = dto.learningLibraryID;
-			_learningDesignID = dto.learningDesignID;
-			_libraryActivityID = dto.libraryActivityID;
-			_parentActivityID = dto.parentActivityID;
-			_parentUIID = dto.parentUIID
-			_orderID = dto.orderID
-			_groupingID = dto.groupingID;
-			_groupingUIID = dto.groupingUIID
-			_title = dto.title;
-			_description = dto.description;
-			_helpText =  dto.helpText;
-			_yCoord = dto.yCoord;
-			_xCoord = dto.xCoord;
-			_libraryActivityUIImage = dto.libraryActivityUIImage;
-			_applyGrouping = dto.applyGrouping;
-			_runOffline = dto.runOffline;
-			_defineLater = dto.defineLater;
-			_createDateTime = dto.createDateTime;
-			_groupingSupportType = dto.groupingSupportType;
-			_readOnly = dto.readOnly;
-			_stopAfterActivity = dto.stopAfterActivity;
-		
- * - * - * @usage - * @param dto //the dto containing these fields - * @return - */ - public function populateFromDTO(dto:Object){ - - //activity properties: - _activityTypeID = dto.activityTypeID; - _activityID = dto.activityID; - _activityCategoryID = dto.activityCategoryID; - _activityUIID = dto.activityUIID; - _learningLibraryID = dto.learningLibraryID; - _learningDesignID = dto.learningDesignID; - _libraryActivityID = dto.libraryActivityID; - - if(StringUtils.isWDDXNull(dto.parentActivityID)) { _parentActivityID = null } - else { _parentActivityID = dto.parentActivityID; } - - if(StringUtils.isWDDXNull(dto.parentUIID)) {_parentUIID = null } - else { _parentUIID = dto.parentUIID} - - _orderID = dto.orderID - _groupingID = dto.groupingID; - _groupingUIID = dto.groupingUIID - _title = dto.activityTitle; - _description = dto.description; - _helpText = dto.helpText; - _yCoord = dto.yCoord; - _xCoord = dto.xCoord; - _libraryActivityUIImage = dto.libraryActivityUIImage; - _applyGrouping = (dto.applyGrouping) ? dto.applyGrouping : false; - _runOffline = (dto.runOffline) ? dto.runOffline : false; - _defineLater = (dto.defineLater) ? dto.defineLater : false; - _createDateTime = dto.createDateTime; - _groupingSupportType = dto.groupingSupportType; - _readOnly = (dto.readOnly) ? dto.readOnly : false; - _stopAfterActivity = (dto.stopAfterActivity) ? dto.stopAfterActivity : false; - - } - - public function toData(){ - var dto:Object = new Object(); - - //DC - Changed mode of toData to be omiting fields with undefined values - if(_activityTypeID){ dto.activityTypeID = _activityTypeID; } - if(_activityID){ dto.activityID = _activityID; } - if(_activityCategoryID){ dto.activityCategoryID = _activityCategoryID; } - if(_activityUIID){ dto.activityUIID = _activityUIID; } - if(_learningLibraryID){ dto.learningLibraryID = _learningLibraryID; } - if(_learningDesignID){ dto.learningDesignID = _learningDesignID; } - if(_libraryActivityID){ dto.libraryActivityID = _libraryActivityID; } - if(_orderID){ dto.orderID = _orderID; } - if(_groupingID){ dto.groupingID = _groupingID; } - if(_groupingUIID){ dto.groupingUIID = _groupingUIID; } - if(_title){ dto.activityTitle = _title; } - if(_description){ dto.description = _description; } - if(_helpText){ dto.helpText = _helpText; } - if(_yCoord){ dto.yCoord = _yCoord; } - if(_xCoord){ dto.xCoord = _xCoord; } - if(_libraryActivityUIImage){dto.libraryActivityUIImage= _libraryActivityUIImage;} - - dto.parentUIID = (_parentUIID==null) ? Config.NUMERIC_NULL_VALUE : _parentUIID; - dto.parentActivityID = (_parentActivityID==null) ? Config.NUMERIC_NULL_VALUE : _parentActivityID; - - //bools need to be included - so do as follows: - dto.applyGrouping = (_applyGrouping==null) ? false : _applyGrouping; - dto.runOffline = (_runOffline==null) ? false : _runOffline; - - if(isBranchingActivity()) - if(_activityTypeID == GROUP_BRANCHING_ACTIVITY_TYPE) - dto.defineLater = (_defineLater==null) ? false : _defineLater; - else - dto.defineLater = false; - else - dto.defineLater = (_defineLater==null) ? false : _defineLater; - - if(_createDateTime){ dto.createDateTime = _createDateTime; } - if(_groupingSupportType){ dto.groupingSupportType = _groupingSupportType; } - if(_readOnly){ dto.readOnly = _readOnly; } - if(_stopAfterActivity != null){ dto.stopAfterActivity = _stopAfterActivity } - - return dto; - } - - public function clone(a:Activity):Activity{ - var dto:Object = toData(); - - var n = (a != null) ? a : new Activity(null); - n.populateFromDTO(dto); - - return n; - } - - //getters and setters - - public function set objectType(a:String):Void{ - _objectType = a; - } - public function get objectType():String{ - return _objectType; - } - - /** - * - * @usage - * @param newactivityTypeID - * @return - */ - public function set activityTypeID (newactivityTypeID:Number):Void { - _activityTypeID = newactivityTypeID; - } - - /** - * - * @usage - * @return - */ - public function get activityTypeID ():Number { - return _activityTypeID; - } - - public function set activityToolContentID (newToolContentID:Number) { - _activityToolContentID = newToolContentID; - } - - public function get activityToolContentID ():Number { - return _activityToolContentID; - } - - public function set activityID(a:Number):Void{ - _activityID = a; - } - - public function get activityID():Number{ - return _activityID; - } - - /** - * - * @usage - * @param newactivityCategoryID - * @return - */ - public function set activityCategoryID (newactivityCategoryID:Number):Void { - _activityCategoryID = newactivityCategoryID; - } - - /** - * - * @usage - * @return - */ - public function get activityCategoryID ():Number { - return _activityCategoryID; - } - - /** - * - * @usage - * @param newactivityUIID - * @return - */ - public function set activityUIID (newactivityUIID:Number):Void { - _activityUIID = newactivityUIID; - } - - /** - * - * @usage - * @return - */ - public function get activityUIID ():Number { - return _activityUIID; - } - - public function set learningLibraryID(a:Number):Void{ - _learningLibraryID = a; - } - - public function get learningLibraryID():Number{ - return _learningLibraryID; +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.authoring.br.CanvasBranchView; +import org.lamsfoundation.lams.common.dict.* +import org.lamsfoundation.lams.common.* +import org.lamsfoundation.lams.common.util.* + +/* +*Activity Data storage class. USed as a base class for extending to be Tool, Gate and Complex +*

+* 
+/**
+	 * static final variables indicating the type of activities
+	 * available for a LearningDesign 
+	******************************************************************
+	public static var TOOL_ACTIVITY_TYPE:Number = 1;
+	public static var GROUPING_ACTIVITY_TYPE:Number = 2;
+	public static var NO_GATE_ACTIVITY_TYPE:Number = 30
+	public static var SYNCH_GATE_ACTIVITY_TYPE:Number = 3;
+	public static var SCHEDULE_GATE_ACTIVITY_TYPE:Number = 4;
+	public static var PERMISSION_GATE_ACTIVITY_TYPE:Number = 5;
+	public static var PARALLEL_ACTIVITY_TYPE:Number = 6;
+	public static var OPTIONAL_ACTIVITY_TYPE:Number = 7;
+	public static var SEQUENCE_ACTIVITY_TYPE:Number = 8;
+	public static var SYSTEM_GATE_ACTIVITY_TYPE:Number = 9;
+	public static var CHOSEN_BRANCHING_ACTIVITY_TYPE:Number = 10;
+	public static var GROUP_BRANCHING_ACTIVITY_TYPE:Number = 11;
+	public static var TOOL_BRANCHING_ACTIVITY_TYPE:Number = 12;
+	public static var OPTIONS_WITH_SEQUENCES_TYPE:Number = 13; 
+	
+	/******************************************************************
+	
+	/**
+	* static final variables indicating the the category of activities
+    *******************************************************************
+	public static var CATEGORY_SYSTEM:Number = 1;
+	public static var CATEGORY_COLLABORATION:Number = 2;
+	public static var CATEGORY_ASSESSMENT:Number = 3;
+	public static var CATEGORY_CONTENT:Number = 4;
+	public static var CATEGORY_SPLIT:Number = 5;
+	/******************************************************************
+	
+	
+	/**
+	 * static final variables indicating the grouping_support of activities
+	 *******************************************************************
+	 public static var GROUPING_SUPPORT_NONE:Number = 1;
+	 public static var GROUPING_SUPPORT_OPTIONAL:Number = 2;
+	 public static var GROUPING_SUPPORT_REQUIRED:Number = 3;
+	/******************************************************************
+
+* 
+* +* @author DC +* @version 2.1 +*/ +class org.lamsfoundation.lams.authoring.Activity { + + /* + //--------------------------------------------------------------------- + // Class Level Constants + //--------------------------------------------------------------------- + /** + * static final variables indicating the type of activities + * available for a LearningDesign + ******************************************************************/ + public static var TOOL_ACTIVITY_TYPE:Number = 1; + public static var GROUPING_ACTIVITY_TYPE:Number = 2; + public static var NO_GATE_ACTIVITY_TYPE:Number = 30 + public static var SYNCH_GATE_ACTIVITY_TYPE:Number = 3; + public static var SCHEDULE_GATE_ACTIVITY_TYPE:Number = 4; + public static var PERMISSION_GATE_ACTIVITY_TYPE:Number = 5; + public static var PARALLEL_ACTIVITY_TYPE:Number = 6; + public static var OPTIONAL_ACTIVITY_TYPE:Number = 7; + public static var SEQUENCE_ACTIVITY_TYPE:Number = 8; + public static var SYSTEM_GATE_ACTIVITY_TYPE:Number = 9; + public static var CHOSEN_BRANCHING_ACTIVITY_TYPE:Number = 10; + public static var GROUP_BRANCHING_ACTIVITY_TYPE:Number = 11; + public static var TOOL_BRANCHING_ACTIVITY_TYPE:Number = 12; + public static var OPTIONS_WITH_SEQUENCES_TYPE:Number = 13; + + /******************************************************************/ + + /** + * static final variables indicating the the category of activities + *******************************************************************/ + public static var CATEGORY_SYSTEM:Number = 1; + public static var CATEGORY_COLLABORATION:Number = 2; + public static var CATEGORY_ASSESSMENT:Number = 3; + public static var CATEGORY_CONTENT:Number = 4; + public static var CATEGORY_SPLIT:Number = 5; + /******************************************************************/ + + + /** + * static final variables indicating the grouping_support of activities + *******************************************************************/ + public static var GROUPING_SUPPORT_NONE:Number = 1; + public static var GROUPING_SUPPORT_OPTIONAL:Number = 2; + public static var GROUPING_SUPPORT_REQUIRED:Number = 3; + /******************************************************************/ + + //Activity Properties: + // * indicates required field + //--------------------------------------------------------------------- + // Instance variables + //--------------------------------------------------------------------- + + private var _objectType:String; //* + private var _activityTypeID:Number; //* + + + private var _activityID:Number; + private var _activityCategoryID:Number; //* + + private var _activityUIID:Number; //* + + private var _learningLibraryID:Number; //* + + private var _learningDesignID:Number; + private var _libraryActivityID:Number; + + private var _parentActivityID:Number; + private var _parentUIID:Number; + + + private var _orderID:Number; + + private var _groupingID:Number; + private var _groupingUIID:Number; + private var _isActivitySelected:String + + + private var _title:String; //* + private var _description:String; //* + private var _helpText:String; + private var _xCoord:Number; + private var _yCoord:Number; + private var _libraryActivityUIImage:String; + private var _applyGrouping:Boolean; + private var _activityToolContentID:Number; + + private var _runOffline:Boolean; + private var _defineLater:Boolean; + private var _createDateTime:Date; + + private var _groupingSupportType:Number; //* + + private var _stopAfterActivity:Boolean; + private var _readOnly:Boolean; + + private var _viewID:Boolean; + + private var _branchView:CanvasBranchView; + + /** + * Constructor + * + * Creates an activity with the minimum of fields. + * + * @param activityUIID + */ + function Activity(activityUIID:Number){ + Debugger.log('activityUIID:'+activityUIID,Debugger.GEN,'constructor','Activity'); + _activityUIID = activityUIID; + + //defaults + _objectType = "Activity"; + _applyGrouping = false; + _stopAfterActivity = false; + _runOffline = false; + _defineLater = false; + _readOnly = false; + _createDateTime = new Date(); + _branchView = null; + + } + + //static class level methods + + /** + * Created an array of activity types to be can be used as a dataprovider + * @usage + * @return + */ + public static function getGateActivityTypes():Array{ + var types:Array = []; + types.addItem({label: Dictionary.getValue('synch_act_lbl'), data: SYNCH_GATE_ACTIVITY_TYPE}); + types.addItem({label: Dictionary.getValue('sched_act_lbl'), data: SCHEDULE_GATE_ACTIVITY_TYPE}); + types.addItem({label: Dictionary.getValue('perm_act_lbl'), data: PERMISSION_GATE_ACTIVITY_TYPE}); + return types; + } + + /** + * Created an array of activity types to be can be used as a dataprovider + * @usage + * @return + */ + public static function getBranchingActivityTypes():Array{ + var types:Array = []; + types.addItem({label: Dictionary.getValue('chosen_branch_act_lbl'), data: CHOSEN_BRANCHING_ACTIVITY_TYPE}); + types.addItem({label: Dictionary.getValue('group_branch_act_lbl'), data: GROUP_BRANCHING_ACTIVITY_TYPE}); + types.addItem({label: Dictionary.getValue('tool_branch_act_lbl'), data: TOOL_BRANCHING_ACTIVITY_TYPE}); + return types; + } + + + //helper methods + + public function isGateActivity():Boolean{ + if (_activityTypeID == SYNCH_GATE_ACTIVITY_TYPE){ + return true; + }else if(_activityTypeID == SCHEDULE_GATE_ACTIVITY_TYPE){ + return true + }else if (_activityTypeID == PERMISSION_GATE_ACTIVITY_TYPE){ + return true; + }else if (_activityTypeID == SYSTEM_GATE_ACTIVITY_TYPE){ + return true; + }else{ + return false; + } + } + + public function isSystemGateActivity():Boolean{ + return _activityTypeID == SYSTEM_GATE_ACTIVITY_TYPE; + } + + public function isGroupActivity():Boolean{ + return (_activityTypeID == GROUPING_ACTIVITY_TYPE); + } + + public function isOptionalActivity():Boolean{ + return (_activityTypeID == OPTIONAL_ACTIVITY_TYPE); + } + + public function isOptionsWithSequencesActivity():Boolean { + return (_activityTypeID == OPTIONS_WITH_SEQUENCES_TYPE); + } + + public function isOptionalSequenceActivity(parent:Activity):Boolean { + return (this.isSequenceActivity() && parent.isOptionsWithSequencesActivity()); + } + + public function isParallelActivity():Boolean{ + return (_activityTypeID == PARALLEL_ACTIVITY_TYPE); + } + + public function isBranchingActivity():Boolean{ + return (_activityTypeID == CHOSEN_BRANCHING_ACTIVITY_TYPE || + _activityTypeID == GROUP_BRANCHING_ACTIVITY_TYPE || + _activityTypeID == TOOL_BRANCHING_ACTIVITY_TYPE); + } + + public function isSequenceActivity():Boolean{ + return _activityTypeID == SEQUENCE_ACTIVITY_TYPE; + } + + /** + * Populates all the fields in this activity from a dto object contaning the following fields + * NB: This is not very clever, if the field in the dto is blank then the value is overwritten in the class... + *
+
+			//activity properties:
+			_activityTypeID = dto.activityTypeID;
+			_activityID = dto.activityID;
+			_activityCategoryID = dto.activityCategoryID;
+			_activityUIID = dto.activityUIID;
+			_learningLibraryID = dto.learningLibraryID;
+			_learningDesignID = dto.learningDesignID;
+			_libraryActivityID = dto.libraryActivityID;
+			_parentActivityID = dto.parentActivityID;
+			_parentUIID = dto.parentUIID
+			_orderID = dto.orderID
+			_groupingID = dto.groupingID;
+			_groupingUIID = dto.groupingUIID
+			_title = dto.title;
+			_description = dto.description;
+			_helpText =  dto.helpText;
+			_yCoord = dto.yCoord;
+			_xCoord = dto.xCoord;
+			_libraryActivityUIImage = dto.libraryActivityUIImage;
+			_applyGrouping = dto.applyGrouping;
+			_runOffline = dto.runOffline;
+			_defineLater = dto.defineLater;
+			_createDateTime = dto.createDateTime;
+			_groupingSupportType = dto.groupingSupportType;
+			_readOnly = dto.readOnly;
+			_stopAfterActivity = dto.stopAfterActivity;
+		
+ * + * + * @usage + * @param dto //the dto containing these fields + * @return + */ + public function populateFromDTO(dto:Object){ + + //activity properties: + _activityTypeID = dto.activityTypeID; + _activityID = dto.activityID; + _activityCategoryID = dto.activityCategoryID; + _activityUIID = dto.activityUIID; + _learningLibraryID = dto.learningLibraryID; + _learningDesignID = dto.learningDesignID; + _libraryActivityID = dto.libraryActivityID; + + if(StringUtils.isWDDXNull(dto.parentActivityID)) { _parentActivityID = null } + else { _parentActivityID = dto.parentActivityID; } + + if(StringUtils.isWDDXNull(dto.parentUIID)) {_parentUIID = null } + else { _parentUIID = dto.parentUIID} + + _orderID = dto.orderID + _groupingID = dto.groupingID; + _groupingUIID = dto.groupingUIID + _title = dto.activityTitle; + _description = dto.description; + _helpText = dto.helpText; + _yCoord = dto.yCoord; + _xCoord = dto.xCoord; + _libraryActivityUIImage = dto.libraryActivityUIImage; + _applyGrouping = (dto.applyGrouping) ? dto.applyGrouping : false; + _runOffline = (dto.runOffline) ? dto.runOffline : false; + _defineLater = (dto.defineLater) ? dto.defineLater : false; + _createDateTime = dto.createDateTime; + _groupingSupportType = dto.groupingSupportType; + _readOnly = (dto.readOnly) ? dto.readOnly : false; + _stopAfterActivity = (dto.stopAfterActivity) ? dto.stopAfterActivity : false; + + } + + public function toData(){ + var dto:Object = new Object(); + + //DC - Changed mode of toData to be omiting fields with undefined values + if(_activityTypeID){ dto.activityTypeID = _activityTypeID; } + if(_activityID){ dto.activityID = _activityID; } + if(_activityCategoryID){ dto.activityCategoryID = _activityCategoryID; } + if(_activityUIID){ dto.activityUIID = _activityUIID; } + if(_learningLibraryID){ dto.learningLibraryID = _learningLibraryID; } + if(_learningDesignID){ dto.learningDesignID = _learningDesignID; } + if(_libraryActivityID){ dto.libraryActivityID = _libraryActivityID; } + if(_orderID){ dto.orderID = _orderID; } + if(_groupingID){ dto.groupingID = _groupingID; } + if(_groupingUIID){ dto.groupingUIID = _groupingUIID; } + if(_title){ dto.activityTitle = _title; } + if(_description){ dto.description = _description; } + if(_helpText){ dto.helpText = _helpText; } + if(_yCoord){ dto.yCoord = _yCoord; } + if(_xCoord){ dto.xCoord = _xCoord; } + if(_libraryActivityUIImage){dto.libraryActivityUIImage= _libraryActivityUIImage;} + + dto.parentUIID = (_parentUIID==null) ? Config.NUMERIC_NULL_VALUE : _parentUIID; + dto.parentActivityID = (_parentActivityID==null) ? Config.NUMERIC_NULL_VALUE : _parentActivityID; + + //bools need to be included - so do as follows: + dto.applyGrouping = (_applyGrouping==null) ? false : _applyGrouping; + dto.runOffline = (_runOffline==null) ? false : _runOffline; + + if(isBranchingActivity()) + if(_activityTypeID == GROUP_BRANCHING_ACTIVITY_TYPE) + dto.defineLater = (_defineLater==null) ? false : _defineLater; + else + dto.defineLater = false; + else + dto.defineLater = (_defineLater==null) ? false : _defineLater; + + if(_createDateTime){ dto.createDateTime = _createDateTime; } + if(_groupingSupportType){ dto.groupingSupportType = _groupingSupportType; } + if(_readOnly){ dto.readOnly = _readOnly; } + if(_stopAfterActivity != null){ dto.stopAfterActivity = _stopAfterActivity } + + return dto; + } + + public function clone(a:Activity):Activity{ + var dto:Object = toData(); + + var n = (a != null) ? a : new Activity(null); + n.populateFromDTO(dto); + + return n; + } + + //getters and setters + + public function set objectType(a:String):Void{ + _objectType = a; + } + public function get objectType():String{ + return _objectType; + } + + /** + * + * @usage + * @param newactivityTypeID + * @return + */ + public function set activityTypeID (newactivityTypeID:Number):Void { + _activityTypeID = newactivityTypeID; + } + + /** + * + * @usage + * @return + */ + public function get activityTypeID ():Number { + return _activityTypeID; + } + + public function set activityToolContentID (newToolContentID:Number) { + _activityToolContentID = newToolContentID; + } + + public function get activityToolContentID ():Number { + return _activityToolContentID; + } + + public function set activityID(a:Number):Void{ + _activityID = a; + } + + public function get activityID():Number{ + return _activityID; + } + + /** + * + * @usage + * @param newactivityCategoryID + * @return + */ + public function set activityCategoryID (newactivityCategoryID:Number):Void { + _activityCategoryID = newactivityCategoryID; + } + + /** + * + * @usage + * @return + */ + public function get activityCategoryID ():Number { + return _activityCategoryID; + } + + /** + * + * @usage + * @param newactivityUIID + * @return + */ + public function set activityUIID (newactivityUIID:Number):Void { + _activityUIID = newactivityUIID; + } + + /** + * + * @usage + * @return + */ + public function get activityUIID ():Number { + return _activityUIID; + } + + public function set learningLibraryID(a:Number):Void{ + _learningLibraryID = a; + } + + public function get learningLibraryID():Number{ + return _learningLibraryID; } - public function set learningDesignID(a:Number):Void{ - _learningDesignID = a; - } - public function get learningDesignID():Number{ - return _learningDesignID; - } - - /** - * - * @usage - * @param newlibraryActivityID - * @return - */ - public function set libraryActivityID (newlibraryActivityID:Number):Void { - _libraryActivityID = newlibraryActivityID; - } - - /** - * - * @usage - * @return - */ - public function get libraryActivityID ():Number { - return _libraryActivityID; - } - - /** - * - * @usage - * @param newparentActivityID - * @return - */ - public function set parentActivityID (newparentActivityID:Number):Void { - _parentActivityID = newparentActivityID; - } - - /** - * - * @usage - * @return - */ - public function get parentActivityID ():Number { - return _parentActivityID; - } - - /** - * - * @usage - * @param newparentUIID - * @return - */ - public function set parentUIID (newparentUIID:Number):Void { - _parentUIID = newparentUIID; - } - - /** - * - * @usage - * @return - */ - public function get parentUIID ():Number { - return _parentUIID; - } - - /** - * - * @usage - * @param neworderID - * @return - */ - public function set orderID (neworderID:Number):Void { - _orderID = neworderID; - } - - /** - * - * @usage - * @return - */ - public function get orderID ():Number { - return _orderID; - } - - - public function set title(a:String):Void{ - _title = a; - } - public function get title():String{ - return _title; - } - - public function set description(a:String):Void{ - _description = a; - } - public function get description():String{ - return _description; - } - - public function set helpText(a:String):Void{ - _helpText = a; - } - public function get helpText():String{ - return _helpText; - } - - /** - * Rounds the value to an integer - * @usage - * @param a - * @return - */ - public function set xCoord(a:Number):Void{ - _xCoord = Math.round(a); - } - public function get xCoord():Number{ - return _xCoord; - } - /** - * Rounds the value to an integer - * @usage - * @param a - * @return - */ - public function set yCoord(a:Number):Void{ - _yCoord = Math.round(a); - } - public function get yCoord():Number{ - return _yCoord; - } - - public function set libraryActivityUIImage(a:String):Void{ - _libraryActivityUIImage = a; - } - public function get libraryActivityUIImage():String{ - return _libraryActivityUIImage; - } - - public function set runOffline(a:Boolean):Void{ - _runOffline = a; - } - public function get runOffline():Boolean{ - return _runOffline; - } - - public function set defineLater(a:Boolean):Void{ - _defineLater = a; - } - public function get defineLater():Boolean{ - return _defineLater; - } - - public function set createDateTime(a:Date):Void{ - _createDateTime = a; - } - public function get createDateTime():Date{ - return _createDateTime; - } - - /** - * - * @usage - * @param newgroupingID - * @return - */ - public function set groupingID (newgroupingID:Number):Void { - _groupingID = newgroupingID; - } - - /** - * - * @usage - * @return - */ - public function get groupingID ():Number { - return _groupingID; - } - - /** - * - * @usage - * @param newgroupingUIID - * @return - */ - public function set groupingUIID (newgroupingUIID:Number):Void { - _groupingUIID = newgroupingUIID; - } - /** - * - * @usage - * @return - */ - public function get groupingUIID ():Number { - return _groupingUIID; - } - - /** - * - * @usage - * @param selected CA - * @return - */ - public function set selectActivity (stat:String):Void { - _isActivitySelected = stat; - } - /** - * - * @usage - * @return - */ - public function get selectActivity ():String { - return _isActivitySelected; - } - - /** - * - * @usage - * @param newapplyGrouping - * @return - */ - public function set applyGrouping (newapplyGrouping:Boolean):Void { - _applyGrouping = newapplyGrouping; - } - - /** - * - * @usage - * @return - */ - public function get applyGrouping ():Boolean { - return _applyGrouping; - } - - /** - * - * @usage - * @param newgroupingSupportType - * @return - */ - public function set groupingSupportType (newgroupingSupportType:Number):Void { - _groupingSupportType = newgroupingSupportType; - } - - /** - * - * @usage - * @return - */ - public function get groupingSupportType ():Number { - return _groupingSupportType; - } - - /** - * - * @usage - * @param newgroupingSupportType - * @return - */ - public function set readOnly (readOnly:Boolean):Void { - _readOnly = readOnly; - } - - /** - * - * @usage - * @return - */ - public function get readOnly ():Boolean { - return _readOnly; - } - - public function isReadOnly():Boolean { - return _readOnly; - } - - /** - * - * @usage - * @return - */ - public function get stopAfterActivity():Boolean { - return _stopAfterActivity; - } - - public function set stopAfterActivity(a:Boolean):Void { - _stopAfterActivity = a; - } - - public function getDictionaryLabel():String { - if(isParallelActivity()) - return "pi_parallel_title"; - else if(isOptionalActivity()) - return "opt_activity_title"; - else if(isBranchingActivity() || isSequenceActivity()) - return "pi_activity_type_branching"; - else if(isGroupActivity()) - return "pi_activity_type_grouping"; - else - return null; - } - - public function get branchView():MovieClip { - return (_branchView instanceof CanvasBranchView) ? _branchView : null; - } - - public function set branchView(a:MovieClip):Void { - _branchView = (a != null) ? CanvasBranchView(a) : null; - } - + public function set learningDesignID(a:Number):Void{ + _learningDesignID = a; + } + public function get learningDesignID():Number{ + return _learningDesignID; + } + + /** + * + * @usage + * @param newlibraryActivityID + * @return + */ + public function set libraryActivityID (newlibraryActivityID:Number):Void { + _libraryActivityID = newlibraryActivityID; + } + + /** + * + * @usage + * @return + */ + public function get libraryActivityID ():Number { + return _libraryActivityID; + } + + /** + * + * @usage + * @param newparentActivityID + * @return + */ + public function set parentActivityID (newparentActivityID:Number):Void { + _parentActivityID = newparentActivityID; + } + + /** + * + * @usage + * @return + */ + public function get parentActivityID ():Number { + return _parentActivityID; + } + + /** + * + * @usage + * @param newparentUIID + * @return + */ + public function set parentUIID (newparentUIID:Number):Void { + _parentUIID = newparentUIID; + } + + /** + * + * @usage + * @return + */ + public function get parentUIID ():Number { + return _parentUIID; + } + + /** + * + * @usage + * @param neworderID + * @return + */ + public function set orderID (neworderID:Number):Void { + _orderID = neworderID; + } + + /** + * + * @usage + * @return + */ + public function get orderID ():Number { + return _orderID; + } + + + public function set title(a:String):Void{ + _title = a; + } + public function get title():String{ + return _title; + } + + public function set description(a:String):Void{ + _description = a; + } + public function get description():String{ + return _description; + } + + public function set helpText(a:String):Void{ + _helpText = a; + } + public function get helpText():String{ + return _helpText; + } + + /** + * Rounds the value to an integer + * @usage + * @param a + * @return + */ + public function set xCoord(a:Number):Void{ + _xCoord = Math.round(a); + } + public function get xCoord():Number{ + return _xCoord; + } + /** + * Rounds the value to an integer + * @usage + * @param a + * @return + */ + public function set yCoord(a:Number):Void{ + _yCoord = Math.round(a); + } + public function get yCoord():Number{ + return _yCoord; + } + + public function set libraryActivityUIImage(a:String):Void{ + _libraryActivityUIImage = a; + } + public function get libraryActivityUIImage():String{ + return _libraryActivityUIImage; + } + + public function set runOffline(a:Boolean):Void{ + _runOffline = a; + } + public function get runOffline():Boolean{ + return _runOffline; + } + + public function set defineLater(a:Boolean):Void{ + _defineLater = a; + } + public function get defineLater():Boolean{ + return _defineLater; + } + + public function set createDateTime(a:Date):Void{ + _createDateTime = a; + } + public function get createDateTime():Date{ + return _createDateTime; + } + + /** + * + * @usage + * @param newgroupingID + * @return + */ + public function set groupingID (newgroupingID:Number):Void { + _groupingID = newgroupingID; + } + + /** + * + * @usage + * @return + */ + public function get groupingID ():Number { + return _groupingID; + } + + /** + * + * @usage + * @param newgroupingUIID + * @return + */ + public function set groupingUIID (newgroupingUIID:Number):Void { + _groupingUIID = newgroupingUIID; + } + /** + * + * @usage + * @return + */ + public function get groupingUIID ():Number { + return _groupingUIID; + } + + /** + * + * @usage + * @param selected CA + * @return + */ + public function set selectActivity (stat:String):Void { + _isActivitySelected = stat; + } + /** + * + * @usage + * @return + */ + public function get selectActivity ():String { + return _isActivitySelected; + } + + /** + * + * @usage + * @param newapplyGrouping + * @return + */ + public function set applyGrouping (newapplyGrouping:Boolean):Void { + _applyGrouping = newapplyGrouping; + } + + /** + * + * @usage + * @return + */ + public function get applyGrouping ():Boolean { + return _applyGrouping; + } + + /** + * + * @usage + * @param newgroupingSupportType + * @return + */ + public function set groupingSupportType (newgroupingSupportType:Number):Void { + _groupingSupportType = newgroupingSupportType; + } + + /** + * + * @usage + * @return + */ + public function get groupingSupportType ():Number { + return _groupingSupportType; + } + + /** + * + * @usage + * @param newgroupingSupportType + * @return + */ + public function set readOnly (readOnly:Boolean):Void { + _readOnly = readOnly; + } + + /** + * + * @usage + * @return + */ + public function get readOnly ():Boolean { + return _readOnly; + } + + public function isReadOnly():Boolean { + return _readOnly; + } + + /** + * + * @usage + * @return + */ + public function get stopAfterActivity():Boolean { + return _stopAfterActivity; + } + + public function set stopAfterActivity(a:Boolean):Void { + _stopAfterActivity = a; + } + + public function getDictionaryLabel():String { + if(isParallelActivity()) + return "pi_parallel_title"; + else if(isOptionalActivity()) + return "opt_activity_title"; + else if(isBranchingActivity() || isSequenceActivity()) + return "pi_activity_type_branching"; + else if(isGroupActivity()) + return "pi_activity_type_grouping"; + else + return null; + } + + public function get branchView():MovieClip { + return (_branchView instanceof CanvasBranchView) ? _branchView : null; + } + + public function set branchView(a:MovieClip):Void { + _branchView = (a != null) ? CanvasBranchView(a) : null; + } + } \ No newline at end of file Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Application.as =================================================================== diff -u -r5b44cd0646c0ee06e57059948a5d5f730040f431 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Application.as (.../Application.as) (revision 5b44cd0646c0ee06e57059948a5d5f730040f431) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Application.as (.../Application.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,805 +1,805 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.* //Design Data model n stuff -import org.lamsfoundation.lams.authoring.br.CanvasBranchView -import org.lamsfoundation.lams.authoring.tk.* //Toolkit -import org.lamsfoundation.lams.authoring.tb.* //Toolbar -import org.lamsfoundation.lams.authoring.cv.* //Canvas -import org.lamsfoundation.lams.authoring.layout.* //Authoring Layout Managers -import org.lamsfoundation.lams.common.ws.* //Workspace -import org.lamsfoundation.lams.common.comms.* //Communications -import org.lamsfoundation.lams.common.util.* //Utils -import org.lamsfoundation.lams.common.dict.* //Dictionary -import org.lamsfoundation.lams.common.ui.* //User interface -import org.lamsfoundation.lams.common.style.* //Themes/Styles -import org.lamsfoundation.lams.common.layout.* // Layouts -import org.lamsfoundation.lams.common.* -import mx.managers.* -import mx.utils.* - -/** -* Application - LAMS Application -* @author DI -*/ -class org.lamsfoundation.lams.authoring.Application extends ApplicationParent { - - private static var SHOW_DEBUGGER:Boolean = false; - - private static var MODULE:String = "authoring"; - - public static var TOOLBAR_X:Number = 0; - public static var TOOLBAR_Y:Number = 21; - public static var TOOLBAR_HEIGHT:Number = 35; - - public static var TOOLKIT_X:Number = 0; - public static var TOOLKIT_Y:Number = 55; - - public static var CANVAS_X:Number = 180; - public static var CANVAS_Y:Number = 55; - public static var CANVAS_W:Number = 1000; - public static var CANVAS_H:Number = 200; - - public static var PI_X:Number = 180; - public static var PI_Y:Number = 551; - public static var PI_W:Number = 616; - - public static var WORKSPACE_X:Number = 200; - public static var WORKSPACE_Y:Number = 200; - public static var WORKSPACE_W:Number = 300; - public static var WORKSPACE_H:Number = 200; - - private static var LOADING_ROOT_DEPTH:Number = 100; //depth of the loading movie - private static var APP_ROOT_DEPTH:Number = 10; //depth of the application root - private static var DIALOGUE_DEPTH:Number = 55; //depth of the dialogue box - private static var TOOLTIP_DEPTH:Number = 60; //depth of the tooltip - private static var CURSOR_DEPTH:Number = 70; //depth of the cursors - private static var CCURSOR_DEPTH:Number = 101; - public static var MENU_DEPTH:Number = 25; //depth of the menu - public static var PI_DEPTH:Number = 35; - public static var TOOLBAR_DEPTH:Number = 50; - private static var UI_LOAD_CHECK_INTERVAL:Number = 50; - private static var UI_LOAD_CHECK_TIMEOUT_COUNT:Number = 200; - private static var DATA_LOAD_CHECK_INTERVAL:Number = 50; - private static var DATA_LOAD_CHECK_TIMEOUT_COUNT:Number = 200; - - private static var QUESTION_MARK_KEY:Number = 191; - private static var X_KEY:Number = 88; - private static var C_KEY:Number = 67; - private static var D_KEY:Number = 68; - private static var V_KEY:Number = 86; - private static var Z_KEY:Number = 90; - private static var Y_KEY:Number = 89; - private static var F12_KEY:Number = 123; - - public static var CUT_TYPE:Number = 0; - public static var COPY_TYPE:Number = 1; - - private static var COMMON_COMPONENT_NO = 4; - - private var _uiLoadCheckCount = 0; // instance counter for number of times we have checked to see if theme and dict are loaded - private var _dataLoadCheckCount = 0; - - private var _ddm:DesignDataModel; - private var _toolbar:Toolbar; - private var _toolkit:Toolkit; - private var _canvas:Canvas; - private var _PI:PropertyInspector; - - private var _workspace:Workspace; - private var _ccm:CustomContextMenu; - private var _debugDialog:MovieClip; //Reference to the debug dialog - - private var _cursorContainer_mc:MovieClip; //Cursor container - private var _menu_mc:MovieClip; //Menu bar clip - private var _container_mc:MovieClip; //Main container - private var _pi_mc:MovieClip; - private var _toolbarContainer_mc:MovieClip; //Container for Toolbar - private var _UILoadCheckIntervalID:Number; //Interval ID for periodic check on UILoad status - private var _UILoaded:Boolean; //UI Loading status - - private var _DataLoadCheckIntervalID:Number; - - //UI Elements - private var _toolbarLoaded:Boolean; //These are flags set to true when respective element is 'loaded' - private var _canvasLoaded:Boolean; - private var _toolkitLoaded:Boolean; - private var _menuLoaded:Boolean; - private var _showCMItem:Boolean; - private var _piLoaded:Boolean; - - //clipboard - private var _clipboardData:Object; - private var _clipboardPasteCount:Number; - - // operation modes - private var _isEditMode:Boolean; - private var _root_layout:String; - private var _layout:LFLayout; - - //Application instance is stored as a static in the application class - private static var _instance:Application = null; - - /** - * Application - Constructor - */ - private function Application(){ - super(this); - _toolkitLoaded = false; - _canvasLoaded = false; - _menuLoaded = false; - _toolbarLoaded = false; - _piLoaded = false; - _module = Application.MODULE; - _PI = new PropertyInspector(); - _ccm = CustomContextMenu.getInstance(); - _root_layout = (_root.layout != undefined || _root.layout != null) ? _root.layout : null; - } - - /** - * Retrieves an instance of the Application singleton - */ - public static function getInstance():Application{ - if(Application._instance == null){ - Application._instance = new Application(); - } - return Application._instance; - } - - /** - * Main entry point to the application - */ - public function main(container_mc:MovieClip){ - - if(_root_layout == ApplicationParent.EDIT_MODE) - _isEditMode = true; - else - _isEditMode = false; - - _container_mc = container_mc; - _UILoaded = false; - - var layout_component_no = (_isEditMode) ? EditOnFlyLayoutManager.COMPONENT_NO : DefaultLayoutManager.COMPONENT_NO; - - _root.preloader.setStartValue(50); - _root.preloader.setEndValue(100); - - _root.preloader.start(COMMON_COMPONENT_NO + layout_component_no); - - _customCursor_mc = _container_mc.createEmptyMovieClip('_customCursor_mc', CCURSOR_DEPTH); - - //add the cursors: - Cursor.addCursor(C_HOURGLASS); - Cursor.addCursor(C_OPTIONAL); - Cursor.addCursor(C_TRANSITION); - Cursor.addCursor(C_GATE); - Cursor.addCursor(C_GROUP); - - //Get the instance of config class - _config = Config.getInstance(); - - //Assign the config load event to - _config.addEventListener('load',Delegate.create(this,configLoaded)); - - //Set up Key handler - Key.addListener(this); - - _container_mc.tabChildren = true; - } - - /** - * Called when the config class has loaded - */ - private function configLoaded(){ - //Now that the config class is ready setup the UI and data, call to setupData() first in - //case UI element constructors use objects instantiated with setupData() - _root.preloader.complete(); - - setupData(); - checkDataLoaded(); - } - - /** - * Loads and sets up event listeners for Theme, Dictionary etc. - */ - private function setupData() { - - //Get the language, create+load dictionary and setup load handler. - var language:String = String(_config.getItem('language')); - _dictionary = Dictionary.getInstance(); - _dictionary.addEventListener('load',Delegate.create(this,onDictionaryLoad)); - _dictionary.load(language); - - //Set reference to StyleManager and load Themes and setup load handler. - var theme:String = String(_config.getItem('theme')); - _themeManager = ThemeManager.getInstance(); - _themeManager.addEventListener('load',Delegate.create(this,onThemeLoad)); - _themeManager.loadTheme(theme); - Debugger.getInstance().crashDumpSeverityLevel = Number(_config.getItem('crashDumpSeverityLevelLog')); - Debugger.getInstance().severityLevel = Number(_config.getItem('severityLevelLog')); - - } - - - /** - * Periodically checks if data has been loaded - */ - private function checkDataLoaded() { - - // first time through set interval for method polling - if(!_DataLoadCheckIntervalID) { - _DataLoadCheckIntervalID = setInterval(Proxy.create(this, checkDataLoaded), DATA_LOAD_CHECK_INTERVAL); - } else { - _dataLoadCheckCount++; - - // if dictionary and theme data loaded setup UI - if(_dictionaryLoaded && _themeLoaded) { - clearInterval(_DataLoadCheckIntervalID); - setupUI(); - checkUILoaded(); - } else if(_dataLoadCheckCount >= DATA_LOAD_CHECK_TIMEOUT_COUNT) { - Debugger.log('reached timeout waiting for data to load.',Debugger.CRITICAL,'checkUILoaded','Application'); - clearInterval(_UILoadCheckIntervalID); - } - } - } - - /** - * Runs periodically and dispatches events as they are ready - */ - private function checkUILoaded() { - //If it's the first time through then set up the interval to keep polling this method - if(!_UILoadCheckIntervalID) { - _UILoadCheckIntervalID = setInterval(Proxy.create(this,checkUILoaded),UI_LOAD_CHECK_INTERVAL); - } else { - _uiLoadCheckCount++; - //If all events dispatched clear interval and call start() - if(_UILoaded && _dictionaryEventDispatched && _themeEventDispatched){ - //Debugger.log('Clearing Interval and calling start :',Debugger.CRITICAL,'checkUILoaded','Application'); - clearInterval(_UILoadCheckIntervalID); - start(); - }else { - //If UI loaded check which events can be broadcast - if(_UILoaded){ - //If dictionary is loaded and event hasn't been dispatched - dispatch it - if(_dictionaryLoaded && !_dictionaryEventDispatched){ - _dictionaryEventDispatched = true; - _dictionary.broadcastInit(); - } - //If theme is loaded and theme event hasn't been dispatched - dispatch it - if(_themeLoaded && !_themeEventDispatched){ - _themeEventDispatched = true; - _themeManager.broadcastThemeChanged(); - } - - if(_uiLoadCheckCount >= UI_LOAD_CHECK_TIMEOUT_COUNT){ - //if we havent loaded the dict or theme by the timeout count then give up - Debugger.log('raeached time out waiting to load dict and themes, giving up.',Debugger.CRITICAL,'checkUILoaded','Application'); - var msg:String = ""; - if(!_themeEventDispatched){ - msg+=Dictionary.getValue("app_chk_themeload"); - } - if(!_dictionaryEventDispatched){ - msg+="The lanaguage data has not been loaded."; - } - msg+=Dictionary.getValue("app_fail_continue"); - var e:LFError = new LFError(msg,"Canvas.setDroppedTemplateActivity",this,'_themeEventDispatched:'+_themeEventDispatched+' _dictionaryEventDispatched:'+_dictionaryEventDispatched); - e.showErrorAlert(); - - //TODO: give the user a message - clearInterval(_UILoadCheckIntervalID); - } - } - } - } - } - - /** - * This is called by each UI element as it loads to notify Application that it's loaded - * When all UIElements are loaded the Application can set UILoaded flag true allowing events to be dispatched - * and methods called on the UI Elements - * - * @param UIElementID:String - Identifier for the Element that was loaded - */ - public function UIElementLoaded(evt:Object) { - Debugger.log('UIElementLoaded: ' + evt.target.className,Debugger.GEN,'UIElementLoaded','Application'); - if(evt.type=='load'){ - //Which item has loaded - switch (evt.target.className) { - case 'Toolkit' : - _toolkitLoaded = true; - break; - case 'Canvas' : - _canvasLoaded = true; - break; - case 'LFMenuBar' : - _menuLoaded = true; - break; - case 'Toolbar' : - _toolbarLoaded = true; - break; - case 'PropertyInspector' : - _piLoaded = true; - break; - default: - } - - _layout.manager.addLayoutItem(new LFLayoutItem(evt.target.className, evt.target)); - - _root.preloader.complete(); - - if(_layout.manager.completedLayout) { - _UILoaded = true; - } else { - _UILoaded = false; - } - } - } - - - /** - * Create all UI Elements - */ - private function setupUI(){ - //Make the base context menu hide built in items so we don't have zoom in etc - _ccm.showCustomCM(_ccm.loadMenu("application", "authoring")) - - //Create the application root - _appRoot_mc = _container_mc.createEmptyMovieClip('appRoot_mc', APP_ROOT_DEPTH); - - //Create screen elements - dialogueContainer = _container_mc.createEmptyMovieClip('_dialogueContainer_mc',DIALOGUE_DEPTH); - _cursorContainer_mc = _container_mc.createEmptyMovieClip('_cursorContainer_mc',CURSOR_DEPTH); - _toolbarContainer_mc = _container_mc.createEmptyMovieClip('_toolbarContainer_mc',TOOLBAR_DEPTH); - _pi_mc = _container_mc.createEmptyMovieClip('_pi_mc',PI_DEPTH); - - // Tooltip - _tooltipContainer_mc = _container_mc.createEmptyMovieClip('_tooltipContainer_mc',TOOLTIP_DEPTH); - - // Workspace - _workspace = new Workspace(); - - setupLayout(); - - setTabIndex(); - } - - private function setupLayout():Void { - var manager = (_isEditMode) ? ILayoutManager(new EditOnFlyLayoutManager('editonfly')) : ILayoutManager(new DefaultLayoutManager('default')); - _layout = new LFLayout(this, manager); - _layout.init(); - } - - private function setTabIndex(selectedTab:String){ - - //All Buttons Tab Index - _menu_mc.tabIndex = 100; - _toolbarContainer_mc.tabIndex = 200; - _pi_mc.tabIndex = 400; - } - - /** - * Runs when application setup has completed. At this point the init/loading screen can be removed and the user can - * work with the application - */ - private function start(){ - - //Fire off a resize to set up sizes - onResize(); - - //Remove the loading screen - _root.preloader.stop(); - _root._visible = true; - - if(SHOW_DEBUGGER){ - showDebugger(); - } - - if(getCanvas().getCanvasModel().autoSaveWait) { - // enable menu item - recover... - LFMenuBar.getInstance().enableRecover(true); - } - - if(_isEditMode) { - Debugger.log("Authoring started in Edit-On-The-Fly Mode", Debugger.CRITICAL, "start", "Application"); - var ldID = Number(_root.learningDesignID); - canvas.openDesignForEditOnFly(ldID); - } else { - Debugger.log("Authoring started in Author Mode", Debugger.CRITICAL, "start", "Application"); - } - - } - - /** - * Opens the preferences dialog - */ - public function showPrefsDialog() { - dialog = PopUpManager.createPopUp(Application.root, LFWindow, true,{title:Dictionary.getValue("prefs_dlg_title"),closeButton:true,scrollContentPath:'preferencesDialog'}); - } - - /** - * Receives events from the Stage resizing - */ - public function onResize(){ - - //Get the stage width and height and call onResize for stage based objects - var w:Number = Stage.width; - var h:Number = Stage.height; - - var someListener:Object = new Object(); - - someListener.onMouseUp = function () { - - _layout.manager.resize(w, h); - - } - - _layout.manager.resize(w, h); - - - - } - - /** - * Handles KEY Releases for Application - */ - private function onKeyUp(){ - Debugger.log('Key released.',Debugger.GEN,'onKeyUp','Application'); - if(!Key.isDown(Key.CONTROL)) { - if(_controlKeyPressed == ApplicationParent.TRANSITION) { - Debugger.log('Control Key released.',Debugger.GEN,'onKeyUp','Application'); - - var c:String = Cursor.getCurrentCursor(); - - if(c == ApplicationParent.C_TRANSITION){ - _controlKeyPressed = ""; - _canvas.stopTransitionTool(); - } - } - } - - } - - /** - * Handles KEY presses for Application - */ - private function onKeyDown(){ - - //the debug window: - if (Key.isDown(Key.CONTROL) && Key.isDown(Key.ALT) && Key.isDown(QUESTION_MARK_KEY)) { - if (!_debugDialog.content){ - showDebugger(); - }else { - hideDebugger(); - } - }else if (Key.isDown(Key.CONTROL) && Key.isDown(X_KEY)) { - //for copy and paste - //assuming that we are in the canvas... - cut(); - }else if (Key.isDown(Key.CONTROL) && Key.isDown(C_KEY)) { - copy(); - }else if (Key.isDown(F12_KEY)) { - trace("P Pressed") - PropertyInspector(_pi_mc).localOnRelease(); - - }else if (Key.isDown(Key.CONTROL) && Key.isDown(V_KEY)) { - paste(); - - }else if (Key.isDown(Key.CONTROL) && Key.isDown(Z_KEY)) { - //undo - _canvas.undo(); - - }else if (Key.isDown(Key.CONTROL) && Key.isDown(Y_KEY)) { - - - }else if(Key.isDown(Key.CONTROL)) { - var c:String = Cursor.getCurrentCursor(); - if(c != ApplicationParent.C_TRANSITION){ - _controlKeyPressed = ApplicationParent.TRANSITION; - _canvas.startTransitionTool() - } - - - } - - } - - public function transition_keyPressed(){ - _controlKeyPressed = "transition"; - if(_canvas.model.activeTool != "TRANSITION"){ - _canvas.toggleTransitionTool(); - } - } - public function showDebugger():Void{ - _debugDialog = PopUpManager.createPopUp(Application.root, LFWindow, false,{title:'Debug',closeButton:true,scrollContentPath:'debugDialog'}); - } - - public function hideDebugger():Void{ - _debugDialog.deletePopUp(); - } - - /** - * stores a reference to the object - * @usage - * @param obj - * @return - */ - public function setClipboardData(obj:Object, type:Number):Void{ - // initialise new clipboard object - _clipboardData = new Object(); - _clipboardData.data = obj; - _clipboardData.type = type; - _clipboardData.count = 0; - - } - - /** - * returns a reference to the object on the clipboard. - * Note it must be cloned to be used. this should be taken care of by the destination class - * @usage - * @return - */ - public function getClipboardData():Object{ - return _clipboardData; - } - - - public function cut():Void{ - var ca = _canvas.model.selectedItem - if (CanvasActivity(ca) != null){ - if (ca.activity.parentUIID == null || ca.activity.parentUIID == undefined){ - setClipboardData(ca, CUT_TYPE); - }else { - LFMessage.showMessageAlert(Dictionary.getValue('cv_activity_cut_invalid')); - } - }else { - LFMessage.showMessageAlert(Dictionary.getValue('al_activity_copy_invalid')); - } - } - - public function copy():Void{ - var ca = _canvas.model.selectedItem; - if (ca != null){ - if (ca.activity.parentUIID == null || ca.activity.parentUIID == undefined){ - setClipboardData(ca, COPY_TYPE); - } else if(_canvas.model.activeView instanceof CanvasBranchView && canvas.ddm.getActivityByUIID(ca.activity.parentUIID).parentUIID == canvas.model.activeView.activity.activityUIID) { - setClipboardData(ca, COPY_TYPE); - } else { - LFMessage.showMessageAlert(Dictionary.getValue('cv_activity_copy_invalid')); - } - }else{ - LFMessage.showMessageAlert(Dictionary.getValue('al_activity_copy_invalid')); - } - } - - public function openEditActivityContent():Void{ - var ca = _canvas.model.selectedItem - if (CanvasActivity(ca) != null){ - _canvas.view.getController().activityDoubleClick(ca); - }else { - LFMessage.showMessageAlert(Dictionary.getValue('al_activity_openContent_invalid')); - } - } - - public function paste():Void{ - _clipboardData.count++; - _canvas.setPastedItem(getClipboardData()); - } - - public function expandPI():Void{ - if (!_PI.isPIExpanded()){ - _canvas.model.setPIHeight(_PI.piFullHeight()); - } - } - - public function help():Void{ - var ca = _canvas.model.selectedItem - if (CanvasActivity(ca) != null){ - _canvas.getHelp(ca); - } - } - - /** - * get the ddm form the canvas.. this method is here as the ddm used to be stored inthe application. - * returns the the Design Data Model - */ - public function getDesignDataModel():DesignDataModel{ - return _canvas.ddm; - } - - /** - * returns the the toolkit instance - */ - public function getToolkit():Toolkit{ - return _toolkit; - } - - /** - * returns the the toolbar instance - */ - public function getToolbar():Toolbar{ - return _toolbar; - } - - public function set toolbar(a:Toolbar) { - _toolbar = a; - } - - public function get toolbar():Toolbar { - return _toolbar; - } - - public function set toolkit(a:Toolkit) { - _toolkit = a; - } - - public function get toolkit():Toolkit { - return _toolkit; - } - - public function set menubar(a:MovieClip) { - _menu_mc = a; - } - - public function get menubar():MovieClip { - return _menu_mc; - } - - public function set pi(a:MovieClip) { - _pi_mc = a; - } - - public function get pi():MovieClip { - return _pi_mc; - } - - /** - * returns the the canvas instance - */ - public function getCanvas():Canvas{ - return _canvas; - } - - public function set canvas(a:Canvas) { - _canvas = a; - } - - public function get canvas():Canvas { - return _canvas; - } - - public function set root_layout(a:String){ - _root_layout = a; - } - - /** - * returns the the workspace instance - */ - public function getWorkspace():Workspace{ - return _workspace; - } - - /** - * Opens the help->about dialog - */ - public function showAboutDialog() { - dialog = PopUpManager.createPopUp(Application.root, LFWindow, true,{title:"About - LAMS Author",closeButton:true,scrollContentPath:'helpaboutDialog'}); - } - - /** - * Returns the Dialogue conatiner mc - * - * @usage Import authoring package and then use - * - */ - static function get dialogue():MovieClip { - //Return root if valid otherwise raise a big system error as app. will not work without it - if(_instance._dialogueContainer_mc != undefined) { - return _instance._dialogueContainer_mc; - } else { - //TODO DI 11/05/05 Raise error if mc hasn't been created - - } - } - - /** - * Returns the Cursor conatiner mc - * - * @usage Import authoring package and then use - * - */ - static function get cursor():MovieClip { - //Return root if valid otherwise raise a big system error as app. will not work without it - if(_instance._cursorContainer_mc != undefined) { - return _instance._cursorContainer_mc; - } else { - //TODO DI 11/05/05 Raise error if mc hasn't been created - - } - } - - /** - * Returns true if in Edit Mode (for Edit-On-The-Fly) otherwise false - * - */ - static function get isEditMode():Boolean { - //Return root if valid otherwise raise a big system error as app. will not work without it - if(_instance._isEditMode != undefined) { - return _instance._isEditMode; - } else { - - } - } - - /** - * Returns the Application root, use as _root would be used - * - * @usage Import authoring package and then use as root e.g. - * - * import org.lamsfoundation.lams.authoring; - * Application.root.attachMovie('myLinkageId','myInstanceName',depth); - */ - static function get root():MovieClip { - //Return root if valid otherwise raise a big system error as app. will not work without it - if(_instance._appRoot_mc != undefined) { - return _instance._appRoot_mc; - } else { - //TODO DI 11/05/05 Raise error if _appRoot hasn't been created - - } - } - - /** - * Returns the Application root, use as _root would be used - * - * @usage Import authoring package and then use as root e.g. - * - * import org.lamsfoundation.lams.authoring; - * Application.root.attachMovie('myLinkageId','myInstanceName',depth); - */ - static function get containermc():MovieClip { - //Return root if valid otherwise raise a big system error as app. will not work without it - if(_instance._container_mc != undefined) { - return _instance._container_mc; - } else { - - } - } - - /** - * Returns the Application root, use as _root would be used - * - * @usage Import authoring package and then use as root e.g. - * - * import org.lamsfoundation.lams.authoring; - * Application.root.attachMovie('myLinkageId','myInstanceName',depth); - */ - static function get toolbarContainer():MovieClip { - //Return root if valid otherwise raise a big system error as app. will not work without it - if(_instance._toolbarContainer_mc != undefined) { - return _instance._toolbarContainer_mc; - } else { - - } - } +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.* //Design Data model n stuff +import org.lamsfoundation.lams.authoring.br.CanvasBranchView +import org.lamsfoundation.lams.authoring.tk.* //Toolkit +import org.lamsfoundation.lams.authoring.tb.* //Toolbar +import org.lamsfoundation.lams.authoring.cv.* //Canvas +import org.lamsfoundation.lams.authoring.layout.* //Authoring Layout Managers +import org.lamsfoundation.lams.common.ws.* //Workspace +import org.lamsfoundation.lams.common.comms.* //Communications +import org.lamsfoundation.lams.common.util.* //Utils +import org.lamsfoundation.lams.common.dict.* //Dictionary +import org.lamsfoundation.lams.common.ui.* //User interface +import org.lamsfoundation.lams.common.style.* //Themes/Styles +import org.lamsfoundation.lams.common.layout.* // Layouts +import org.lamsfoundation.lams.common.* +import mx.managers.* +import mx.utils.* + +/** +* Application - LAMS Application +* @author DI +*/ +class org.lamsfoundation.lams.authoring.Application extends ApplicationParent { + + private static var SHOW_DEBUGGER:Boolean = false; + + private static var MODULE:String = "authoring"; + + public static var TOOLBAR_X:Number = 0; + public static var TOOLBAR_Y:Number = 21; + public static var TOOLBAR_HEIGHT:Number = 35; + + public static var TOOLKIT_X:Number = 0; + public static var TOOLKIT_Y:Number = 55; + + public static var CANVAS_X:Number = 180; + public static var CANVAS_Y:Number = 55; + public static var CANVAS_W:Number = 1000; + public static var CANVAS_H:Number = 200; + + public static var PI_X:Number = 180; + public static var PI_Y:Number = 551; + public static var PI_W:Number = 616; + + public static var WORKSPACE_X:Number = 200; + public static var WORKSPACE_Y:Number = 200; + public static var WORKSPACE_W:Number = 300; + public static var WORKSPACE_H:Number = 200; + + private static var LOADING_ROOT_DEPTH:Number = 100; //depth of the loading movie + private static var APP_ROOT_DEPTH:Number = 10; //depth of the application root + private static var DIALOGUE_DEPTH:Number = 55; //depth of the dialogue box + private static var TOOLTIP_DEPTH:Number = 60; //depth of the tooltip + private static var CURSOR_DEPTH:Number = 70; //depth of the cursors + private static var CCURSOR_DEPTH:Number = 101; + public static var MENU_DEPTH:Number = 25; //depth of the menu + public static var PI_DEPTH:Number = 35; + public static var TOOLBAR_DEPTH:Number = 50; + private static var UI_LOAD_CHECK_INTERVAL:Number = 50; + private static var UI_LOAD_CHECK_TIMEOUT_COUNT:Number = 200; + private static var DATA_LOAD_CHECK_INTERVAL:Number = 50; + private static var DATA_LOAD_CHECK_TIMEOUT_COUNT:Number = 200; + + private static var QUESTION_MARK_KEY:Number = 191; + private static var X_KEY:Number = 88; + private static var C_KEY:Number = 67; + private static var D_KEY:Number = 68; + private static var V_KEY:Number = 86; + private static var Z_KEY:Number = 90; + private static var Y_KEY:Number = 89; + private static var F12_KEY:Number = 123; + + public static var CUT_TYPE:Number = 0; + public static var COPY_TYPE:Number = 1; + + private static var COMMON_COMPONENT_NO = 4; + + private var _uiLoadCheckCount = 0; // instance counter for number of times we have checked to see if theme and dict are loaded + private var _dataLoadCheckCount = 0; + + private var _ddm:DesignDataModel; + private var _toolbar:Toolbar; + private var _toolkit:Toolkit; + private var _canvas:Canvas; + private var _PI:PropertyInspector; + + private var _workspace:Workspace; + private var _ccm:CustomContextMenu; + private var _debugDialog:MovieClip; //Reference to the debug dialog + + private var _cursorContainer_mc:MovieClip; //Cursor container + private var _menu_mc:MovieClip; //Menu bar clip + private var _container_mc:MovieClip; //Main container + private var _pi_mc:MovieClip; + private var _toolbarContainer_mc:MovieClip; //Container for Toolbar + private var _UILoadCheckIntervalID:Number; //Interval ID for periodic check on UILoad status + private var _UILoaded:Boolean; //UI Loading status + + private var _DataLoadCheckIntervalID:Number; + + //UI Elements + private var _toolbarLoaded:Boolean; //These are flags set to true when respective element is 'loaded' + private var _canvasLoaded:Boolean; + private var _toolkitLoaded:Boolean; + private var _menuLoaded:Boolean; + private var _showCMItem:Boolean; + private var _piLoaded:Boolean; + + //clipboard + private var _clipboardData:Object; + private var _clipboardPasteCount:Number; + + // operation modes + private var _isEditMode:Boolean; + private var _root_layout:String; + private var _layout:LFLayout; + + //Application instance is stored as a static in the application class + private static var _instance:Application = null; + + /** + * Application - Constructor + */ + private function Application(){ + super(this); + _toolkitLoaded = false; + _canvasLoaded = false; + _menuLoaded = false; + _toolbarLoaded = false; + _piLoaded = false; + _module = Application.MODULE; + _PI = new PropertyInspector(); + _ccm = CustomContextMenu.getInstance(); + _root_layout = (_root.layout != undefined || _root.layout != null) ? _root.layout : null; + } + + /** + * Retrieves an instance of the Application singleton + */ + public static function getInstance():Application{ + if(Application._instance == null){ + Application._instance = new Application(); + } + return Application._instance; + } + + /** + * Main entry point to the application + */ + public function main(container_mc:MovieClip){ + + if(_root_layout == ApplicationParent.EDIT_MODE) + _isEditMode = true; + else + _isEditMode = false; + + _container_mc = container_mc; + _UILoaded = false; + + var layout_component_no = (_isEditMode) ? EditOnFlyLayoutManager.COMPONENT_NO : DefaultLayoutManager.COMPONENT_NO; + + _root.preloader.setStartValue(50); + _root.preloader.setEndValue(100); + + _root.preloader.start(COMMON_COMPONENT_NO + layout_component_no); + + _customCursor_mc = _container_mc.createEmptyMovieClip('_customCursor_mc', CCURSOR_DEPTH); + + //add the cursors: + Cursor.addCursor(C_HOURGLASS); + Cursor.addCursor(C_OPTIONAL); + Cursor.addCursor(C_TRANSITION); + Cursor.addCursor(C_GATE); + Cursor.addCursor(C_GROUP); + + //Get the instance of config class + _config = Config.getInstance(); + + //Assign the config load event to + _config.addEventListener('load',Delegate.create(this,configLoaded)); + + //Set up Key handler + Key.addListener(this); + + _container_mc.tabChildren = true; + } + + /** + * Called when the config class has loaded + */ + private function configLoaded(){ + //Now that the config class is ready setup the UI and data, call to setupData() first in + //case UI element constructors use objects instantiated with setupData() + _root.preloader.complete(); + + setupData(); + checkDataLoaded(); + } + + /** + * Loads and sets up event listeners for Theme, Dictionary etc. + */ + private function setupData() { + + //Get the language, create+load dictionary and setup load handler. + var language:String = String(_config.getItem('language')); + _dictionary = Dictionary.getInstance(); + _dictionary.addEventListener('load',Delegate.create(this,onDictionaryLoad)); + _dictionary.load(language); + + //Set reference to StyleManager and load Themes and setup load handler. + var theme:String = String(_config.getItem('theme')); + _themeManager = ThemeManager.getInstance(); + _themeManager.addEventListener('load',Delegate.create(this,onThemeLoad)); + _themeManager.loadTheme(theme); + Debugger.getInstance().crashDumpSeverityLevel = Number(_config.getItem('crashDumpSeverityLevelLog')); + Debugger.getInstance().severityLevel = Number(_config.getItem('severityLevelLog')); + + } + + + /** + * Periodically checks if data has been loaded + */ + private function checkDataLoaded() { + + // first time through set interval for method polling + if(!_DataLoadCheckIntervalID) { + _DataLoadCheckIntervalID = setInterval(Proxy.create(this, checkDataLoaded), DATA_LOAD_CHECK_INTERVAL); + } else { + _dataLoadCheckCount++; + + // if dictionary and theme data loaded setup UI + if(_dictionaryLoaded && _themeLoaded) { + clearInterval(_DataLoadCheckIntervalID); + setupUI(); + checkUILoaded(); + } else if(_dataLoadCheckCount >= DATA_LOAD_CHECK_TIMEOUT_COUNT) { + Debugger.log('reached timeout waiting for data to load.',Debugger.CRITICAL,'checkUILoaded','Application'); + clearInterval(_UILoadCheckIntervalID); + } + } + } + + /** + * Runs periodically and dispatches events as they are ready + */ + private function checkUILoaded() { + //If it's the first time through then set up the interval to keep polling this method + if(!_UILoadCheckIntervalID) { + _UILoadCheckIntervalID = setInterval(Proxy.create(this,checkUILoaded),UI_LOAD_CHECK_INTERVAL); + } else { + _uiLoadCheckCount++; + //If all events dispatched clear interval and call start() + if(_UILoaded && _dictionaryEventDispatched && _themeEventDispatched){ + //Debugger.log('Clearing Interval and calling start :',Debugger.CRITICAL,'checkUILoaded','Application'); + clearInterval(_UILoadCheckIntervalID); + start(); + }else { + //If UI loaded check which events can be broadcast + if(_UILoaded){ + //If dictionary is loaded and event hasn't been dispatched - dispatch it + if(_dictionaryLoaded && !_dictionaryEventDispatched){ + _dictionaryEventDispatched = true; + _dictionary.broadcastInit(); + } + //If theme is loaded and theme event hasn't been dispatched - dispatch it + if(_themeLoaded && !_themeEventDispatched){ + _themeEventDispatched = true; + _themeManager.broadcastThemeChanged(); + } + + if(_uiLoadCheckCount >= UI_LOAD_CHECK_TIMEOUT_COUNT){ + //if we havent loaded the dict or theme by the timeout count then give up + Debugger.log('raeached time out waiting to load dict and themes, giving up.',Debugger.CRITICAL,'checkUILoaded','Application'); + var msg:String = ""; + if(!_themeEventDispatched){ + msg+=Dictionary.getValue("app_chk_themeload"); + } + if(!_dictionaryEventDispatched){ + msg+="The lanaguage data has not been loaded."; + } + msg+=Dictionary.getValue("app_fail_continue"); + var e:LFError = new LFError(msg,"Canvas.setDroppedTemplateActivity",this,'_themeEventDispatched:'+_themeEventDispatched+' _dictionaryEventDispatched:'+_dictionaryEventDispatched); + e.showErrorAlert(); + + //TODO: give the user a message + clearInterval(_UILoadCheckIntervalID); + } + } + } + } + } + + /** + * This is called by each UI element as it loads to notify Application that it's loaded + * When all UIElements are loaded the Application can set UILoaded flag true allowing events to be dispatched + * and methods called on the UI Elements + * + * @param UIElementID:String - Identifier for the Element that was loaded + */ + public function UIElementLoaded(evt:Object) { + Debugger.log('UIElementLoaded: ' + evt.target.className,Debugger.GEN,'UIElementLoaded','Application'); + if(evt.type=='load'){ + //Which item has loaded + switch (evt.target.className) { + case 'Toolkit' : + _toolkitLoaded = true; + break; + case 'Canvas' : + _canvasLoaded = true; + break; + case 'LFMenuBar' : + _menuLoaded = true; + break; + case 'Toolbar' : + _toolbarLoaded = true; + break; + case 'PropertyInspector' : + _piLoaded = true; + break; + default: + } + + _layout.manager.addLayoutItem(new LFLayoutItem(evt.target.className, evt.target)); + + _root.preloader.complete(); + + if(_layout.manager.completedLayout) { + _UILoaded = true; + } else { + _UILoaded = false; + } + } + } + + + /** + * Create all UI Elements + */ + private function setupUI(){ + //Make the base context menu hide built in items so we don't have zoom in etc + _ccm.showCustomCM(_ccm.loadMenu("application", "authoring")) + + //Create the application root + _appRoot_mc = _container_mc.createEmptyMovieClip('appRoot_mc', APP_ROOT_DEPTH); + + //Create screen elements + dialogueContainer = _container_mc.createEmptyMovieClip('_dialogueContainer_mc',DIALOGUE_DEPTH); + _cursorContainer_mc = _container_mc.createEmptyMovieClip('_cursorContainer_mc',CURSOR_DEPTH); + _toolbarContainer_mc = _container_mc.createEmptyMovieClip('_toolbarContainer_mc',TOOLBAR_DEPTH); + _pi_mc = _container_mc.createEmptyMovieClip('_pi_mc',PI_DEPTH); + + // Tooltip + _tooltipContainer_mc = _container_mc.createEmptyMovieClip('_tooltipContainer_mc',TOOLTIP_DEPTH); + + // Workspace + _workspace = new Workspace(); + + setupLayout(); + + setTabIndex(); + } + + private function setupLayout():Void { + var manager = (_isEditMode) ? ILayoutManager(new EditOnFlyLayoutManager('editonfly')) : ILayoutManager(new DefaultLayoutManager('default')); + _layout = new LFLayout(this, manager); + _layout.init(); + } + + private function setTabIndex(selectedTab:String){ + + //All Buttons Tab Index + _menu_mc.tabIndex = 100; + _toolbarContainer_mc.tabIndex = 200; + _pi_mc.tabIndex = 400; + } + + /** + * Runs when application setup has completed. At this point the init/loading screen can be removed and the user can + * work with the application + */ + private function start(){ + + //Fire off a resize to set up sizes + onResize(); + + //Remove the loading screen + _root.preloader.stop(); + _root._visible = true; + + if(SHOW_DEBUGGER){ + showDebugger(); + } + + if(getCanvas().getCanvasModel().autoSaveWait) { + // enable menu item - recover... + LFMenuBar.getInstance().enableRecover(true); + } + + if(_isEditMode) { + Debugger.log("Authoring started in Edit-On-The-Fly Mode", Debugger.CRITICAL, "start", "Application"); + var ldID = Number(_root.learningDesignID); + canvas.openDesignForEditOnFly(ldID); + } else { + Debugger.log("Authoring started in Author Mode", Debugger.CRITICAL, "start", "Application"); + } + + } + + /** + * Opens the preferences dialog + */ + public function showPrefsDialog() { + dialog = PopUpManager.createPopUp(Application.root, LFWindow, true,{title:Dictionary.getValue("prefs_dlg_title"),closeButton:true,scrollContentPath:'preferencesDialog'}); + } + + /** + * Receives events from the Stage resizing + */ + public function onResize(){ + + //Get the stage width and height and call onResize for stage based objects + var w:Number = Stage.width; + var h:Number = Stage.height; + + var someListener:Object = new Object(); + + someListener.onMouseUp = function () { + + _layout.manager.resize(w, h); + + } + + _layout.manager.resize(w, h); + + + + } + + /** + * Handles KEY Releases for Application + */ + private function onKeyUp(){ + Debugger.log('Key released.',Debugger.GEN,'onKeyUp','Application'); + if(!Key.isDown(Key.CONTROL)) { + if(_controlKeyPressed == ApplicationParent.TRANSITION) { + Debugger.log('Control Key released.',Debugger.GEN,'onKeyUp','Application'); + + var c:String = Cursor.getCurrentCursor(); + + if(c == ApplicationParent.C_TRANSITION){ + _controlKeyPressed = ""; + _canvas.stopTransitionTool(); + } + } + } + + } + + /** + * Handles KEY presses for Application + */ + private function onKeyDown(){ + + //the debug window: + if (Key.isDown(Key.CONTROL) && Key.isDown(Key.ALT) && Key.isDown(QUESTION_MARK_KEY)) { + if (!_debugDialog.content){ + showDebugger(); + }else { + hideDebugger(); + } + }else if (Key.isDown(Key.CONTROL) && Key.isDown(X_KEY)) { + //for copy and paste + //assuming that we are in the canvas... + cut(); + }else if (Key.isDown(Key.CONTROL) && Key.isDown(C_KEY)) { + copy(); + }else if (Key.isDown(F12_KEY)) { + trace("P Pressed") + PropertyInspector(_pi_mc).localOnRelease(); + + }else if (Key.isDown(Key.CONTROL) && Key.isDown(V_KEY)) { + paste(); + + }else if (Key.isDown(Key.CONTROL) && Key.isDown(Z_KEY)) { + //undo + _canvas.undo(); + + }else if (Key.isDown(Key.CONTROL) && Key.isDown(Y_KEY)) { + + + }else if(Key.isDown(Key.CONTROL)) { + var c:String = Cursor.getCurrentCursor(); + if(c != ApplicationParent.C_TRANSITION){ + _controlKeyPressed = ApplicationParent.TRANSITION; + _canvas.startTransitionTool() + } + + + } + + } + + public function transition_keyPressed(){ + _controlKeyPressed = "transition"; + if(_canvas.model.activeTool != "TRANSITION"){ + _canvas.toggleTransitionTool(); + } + } + public function showDebugger():Void{ + _debugDialog = PopUpManager.createPopUp(Application.root, LFWindow, false,{title:'Debug',closeButton:true,scrollContentPath:'debugDialog'}); + } + + public function hideDebugger():Void{ + _debugDialog.deletePopUp(); + } + + /** + * stores a reference to the object + * @usage + * @param obj + * @return + */ + public function setClipboardData(obj:Object, type:Number):Void{ + // initialise new clipboard object + _clipboardData = new Object(); + _clipboardData.data = obj; + _clipboardData.type = type; + _clipboardData.count = 0; + + } + + /** + * returns a reference to the object on the clipboard. + * Note it must be cloned to be used. this should be taken care of by the destination class + * @usage + * @return + */ + public function getClipboardData():Object{ + return _clipboardData; + } + + + public function cut():Void{ + var ca = _canvas.model.selectedItem + if (CanvasActivity(ca) != null){ + if (ca.activity.parentUIID == null || ca.activity.parentUIID == undefined){ + setClipboardData(ca, CUT_TYPE); + }else { + LFMessage.showMessageAlert(Dictionary.getValue('cv_activity_cut_invalid')); + } + }else { + LFMessage.showMessageAlert(Dictionary.getValue('al_activity_copy_invalid')); + } + } + + public function copy():Void{ + var ca = _canvas.model.selectedItem; + if (ca != null){ + if (ca.activity.parentUIID == null || ca.activity.parentUIID == undefined){ + setClipboardData(ca, COPY_TYPE); + } else if(_canvas.model.activeView instanceof CanvasBranchView && canvas.ddm.getActivityByUIID(ca.activity.parentUIID).parentUIID == canvas.model.activeView.activity.activityUIID) { + setClipboardData(ca, COPY_TYPE); + } else { + LFMessage.showMessageAlert(Dictionary.getValue('cv_activity_copy_invalid')); + } + }else{ + LFMessage.showMessageAlert(Dictionary.getValue('al_activity_copy_invalid')); + } + } + + public function openEditActivityContent():Void{ + var ca = _canvas.model.selectedItem + if (CanvasActivity(ca) != null){ + _canvas.view.getController().activityDoubleClick(ca); + }else { + LFMessage.showMessageAlert(Dictionary.getValue('al_activity_openContent_invalid')); + } + } + + public function paste():Void{ + _clipboardData.count++; + _canvas.setPastedItem(getClipboardData()); + } + + public function expandPI():Void{ + if (!_PI.isPIExpanded()){ + _canvas.model.setPIHeight(_PI.piFullHeight()); + } + } + + public function help():Void{ + var ca = _canvas.model.selectedItem + if (CanvasActivity(ca) != null){ + _canvas.getHelp(ca); + } + } + + /** + * get the ddm form the canvas.. this method is here as the ddm used to be stored inthe application. + * returns the the Design Data Model + */ + public function getDesignDataModel():DesignDataModel{ + return _canvas.ddm; + } + + /** + * returns the the toolkit instance + */ + public function getToolkit():Toolkit{ + return _toolkit; + } + + /** + * returns the the toolbar instance + */ + public function getToolbar():Toolbar{ + return _toolbar; + } + + public function set toolbar(a:Toolbar) { + _toolbar = a; + } + + public function get toolbar():Toolbar { + return _toolbar; + } + + public function set toolkit(a:Toolkit) { + _toolkit = a; + } + + public function get toolkit():Toolkit { + return _toolkit; + } + + public function set menubar(a:MovieClip) { + _menu_mc = a; + } + + public function get menubar():MovieClip { + return _menu_mc; + } + + public function set pi(a:MovieClip) { + _pi_mc = a; + } + + public function get pi():MovieClip { + return _pi_mc; + } + + /** + * returns the the canvas instance + */ + public function getCanvas():Canvas{ + return _canvas; + } + + public function set canvas(a:Canvas) { + _canvas = a; + } + + public function get canvas():Canvas { + return _canvas; + } + + public function set root_layout(a:String){ + _root_layout = a; + } + + /** + * returns the the workspace instance + */ + public function getWorkspace():Workspace{ + return _workspace; + } + + /** + * Opens the help->about dialog + */ + public function showAboutDialog() { + dialog = PopUpManager.createPopUp(Application.root, LFWindow, true,{title:"About - LAMS Author",closeButton:true,scrollContentPath:'helpaboutDialog'}); + } + + /** + * Returns the Dialogue conatiner mc + * + * @usage Import authoring package and then use + * + */ + static function get dialogue():MovieClip { + //Return root if valid otherwise raise a big system error as app. will not work without it + if(_instance._dialogueContainer_mc != undefined) { + return _instance._dialogueContainer_mc; + } else { + //TODO DI 11/05/05 Raise error if mc hasn't been created + + } + } + + /** + * Returns the Cursor conatiner mc + * + * @usage Import authoring package and then use + * + */ + static function get cursor():MovieClip { + //Return root if valid otherwise raise a big system error as app. will not work without it + if(_instance._cursorContainer_mc != undefined) { + return _instance._cursorContainer_mc; + } else { + //TODO DI 11/05/05 Raise error if mc hasn't been created + + } + } + + /** + * Returns true if in Edit Mode (for Edit-On-The-Fly) otherwise false + * + */ + static function get isEditMode():Boolean { + //Return root if valid otherwise raise a big system error as app. will not work without it + if(_instance._isEditMode != undefined) { + return _instance._isEditMode; + } else { + + } + } + + /** + * Returns the Application root, use as _root would be used + * + * @usage Import authoring package and then use as root e.g. + * + * import org.lamsfoundation.lams.authoring; + * Application.root.attachMovie('myLinkageId','myInstanceName',depth); + */ + static function get root():MovieClip { + //Return root if valid otherwise raise a big system error as app. will not work without it + if(_instance._appRoot_mc != undefined) { + return _instance._appRoot_mc; + } else { + //TODO DI 11/05/05 Raise error if _appRoot hasn't been created + + } + } + + /** + * Returns the Application root, use as _root would be used + * + * @usage Import authoring package and then use as root e.g. + * + * import org.lamsfoundation.lams.authoring; + * Application.root.attachMovie('myLinkageId','myInstanceName',depth); + */ + static function get containermc():MovieClip { + //Return root if valid otherwise raise a big system error as app. will not work without it + if(_instance._container_mc != undefined) { + return _instance._container_mc; + } else { + + } + } + + /** + * Returns the Application root, use as _root would be used + * + * @usage Import authoring package and then use as root e.g. + * + * import org.lamsfoundation.lams.authoring; + * Application.root.attachMovie('myLinkageId','myInstanceName',depth); + */ + static function get toolbarContainer():MovieClip { + //Return root if valid otherwise raise a big system error as app. will not work without it + if(_instance._toolbarContainer_mc != undefined) { + return _instance._toolbarContainer_mc; + } else { + + } + } } \ No newline at end of file Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Branch.as =================================================================== diff -u -r745cc845b7776b062471723072abb234db21f292 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Branch.as (.../Branch.as) (revision 745cc845b7776b062471723072abb234db21f292) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/Branch.as (.../Branch.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,105 +1,105 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.authoring.br.BranchConnector; -import org.lamsfoundation.lams.common.*; -import org.lamsfoundation.lams.common.util.*; -import org.lamsfoundation.lams.common.dict.*; - - -class Branch extends Transition { - - private var UIID:Number; - private var _sequenceActivity:SequenceActivity; - private var _direction:Number; - private var _targetUIID:Number; - private var _hubUIID:Number; - - - // TODO: add learningDesignID - - public function Branch(activityUIID:Number, _dir:Number, targetUIID:Number, hubUIID:Number, sequenceActivity:SequenceActivity, learningDesignID:Number){ - if(_dir == BranchConnector.DIR_FROM_START) - super(null, hubUIID, targetUIID, learningDesignID); - else if(_dir == BranchConnector.DIR_SINGLE) - super(null, targetUIID, targetUIID, learningDesignID); - else - super(null, targetUIID, hubUIID, learningDesignID); - - UIID = activityUIID; - _direction = _dir; - _targetUIID = targetUIID; - _hubUIID = hubUIID; - _sequenceActivity = sequenceActivity; - } - - public function toData():Object{ - var dto:Object = super.toData(); - dto.branchUIID = branchUIID; - dto.sequenceActivity = sequenceActivity; - return dto; - } - - public function get branchUIID():Number { - return UIID; - } - - public function get sequenceActivity():SequenceActivity { - return _sequenceActivity; - } - - public function setDefaultSequenceName():Void { - var title = Dictionary.getValue('branch_mapping_dlg_branch_col_lbl'); - _sequenceActivity.title = Dictionary.getValue('sequence_act_title_new', [title, _sequenceActivity.orderID]); - } - - public function get sequenceName():String { - return _sequenceActivity.title; - } - - public function get direction():Number { - return _direction; - } - - public function get targetUIID():Number { - return _targetUIID; - } - - public function get hubUIID():Number { - return _hubUIID; - } - - public function get isStart():Boolean { - return (_direction == BranchConnector.DIR_FROM_START); - } - - public function get isEnd():Boolean { - return (_direction == BranchConnector.DIR_TO_END); - } - - public function get isActivityless():Boolean { - return (_direction == BranchConnector.DIR_SINGLE); - } -} - +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.authoring.br.BranchConnector; +import org.lamsfoundation.lams.common.*; +import org.lamsfoundation.lams.common.util.*; +import org.lamsfoundation.lams.common.dict.*; + + +class Branch extends Transition { + + private var UIID:Number; + private var _sequenceActivity:SequenceActivity; + private var _direction:Number; + private var _targetUIID:Number; + private var _hubUIID:Number; + + + // TODO: add learningDesignID + + public function Branch(activityUIID:Number, _dir:Number, targetUIID:Number, hubUIID:Number, sequenceActivity:SequenceActivity, learningDesignID:Number){ + if(_dir == BranchConnector.DIR_FROM_START) + super(null, hubUIID, targetUIID, learningDesignID); + else if(_dir == BranchConnector.DIR_SINGLE) + super(null, targetUIID, targetUIID, learningDesignID); + else + super(null, targetUIID, hubUIID, learningDesignID); + + UIID = activityUIID; + _direction = _dir; + _targetUIID = targetUIID; + _hubUIID = hubUIID; + _sequenceActivity = sequenceActivity; + } + + public function toData():Object{ + var dto:Object = super.toData(); + dto.branchUIID = branchUIID; + dto.sequenceActivity = sequenceActivity; + return dto; + } + + public function get branchUIID():Number { + return UIID; + } + + public function get sequenceActivity():SequenceActivity { + return _sequenceActivity; + } + + public function setDefaultSequenceName():Void { + var title = Dictionary.getValue('branch_mapping_dlg_branch_col_lbl'); + _sequenceActivity.title = Dictionary.getValue('sequence_act_title_new', [title, _sequenceActivity.orderID]); + } + + public function get sequenceName():String { + return _sequenceActivity.title; + } + + public function get direction():Number { + return _direction; + } + + public function get targetUIID():Number { + return _targetUIID; + } + + public function get hubUIID():Number { + return _hubUIID; + } + + public function get isStart():Boolean { + return (_direction == BranchConnector.DIR_FROM_START); + } + + public function get isEnd():Boolean { + return (_direction == BranchConnector.DIR_TO_END); + } + + public function get isActivityless():Boolean { + return (_direction == BranchConnector.DIR_SINGLE); + } +} + Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/BranchingActivity.as =================================================================== diff -u -r34cb1725fa1d312652042fd3108aceaa65adf7ad -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/BranchingActivity.as (.../BranchingActivity.as) (revision 34cb1725fa1d312652042fd3108aceaa65adf7ad) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/BranchingActivity.as (.../BranchingActivity.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,174 +1,174 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.common.util.Debugger; -/* -* -* @author Mitchell Seaton -* @version 2.1 -* @comments Branching Activity Data storage class. -* @see Activity -*/ -class BranchingActivity extends ComplexActivity { - - private static var DEFAULT_STARTX:Number = 0; - private static var DEFAULT_STARTY:Number = 0; - private static var DEFAULT_ENDX:Number = 0; - private static var DEFAULT_ENDY:Number = 0; - - private var _startXCoord:Number; - private var _startYCoord:Number; - private var _endXCoord:Number; - private var _endYCoord:Number; - - private var _toolActivityUIID:Number; - private var _defaultBranch:Branch; - - private var _clear:Boolean; - - function BranchingActivity(activityUIID:Number, activityTypeID:Number){ - super(activityUIID); - _activityTypeID = activityTypeID; - - _toolActivityUIID == null; - _defaultBranch = null; - - _clear = false; - - } - - /** - * Creates from a dto... which is nice - * @usage - * @param dto - * @return - */ - public function populateFromDTO(dto:Object){ - super.populateFromDTO(dto); - - _startXCoord = dto.startXCoord; - _startYCoord = dto.startYCoord; - _endXCoord = dto.endXCoord; - _endYCoord = dto.endYCoord; - _toolActivityUIID = dto.toolActivityUIID; - } - - /** - * Creates an object containing all the props - * If a value is null then it is ommitted... if itsd the null value from const - * then its included - * @usage - * @return the DTO - */ - public function toData():Object{ - var dto:Object = super.toData(); - if(_startXCoord) dto.startXCoord = _startXCoord; - if(_startYCoord) dto.startYCoord = _startYCoord; - if(_endXCoord) dto.endXCoord = _endXCoord; - if(_endYCoord) dto.endYCoord = _endYCoord; - if(_toolActivityUIID) dto.toolActivityUIID = _toolActivityUIID; - - return dto; - } - - /** - * Creates an exact copy of this ComplexActivity - * @usage - * @return the copy - */ - public function clone():BranchingActivity{ - var dto:Object = toData(); - var ba = new BranchingActivity(); - ba.populateFromDTO(dto); - return ba; - } - - - public function set type(a:Number):Void{ - _activityTypeID = a; - } - - public function get type():Number { - return _activityTypeID; - } - - public function set startXCoord(a:Number):Void{ - Debugger.log("setting x coord: " + a, Debugger.CRITICAL, "startXCoord", "BranchingActivity"); - _startXCoord = Math.round(a); - } - - public function get startXCoord():Number{ - return _startXCoord; - } - - public function set startYCoord(a:Number):Void{ - _startYCoord = Math.round(a); - } - - public function get startYCoord():Number{ - return _startYCoord; - } - - public function set endXCoord(a:Number):Void{ - _endXCoord = Math.round(a); - } - - public function get endXCoord():Number{ - return _endXCoord; - } - - public function set endYCoord(a:Number):Void{ - _endYCoord = Math.round(a); - } - - public function get endYCoord():Number{ - return _endYCoord; - } - - public function set toolActivityUIID(a:Number) { - _toolActivityUIID = a; - } - - public function get toolActivityUIID():Number { - return _toolActivityUIID; - } - - public function set defaultBranch(a:Branch) { - _defaultBranch = a; - _firstActivityUIID = (a != null) ? SequenceActivity(a.sequenceActivity).activityUIID : null; - } - - public function get defaultBranch():Branch { - return _defaultBranch; - } - - public function get clear():Boolean { - return _clear; - } - - public function set clear(a:Boolean):Void { - _clear = a; - } -} - +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.common.util.Debugger; +/* +* +* @author Mitchell Seaton +* @version 2.1 +* @comments Branching Activity Data storage class. +* @see Activity +*/ +class BranchingActivity extends ComplexActivity { + + private static var DEFAULT_STARTX:Number = 0; + private static var DEFAULT_STARTY:Number = 0; + private static var DEFAULT_ENDX:Number = 0; + private static var DEFAULT_ENDY:Number = 0; + + private var _startXCoord:Number; + private var _startYCoord:Number; + private var _endXCoord:Number; + private var _endYCoord:Number; + + private var _toolActivityUIID:Number; + private var _defaultBranch:Branch; + + private var _clear:Boolean; + + function BranchingActivity(activityUIID:Number, activityTypeID:Number){ + super(activityUIID); + _activityTypeID = activityTypeID; + + _toolActivityUIID == null; + _defaultBranch = null; + + _clear = false; + + } + + /** + * Creates from a dto... which is nice + * @usage + * @param dto + * @return + */ + public function populateFromDTO(dto:Object){ + super.populateFromDTO(dto); + + _startXCoord = dto.startXCoord; + _startYCoord = dto.startYCoord; + _endXCoord = dto.endXCoord; + _endYCoord = dto.endYCoord; + _toolActivityUIID = dto.toolActivityUIID; + } + + /** + * Creates an object containing all the props + * If a value is null then it is ommitted... if itsd the null value from const + * then its included + * @usage + * @return the DTO + */ + public function toData():Object{ + var dto:Object = super.toData(); + if(_startXCoord) dto.startXCoord = _startXCoord; + if(_startYCoord) dto.startYCoord = _startYCoord; + if(_endXCoord) dto.endXCoord = _endXCoord; + if(_endYCoord) dto.endYCoord = _endYCoord; + if(_toolActivityUIID) dto.toolActivityUIID = _toolActivityUIID; + + return dto; + } + + /** + * Creates an exact copy of this ComplexActivity + * @usage + * @return the copy + */ + public function clone():BranchingActivity{ + var dto:Object = toData(); + var ba = new BranchingActivity(); + ba.populateFromDTO(dto); + return ba; + } + + + public function set type(a:Number):Void{ + _activityTypeID = a; + } + + public function get type():Number { + return _activityTypeID; + } + + public function set startXCoord(a:Number):Void{ + Debugger.log("setting x coord: " + a, Debugger.CRITICAL, "startXCoord", "BranchingActivity"); + _startXCoord = Math.round(a); + } + + public function get startXCoord():Number{ + return _startXCoord; + } + + public function set startYCoord(a:Number):Void{ + _startYCoord = Math.round(a); + } + + public function get startYCoord():Number{ + return _startYCoord; + } + + public function set endXCoord(a:Number):Void{ + _endXCoord = Math.round(a); + } + + public function get endXCoord():Number{ + return _endXCoord; + } + + public function set endYCoord(a:Number):Void{ + _endYCoord = Math.round(a); + } + + public function get endYCoord():Number{ + return _endYCoord; + } + + public function set toolActivityUIID(a:Number) { + _toolActivityUIID = a; + } + + public function get toolActivityUIID():Number { + return _toolActivityUIID; + } + + public function set defaultBranch(a:Branch) { + _defaultBranch = a; + _firstActivityUIID = (a != null) ? SequenceActivity(a.sequenceActivity).activityUIID : null; + } + + public function get defaultBranch():Branch { + return _defaultBranch; + } + + public function get clear():Boolean { + return _clear; + } + + public function set clear(a:Boolean):Void { + _clear = a; + } +} + Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ComplexActivity.as =================================================================== diff -u -r5b44cd0646c0ee06e57059948a5d5f730040f431 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ComplexActivity.as (.../ComplexActivity.as) (revision 5b44cd0646c0ee06e57059948a5d5f730040f431) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ComplexActivity.as (.../ComplexActivity.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,185 +1,184 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.common.Config; -import org.lamsfoundation.lams.common.util.Debugger; -import org.lamsfoundation.lams.common.util.StringUtils; - -/* -* This class represents all the complex activity types. they are not much different, so we can handle them in one class. -* For reference these are the activity types -*

-* public static var PARALLEL_ACTIVITY_TYPE:Number = 6;
-* public static var OPTIONAL_ACTIVITY_TYPE:Number = 7;
-* public static var SEQUENCE_ACTIVITY_TYPE:Number = 8;
-* 
-* @author DC -* @version 0.1 -* @see Activity -*/ -class ComplexActivity extends Activity { - - private var _maxOptions:Number; - private var _minOptions:Number; - private var _optionsInstructions:String; - - private var _firstActivityUIID:Number; - - private var _noSequences:Number; - - function ComplexActivity(activityUIID:Number){ - super(activityUIID); - _firstActivityUIID = null; +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.common.Config; +import org.lamsfoundation.lams.common.util.Debugger; +import org.lamsfoundation.lams.common.util.StringUtils; + +/* +* This class represents all the complex activity types. they are not much different, so we can handle them in one class. +* For reference these are the activity types +*

+* public static var PARALLEL_ACTIVITY_TYPE:Number = 6;
+* public static var OPTIONAL_ACTIVITY_TYPE:Number = 7;
+* public static var SEQUENCE_ACTIVITY_TYPE:Number = 8;
+* 
+* @author DC +* @version 0.1 +* @see Activity +*/ +class ComplexActivity extends Activity { + + private var _maxOptions:Number; + private var _minOptions:Number; + private var _optionsInstructions:String; + + private var _firstActivityUIID:Number; + + private var _noSequences:Number; + + function ComplexActivity(activityUIID:Number){ + super(activityUIID); + _firstActivityUIID = null; + } + + /** + * Creates a complex activity from a dto... which is nice + * @usage + * @param dto + * @return + */ + public function populateFromDTO(dto:Object){ + super.populateFromDTO(dto); + if(_activityTypeID == Activity.OPTIONAL_ACTIVITY_TYPE || _activityTypeID == Activity.OPTIONS_WITH_SEQUENCES_TYPE){ + _maxOptions = dto.maxOptions; + _minOptions = dto.minOptions; + //TODO: This is missing in the Library packet - tell mai. + _optionsInstructions = dto.optionsInstructions; + } + + if(StringUtils.isWDDXNull(dto.defaultActivityUIID)) _firstActivityUIID = null; + else _firstActivityUIID = dto.defaultActivityUIID; + } + + /** + * Creates an object containing all the props of the ComplexActivity. + * If a value is null then it is ommitted... if itsd the null value from const + * then its included + * @usage + * @return the DTO + */ + public function toData():Object{ + var dto:Object = super.toData(); + if(_activityTypeID == Activity.OPTIONAL_ACTIVITY_TYPE || _activityTypeID == Activity.OPTIONS_WITH_SEQUENCES_TYPE){ + if(_maxOptions){ dto.maxOptions = _maxOptions; } + if(_minOptions){ dto.minOptions = _minOptions; } + if(_optionsInstructions){ dto.optionsInstructions = _optionsInstructions; } + } + + dto.defaultActivityUIID = (_firstActivityUIID == null) ? Config.NUMERIC_NULL_VALUE : _firstActivityUIID; + + return dto; + } + + /** + * Creates an exact copy of this ComplexActivity + * @usage + * @return the copy + */ + public function clone():ComplexActivity{ + var dto:Object = toData(); + var ca = new ComplexActivity(); + ca.populateFromDTO(dto); + + return ca; } - - /** - * Creates a complex activity from a dto... which is nice - * @usage - * @param dto - * @return - */ - public function populateFromDTO(dto:Object){ - super.populateFromDTO(dto); - if(_activityTypeID == Activity.OPTIONAL_ACTIVITY_TYPE || _activityTypeID == Activity.OPTIONS_WITH_SEQUENCES_TYPE){ - _maxOptions = dto.maxOptions; - _minOptions = dto.minOptions; - //TODO: This is missing in the Library packet - tell mai. - _optionsInstructions = dto.optionsInstructions; - } - - if(StringUtils.isWDDXNull(dto.defaultActivityUIID)) _firstActivityUIID = null; - else _firstActivityUIID = dto.defaultActivityUIID; - } - - /** - * Creates an object containing all the props of the ComplexActivity. - * If a value is null then it is ommitted... if itsd the null value from const - * then its included - * @usage - * @return the DTO - */ - public function toData():Object{ - var dto:Object = super.toData(); - if(_activityTypeID == Activity.OPTIONAL_ACTIVITY_TYPE || _activityTypeID == Activity.OPTIONS_WITH_SEQUENCES_TYPE){ - if(_maxOptions){ dto.maxOptions = _maxOptions; } - if(_minOptions){ dto.minOptions = _minOptions; } - if(_optionsInstructions){ dto.optionsInstructions = _optionsInstructions; } - } - - dto.defaultActivityUIID = (_firstActivityUIID == null) ? Config.NUMERIC_NULL_VALUE : _firstActivityUIID; - - return dto; - } - - /** - * Creates an exact copy of this ComplexActivity - * @usage - * @return the copy - */ - public function clone():ComplexActivity{ - var dto:Object = toData(); - var ca = new ComplexActivity(); - ca.populateFromDTO(dto); - - return ca; - } - - - /** - * Used by OPTIONAL_ACTIVITY_TYPE - * @usage - * @param newmaxOptions - * @return - */ - public function set maxOptions (newmaxOptions:Number):Void { - _maxOptions = newmaxOptions; - } - /** - * used by OPTIONAL_ACTIVITY_TYPE - * @usage - * @return - */ - public function get maxOptions ():Number { - return _maxOptions; - } - - - /** - * used by OPTIONAL_ACTIVITY_TYPE - * @usage - * @param newminOptions - * @return - */ - public function set minOptions (newminOptions:Number):Void { - _minOptions = newminOptions; - } - /** - * used by OPTIONAL_ACTIVITY_TYPE - * @usage - * @return - */ - public function get minOptions ():Number { - return _minOptions; - } - - - /** - * - * @usage - * @param newoptionsInstructions - * @return - */ - public function set optionsInstructions (newoptionsInstructions:String):Void { - _optionsInstructions = newoptionsInstructions; - } - /** - * - * @usage - * @return - */ - public function get optionsInstructions ():String { - return _optionsInstructions; - } - - public function get firstActivityUIID():Number{ - return _firstActivityUIID; - } - - public function set firstActivityUIID(a:Number):Void{ - _firstActivityUIID = a; - } - - public function get isSequenceBased():Boolean{ - return (_activityTypeID == Activity.OPTIONS_WITH_SEQUENCES_TYPE); - } - - public function get noSequences():Number{ - return _noSequences; - } - - public function set noSequences(a:Number):Void{ - _noSequences = a; - } -} - + + /** + * Used by OPTIONAL_ACTIVITY_TYPE + * @usage + * @param newmaxOptions + * @return + */ + public function set maxOptions (newmaxOptions:Number):Void { + _maxOptions = newmaxOptions; + } + /** + * used by OPTIONAL_ACTIVITY_TYPE + * @usage + * @return + */ + public function get maxOptions ():Number { + return _maxOptions; + } + + + /** + * used by OPTIONAL_ACTIVITY_TYPE + * @usage + * @param newminOptions + * @return + */ + public function set minOptions (newminOptions:Number):Void { + _minOptions = newminOptions; + } + /** + * used by OPTIONAL_ACTIVITY_TYPE + * @usage + * @return + */ + public function get minOptions ():Number { + return _minOptions; + } + + + /** + * + * @usage + * @param newoptionsInstructions + * @return + */ + public function set optionsInstructions (newoptionsInstructions:String):Void { + _optionsInstructions = newoptionsInstructions; + } + /** + * + * @usage + * @return + */ + public function get optionsInstructions ():String { + return _optionsInstructions; + } + + public function get firstActivityUIID():Number{ + return _firstActivityUIID; + } + + public function set firstActivityUIID(a:Number):Void{ + _firstActivityUIID = a; + } + + public function get isSequenceBased():Boolean{ + return (_activityTypeID == Activity.OPTIONS_WITH_SEQUENCES_TYPE); + } + + public function get noSequences():Number{ + return _noSequences; + } + + public function set noSequences(a:Number):Void{ + _noSequences = a; + } +} + Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/DesignDataModel.as =================================================================== diff -u -r3f521ad22e97838d8d2c5d81c00d38acd1bfc678 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/DesignDataModel.as (.../DesignDataModel.as) (revision 3f521ad22e97838d8d2c5d81c00d38acd1bfc678) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/DesignDataModel.as (.../DesignDataModel.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,1670 +1,1670 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.common.util.*; -import org.lamsfoundation.lams.common.ui.Cursor; -import org.lamsfoundation.lams.authoring.br.BranchConnector; -import org.lamsfoundation.lams.common.*; -import mx.events.* - -/* -* -* DesignDataModel stores all the data relating to the design -* -* Note the hashtable of _activities might contain the following types: -* 1) ToolActivities -* 2) Grouping activities which reference a _groupings element -* 3) Parallel activities which reference 2 or more other _activitiy elements -* 4) Optional activities which reference 2 or more other _activitiy elements -* 5) Gate activities -* -* -* @author DC -* @version 0.1 -* -*/ - -class org.lamsfoundation.lams.authoring.DesignDataModel { - - public static var COPY_TYPE_ID_AUTHORING:Number = 1; - public static var COPY_TYPE_ID_RUN:Number = 2; +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.common.util.*; +import org.lamsfoundation.lams.common.ui.Cursor; +import org.lamsfoundation.lams.authoring.br.BranchConnector; +import org.lamsfoundation.lams.common.*; +import mx.events.* + +/* +* +* DesignDataModel stores all the data relating to the design +* +* Note the hashtable of _activities might contain the following types: +* 1) ToolActivities +* 2) Grouping activities which reference a _groupings element +* 3) Parallel activities which reference 2 or more other _activitiy elements +* 4) Optional activities which reference 2 or more other _activitiy elements +* 5) Gate activities +* +* +* @author DC +* @version 0.1 +* +*/ + +class org.lamsfoundation.lams.authoring.DesignDataModel { + + public static var COPY_TYPE_ID_AUTHORING:Number = 1; + public static var COPY_TYPE_ID_RUN:Number = 2; public static var COPY_TYPE_ID_PREVIEW:Number = 3; - - //LearningDesign Properties: - private var _objectType:String; - private var _copyTypeID:Number; - - private var _learningDesignID:Number; - private var _prevLearningDesignID:Number; // used for backup retrieval of the learning Design ID - private var _title:String; - private var _description:String; - private var _helpText:String; - private var _version:String; - private var _designVersion:Number; - private var _userID:Number; - private var _editOverrideUserID:Number; - private var _editOverrideUserFullName:String; - private var _duration:Number; - private var _readOnly:Boolean; - private var _editOverrideLock:Boolean - private var _autoSaved:Boolean - private var _saveMode:Number; - private var _validDesign:Boolean; - private var _modified:Boolean; - private var _maxID:Number; - private var _firstActivityID:Number; - private var _firstActivityUIID:Number; - - //James has asked for previous and next fields so I can build up a sequence map of LDs when browsing workspaces... - private var _parentLearningDesignID:Number; - private var _activities:Hashtable; - private var _transitions:Hashtable; - private var _groupings:Hashtable; - private var _branches:Hashtable; - private var _branchMappings:Hashtable; - private var _competences:Hashtable; - private var _outputConditions:Hashtable; - - private var _licenseID:Number; - private var _licenseText:String; - private var _workspaceFolderID:Number; - private var _createDateTime:Date; - private var _lastModifiedDateTime:Date; - private var _dateReadOnly:Date; - - private var _contentFolderID:String; - - //These are defined so that the compiler can 'see' the events that are added at runtime by EventDispatcher - private var dispatchEvent:Function; - public var addEventListener:Function; - public var removeEventListener:Function; - - //Constructor - function DesignDataModel(){ - //initialise the hashtables - _activities = new Hashtable("_activities"); - _transitions = new Hashtable("_transitions"); - _groupings = new Hashtable("_groupings"); - _branches = new Hashtable("_branches"); - _branchMappings = new Hashtable("_branchMappings"); - _competences = new Hashtable("_competences"); - _outputConditions = new Hashtable("_outputConditions"); - - //set the defualts: - _objectType = "LearningDesign"; - _copyTypeID = COPY_TYPE_ID_AUTHORING; - _version = null; - _readOnly = false; - _editOverrideLock = false; - _validDesign = false; - _autoSaved = false; - - _userID = Config.getInstance().userID; - - EventDispatcher.initialize(this); - - //dispatch an event now the design has changed - dispatchEvent({type:'ddmUpdate',target:this}); - - } - - /** - * Validates the design data model - * @usage - * @return - */ - public function validate():Boolean{ - var success:Boolean= false; - Debugger.log("******* FUNCTION NOT IMPLEMENTED",Debugger.CRITICAL,'validate','DesignDataModel'); - return success; - } - - //////////////////////////////////////////////////////////////////////////// - //////////////////////// UPDATE METHODS /////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - /** - * Adds a template activity to the model. - * - */ - public function addActivity(activity:Activity):Object{ - var success = false; - - //create an Activity from the template actvity. - Debugger.log('activity:'+activity.title+', UIID:'+activity.activityUIID,4,'addActivity','DesignDataModel'); - - //validate the activity ? - //validate if we can do it? - - //dispatch an event before the design has changed - dispatchEvent({type:'ddmBeforeUpdate',target:this}); - _activities.put(activity.activityUIID, activity); - - //pull it out to check it - var tmp:Activity = _activities.get(activity.activityUIID) - - if(tmp){ - Debugger.log('Succesfully added:'+tmp.title+':'+tmp.activityUIID,4,'addActivity','DesignDataModel'); - }else{ - return new LFError("Adding activity failed","addActivity",this,'activityUIID:'+activity.activityUIID); - } - - //dispatch an event now the design has changed - dispatchEvent({type:'ddmUpdate',target:this}); - - - - } - - /** - * Removes the activity from the DDM - * @usage - * @param activityUIID - * @return - */ - public function removeActivity(activityUIID:Number):Object{ - //dispatch an event to show the design has changed - dispatchEvent({type:'ddmBeforeUpdate',target:this}); - - var r:Object = _activities.remove(activityUIID); - if(r==null){ - return new LFError("Removing activity failed:"+activityUIID,"removeActivity",this,null); - } else { - if(r.activityTypeID == Activity.GROUPING_ACTIVITY_TYPE) { - var rg:Object = _groupings.remove(r.createGroupingUIID); - if(rg==null) { - return new LFError("Removing associated grouping failed:"+r.createGroupingUIID, "removeActivity", this, null); - } else { - Debugger.log('Removed grouping:'+rg.groupingUIID, Debugger.GEN,'removeActivity','DesignDataModel'); - } - } - - Debugger.log('Removed:'+r.activityUIID,Debugger.GEN,'removeActivity','DesignDataModel'); - dispatchEvent({type:'ddmUpdate',target:this}); - - return r; - - } - } - - /** - * Removes the complex activity (and children) from only DDM (no canvas items) - * @usage - * @param activityUIID - * @return - */ - public function removeComplexActivity(activityUIID:Number, _children:Array, removeTrans:Boolean):Void{ - - for(var i=0; i<_children.length; i++) { - var _nChildren:Array = getComplexActivityChildren(_children[i].activityUIID); - if(_nChildren.length > 0) { - removeComplexActivity(_children[i].activityUIID, _nChildren, removeTrans); - } else { - removeActivity(_children[i].activityUIID); - if(removeTrans) removeTransitionByConnection(_children[i].activityUIID); - } - - } - - removeActivity(activityUIID); - if(removeTrans) removeTransitionByConnection(_children[i].activityUIID); - - } - - /** - * Adds a transition to the DDM - * @usage - * @param transition - * @return - */ - public function addTransition(transition:Transition):Boolean{ - //dispatch an event to show the design has changed - dispatchEvent({type:'ddmBeforeUpdate',target:this}); - - Debugger.log('Transition from:'+transition.fromUIID+', to:'+transition.toUIID,4,'addTransition','DesignDataModel'); - _transitions.put(transition.transitionUIID,transition); - dispatchEvent({type:'ddmUpdate',target:this}); - - //TODO some validation would be nice - - return true; - } - - /** - * Removes the transition from the DDM - * @usage - * @param transitionUIID - * @return - */ - public function removeTransition(transitionUIID):Object{ - //dispatch an event to show the design has changed - dispatchEvent({type:'ddmBeforeUpdate',target:this}); - - var r:Object = _transitions.remove(transitionUIID); - if(r==null){ - return new LFError("Removing transition failed:"+transitionUIID,"removeTransition",this,null); - }else{ - Debugger.log('Removed:'+r.transitionUIID,Debugger.GEN,'removeTransition','DesignDataModel'); - dispatchEvent({type:'ddmUpdate',target:this}); - } - } - - /** - * Removes the transitions from the DDM which are connected to the Activity - * - * @param connectUIID connected Activity UIID - */ - - public function removeTransitionByConnection(connectUIID):Void{ - var keyArray:Array = _transitions.keys(); - for(var i=0; i.setDesign(design:Object) - * @param design - * @return success - */ - public function setDesign(design:Object):Boolean{ - //note the design must be empty to call this - //note: Dont fire the update event as we dont want to store this change in an undo! - - //TODO: Validate that the design is clear - var success:Boolean = false; - - //TODO:Validate if design is saved if not notify user - success = true; - - Debugger.log('Setting design ID:'+design.learningDesignID,Debugger.GEN,'setDesign','DesignDataModel'); - Debugger.log('Printing the design revieced:...\n'+ObjectUtils.toString(design),Debugger.VERBOSE,'setDesign','DesignDataModel'); - - _learningDesignID = design.learningDesignID; - _title = design.title; - _description = design.description; - _helpText = design.helpText; - _version = design.version; - _designVersion = design.designVersion; - - _userID = design.userID; - _editOverrideUserID = design.editOverrideUserID; - _editOverrideUserFullName = design.editOverrideUserFullName; - _workspaceFolderID = design.workspaceFolderID; - _createDateTime = design.createDateTime; - _readOnly = design.readOnly; - _editOverrideLock = design.editOverrideLock; - _validDesign = design.validDesign; - - _maxID = design.maxID; - _firstActivityID = design.firstActivityUIID; - _copyTypeID = design.copyTypeID; - - _licenseID = design.licenseID; - _licenseText = design.licenseText; - - _contentFolderID = design.contentFolderID; - - //set the activities in the hash table - for(var i=0; i 0){ - - for(var i=0; i 0) - for(var i=0; i 0) - for(var i=0; i 0) { - for (var i=0; i 0) - for(var i=0; i 0) - mappingsToRemove.push(Array(mappings.toolBased)); - - if(mappings.choosenBased.length > 0) - mappingsToRemove.push(Array(mappings.choosenBased)); - - for(var j=0; j 0) - mappingsToRemove.push(Array(mappings.groupBased)); - - if(mappings.choosenBased.length > 0) - mappingsToRemove.push(Array(mappings.choosenBased)); - - for(var j=0; j 0) - v = false; - - if(remove && !v) - removeEntries(mappingsToRemove); - - return !v; - - } - - public function removeEntries(e:Array) { - for(var i=0; i 0) { + removeComplexActivity(_children[i].activityUIID, _nChildren, removeTrans); + } else { + removeActivity(_children[i].activityUIID); + if(removeTrans) removeTransitionByConnection(_children[i].activityUIID); + } + + } + + removeActivity(activityUIID); + if(removeTrans) removeTransitionByConnection(_children[i].activityUIID); + + } + + /** + * Adds a transition to the DDM + * @usage + * @param transition + * @return + */ + public function addTransition(transition:Transition):Boolean{ + //dispatch an event to show the design has changed + dispatchEvent({type:'ddmBeforeUpdate',target:this}); + + Debugger.log('Transition from:'+transition.fromUIID+', to:'+transition.toUIID,4,'addTransition','DesignDataModel'); + _transitions.put(transition.transitionUIID,transition); + dispatchEvent({type:'ddmUpdate',target:this}); + + //TODO some validation would be nice + + return true; + } + + /** + * Removes the transition from the DDM + * @usage + * @param transitionUIID + * @return + */ + public function removeTransition(transitionUIID):Object{ + //dispatch an event to show the design has changed + dispatchEvent({type:'ddmBeforeUpdate',target:this}); + + var r:Object = _transitions.remove(transitionUIID); + if(r==null){ + return new LFError("Removing transition failed:"+transitionUIID,"removeTransition",this,null); + }else{ + Debugger.log('Removed:'+r.transitionUIID,Debugger.GEN,'removeTransition','DesignDataModel'); + dispatchEvent({type:'ddmUpdate',target:this}); + } + } + + /** + * Removes the transitions from the DDM which are connected to the Activity + * + * @param connectUIID connected Activity UIID + */ + + public function removeTransitionByConnection(connectUIID):Void{ + var keyArray:Array = _transitions.keys(); + for(var i=0; i.setDesign(design:Object) + * @param design + * @return success + */ + public function setDesign(design:Object):Boolean{ + //note the design must be empty to call this + //note: Dont fire the update event as we dont want to store this change in an undo! + + //TODO: Validate that the design is clear + var success:Boolean = false; + + //TODO:Validate if design is saved if not notify user + success = true; + + Debugger.log('Setting design ID:'+design.learningDesignID,Debugger.GEN,'setDesign','DesignDataModel'); + Debugger.log('Printing the design revieced:...\n'+ObjectUtils.toString(design),Debugger.VERBOSE,'setDesign','DesignDataModel'); + + _learningDesignID = design.learningDesignID; + _title = design.title; + _description = design.description; + _helpText = design.helpText; + _version = design.version; + _designVersion = design.designVersion; + + _userID = design.userID; + _editOverrideUserID = design.editOverrideUserID; + _editOverrideUserFullName = design.editOverrideUserFullName; + _workspaceFolderID = design.workspaceFolderID; + _createDateTime = design.createDateTime; + _readOnly = design.readOnly; + _editOverrideLock = design.editOverrideLock; + _validDesign = design.validDesign; + + _maxID = design.maxID; + _firstActivityID = design.firstActivityUIID; + _copyTypeID = design.copyTypeID; + + _licenseID = design.licenseID; + _licenseText = design.licenseText; + + _contentFolderID = design.contentFolderID; + + //set the activities in the hash table + for(var i=0; i 0){ + + for(var i=0; i 0) + for(var i=0; i 0) + for(var i=0; i 0) { + for (var i=0; i 0) + for(var i=0; i 0) + mappingsToRemove.push(Array(mappings.toolBased)); + + if(mappings.choosenBased.length > 0) + mappingsToRemove.push(Array(mappings.choosenBased)); + + for(var j=0; j 0) + mappingsToRemove.push(Array(mappings.groupBased)); + + if(mappings.choosenBased.length > 0) + mappingsToRemove.push(Array(mappings.choosenBased)); + + for(var j=0; j 0) + v = false; + + if(remove && !v) + removeEntries(mappingsToRemove); + + return !v; + + } + + public function removeEntries(e:Array) { + for(var i=0; i 0) - return _children[0].orderID+1; - else - return 1; - } - - public function getValidTransitionsKeys():Array { - var keys:Array = transitions.keys(); - var keysToSend:Array = new Array(); - - for(var i=0; i 0) + return _children[0].orderID+1; + else + return 1; + } + + public function getValidTransitionsKeys():Array { + var keys:Array = transitions.keys(); + var keysToSend:Array = new Array(); + + for(var i=0; i 0) ? _numberOfGroups : Config.NUMERIC_NULL_VALUE; - dto.maxNumberOfGroups = (_maxNumberOfGroups > 0) ? _maxNumberOfGroups : Config.NUMERIC_NULL_VALUE; - dto.equalNumberOfLearnersPerGroup = (_equalGroupSizes != null && _equalGroupSizes != undefined) ? equalGroupSizes : Config.BOOLEAN_NULL_VALUE; - dto.learnersPerGroup = (_learnersPerGroups > 0) ? _learnersPerGroups : Config.NUMERIC_NULL_VALUE; - - dto.groups = new Array(); - - var groupTotal = (groupingTypeID == RANDOM_GROUPING || groupingTypeID == LEARNER_CHOICE_GROUPING) ? numberOfGroups : maxNumberOfGroups; - if(groupTotal == 0) _groups.clear(); - - var groups:Array = getGroups(_ddm); - - if(groups.length > 0){ - for(var i=0; i 0) - return groups; - - if(groupDiff >= 0) { - for(var i=0; i 0) ? new Group(this.groupingUIID, null, _ddm.newUIID(), "Group " + Number(groups.length + i + 1), Number(groups.length+i)) - : new Group(this.groupingUIID, null, _ddm.newUIID(), "Group " + Number(i+1), i); - addGroup(group); - } - } else { - for(var i=-1; i>=groupDiff; i--) { - _ddm.removeBranchMappingsByGroupUIID(groups[groups.length+i].groupUIID); - _groups.remove(groups[groups.length+i].groupUIID); - } - } - - return _groups.values(); - - } - - public function updateGroups(groups:Array):Void { - for(var i=0; i 0) ? _numberOfGroups : Config.NUMERIC_NULL_VALUE; + dto.maxNumberOfGroups = (_maxNumberOfGroups > 0) ? _maxNumberOfGroups : Config.NUMERIC_NULL_VALUE; + dto.equalNumberOfLearnersPerGroup = (_equalGroupSizes != null && _equalGroupSizes != undefined) ? equalGroupSizes : Config.BOOLEAN_NULL_VALUE; + dto.learnersPerGroup = (_learnersPerGroups > 0) ? _learnersPerGroups : Config.NUMERIC_NULL_VALUE; + + dto.groups = new Array(); + + var groupTotal = (groupingTypeID == RANDOM_GROUPING || groupingTypeID == LEARNER_CHOICE_GROUPING) ? numberOfGroups : maxNumberOfGroups; + if(groupTotal == 0) _groups.clear(); + + var groups:Array = getGroups(_ddm); + + if(groups.length > 0){ + for(var i=0; i 0) + return groups; + + if(groupDiff >= 0) { + for(var i=0; i 0) ? new Group(this.groupingUIID, null, _ddm.newUIID(), "Group " + Number(groups.length + i + 1), Number(groups.length+i)) + : new Group(this.groupingUIID, null, _ddm.newUIID(), "Group " + Number(i+1), i); + addGroup(group); + } + } else { + for(var i=-1; i>=groupDiff; i--) { + _ddm.removeBranchMappingsByGroupUIID(groups[groups.length+i].groupUIID); + _groups.remove(groups[groups.length+i].groupUIID); + } + } + + return _groups.values(); + + } + + public function updateGroups(groups:Array):Void { + for(var i=0; i -* public static var SEQUENCE_ACTIVITY_TYPE:Number = 8; -* -* @author Mitchell Seaton -* @version 2.1 -* @see Activity -*/ -class SequenceActivity extends ComplexActivity { - - private var _empty:Boolean; - private var _default:Boolean; - - function SequenceActivity(activityUIID:Number){ - super(activityUIID); - _activityTypeID = SEQUENCE_ACTIVITY_TYPE; - _empty = true; - _default = false; - } - - /** - * Creates a complex activity from a dto... which is nice - * @usage - * @param dto - * @return - */ - public function populateFromDTO(dto:Object){ - super.populateFromDTO(dto); - } - - /** - * Creates an object containing all the props of the ComplexActivity. - * If a value is null then it is ommitted... if itsd the null value from const - * then its included - * @usage - * @return the DTO - */ - public function toData():Object{ - if(_empty && _default) - return null; - - var dto:Object = super.toData(); - - return dto; - } - - /** - * Creates an exact copy of this SequenceActivity - * @usage - * @return the copy - */ - public function clone():SequenceActivity{ - var dto:Object = toData(); - if(dto != null) { - var sa = new SequenceActivity(); - sa.populateFromDTO(dto); - - return sa; - } - - return null; - } - - public function set firstActivityUIID(a:Number):Void { - _firstActivityUIID = a; - - if(a != null) - _empty = false; - else - _empty = true; - - } - - public function set empty(b:Boolean):Void{ - _empty = b; - } - - public function get empty():Boolean{ - return _empty; - } - - public function set isDefault(b:Boolean):Void { - _default = b; - } - - public function get isDefault():Boolean { - return _default; - } - -} - +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.common.util.Debugger; + +/* +* This class represents the sequence activity. +* For reference these are the activity types +*

+* public static var SEQUENCE_ACTIVITY_TYPE:Number = 8;
+* 
+* @author Mitchell Seaton +* @version 2.1 +* @see Activity +*/ +class SequenceActivity extends ComplexActivity { + + private var _empty:Boolean; + private var _default:Boolean; + + function SequenceActivity(activityUIID:Number){ + super(activityUIID); + _activityTypeID = SEQUENCE_ACTIVITY_TYPE; + _empty = true; + _default = false; + } + + /** + * Creates a complex activity from a dto... which is nice + * @usage + * @param dto + * @return + */ + public function populateFromDTO(dto:Object){ + super.populateFromDTO(dto); + } + + /** + * Creates an object containing all the props of the ComplexActivity. + * If a value is null then it is ommitted... if itsd the null value from const + * then its included + * @usage + * @return the DTO + */ + public function toData():Object{ + if(_empty && _default) + return null; + + var dto:Object = super.toData(); + + return dto; + } + + /** + * Creates an exact copy of this SequenceActivity + * @usage + * @return the copy + */ + public function clone():SequenceActivity{ + var dto:Object = toData(); + if(dto != null) { + var sa = new SequenceActivity(); + sa.populateFromDTO(dto); + + return sa; + } + + return null; + } + + public function set firstActivityUIID(a:Number):Void { + _firstActivityUIID = a; + + if(a != null) + _empty = false; + else + _empty = true; + + } + + public function set empty(b:Boolean):Void{ + _empty = b; + } + + public function get empty():Boolean{ + return _empty; + } + + public function set isDefault(b:Boolean):Void { + _default = b; + } + + public function get isDefault():Boolean { + return _default; + } + +} + Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolActivity.as =================================================================== diff -u -r6071623eaaab7f58e5c1befe499b0fc1c76850dc -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolActivity.as (.../ToolActivity.as) (revision 6071623eaaab7f58e5c1befe499b0fc1c76850dc) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolActivity.as (.../ToolActivity.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -1,515 +1,515 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.common.dict.* -import org.lamsfoundation.lams.common.* -import org.lamsfoundation.lams.common.util.* -/* -* -* @author DC -* @version 0.1 -* @comments Tool Activity Data storage class. -* @see Activity -*/ -class ToolActivity extends Activity{ - - private var _authoringURL:String; - private var _monitoringURL:String; - private var _contributeURL:String; - private var _helpURL:String; - - private var _toolDisplayName:String; - private var _toolSignature:String; - - //generated by the LAMS server, has to do a round trip to populate them - private var _toolContentID:Number; - private var _toolID:Number; - - private var _extLmsId:String; //external LMS id for tool adapter tools - - //flags to tell UI which to disable - private var _supportsContribute:Boolean; - private var _supportsDefineLater:Boolean; - private var _supportsModeration:Boolean; - private var _supportsRunOffline:Boolean; - private var _supportsOutputs:Boolean; - - private var _competenceMappings:Array; // competences to which this activity is mapped - - private var _toolOutputDefinitions:Hashtable; - - function ToolActivity(activityUIID:Number){ - super(activityUIID); - - _objectType = "ToolActivity"; - - _activityTypeID = TOOL_ACTIVITY_TYPE; - _toolOutputDefinitions = new Hashtable("_toolOutputDefinitions"); - - _competenceMappings = new Array(); - } - - //TODO: ADD A VALIDATE() FUNCTION - - /** - * Pass an object with all the fields of a ToolActivity into this function to populate: - *

-	 * //activity properties:
-	 * _activityTypeID = dto.activityTypeID;
-	 * _activityID = dto.activityID;
-	 * _activityCategoryID = dto.activityCategoryID;
-	 * _activityUIID = dto.activityUIID;
-	 * _learningLibraryID = dto.learningLibraryID;
-	 * _learningDesignID = dto.learningDesignID;
-	 * _libraryActivityID = dto.libraryActivityID;
-	 * _parentActivityID = dto.parentActivityID;
-	 * _parentUIID = dto.parentUIID;
-	 * _orderID = dto.orderID;
-	 * _groupingID = dto.groupingID;
-	 * _groupingUIID = dto.groupingUIID;
-	 * _title = dto.title;
-	 * _description = dto.description;
-	 * _helpText =  dto.helpText;
-	 * _yCoord = dto.yCoord;
-	 * _xCoord = dto.xCoord;
-	 * _libraryActivityUIImage = dto.libraryActivityUIImage;
-	 * _applyGrouping = dto.applyGrouping;
-	 * _runOffline = dto.runOffline;
-	 * //now removed
-	 * //_offlineInstructions = dto.offlineInstructions;
-	 * //_onlineInstructions = dto.onlineInstructions;
-	 * _defineLater = dto.defineLater;
-	 * _createDateTime = dto.createDateTime;
-	 * _groupingSupportType = dto.groupingSupportType;
-	 * 
-	 * //Toolactivity class props
-	 * _authoringURL = dto.authoringURL;
-	 * _toolDisplayName = dto.toolDisplayName;
-	 * _toolContentID = dto.toolContentID;
-	 * _toolID = dto.toolID;
-	 * _supportsContribute = dto.supportsContribute;
-	 * _supportsDefineLater = dto.supportsDefineLater;
-	 * _supportsModeration = dto.supportsRunOffline;
-	 * 
- * @usage - * @param dto Object containing all ToolActivity fields: - * @return Noting - */ - public function populateFromDTO(dto:Object):Void{ - - //first do the super method for activity props - super.populateFromDTO(dto); - - //Tool Activity class props - if(StringUtils.isWDDXNull(dto.authoringURL)) { _authoringURL = null } - else { _authoringURL = dto.authoringURL; } - - if(StringUtils.isWDDXNull(dto.helpURL)) { _helpURL = null } - else { _helpURL = dto.helpURL; } - - if(StringUtils.isWDDXNull(dto.toolDisplayName)) { _toolDisplayName = null } - else { _toolDisplayName = dto.toolDisplayName; } - - if(StringUtils.isWDDXNull(dto.toolSignature)) { _toolSignature = null } - else { _toolSignature = dto.toolSignature; } - - if(StringUtils.isWDDXNull(dto.toolContentID)) { _toolContentID = null } - else { _toolContentID = dto.toolContentID; } - - if(StringUtils.isWDDXNull(dto.toolID)) { _toolID = null } - else { _toolID = dto.toolID; } - - if(StringUtils.isWDDXNull(dto.extLmsId)) { _extLmsId = null } - else { _extLmsId = dto.extLmsId; } - - _competenceMappings = new Array(); - if(!StringUtils.isWDDXNull(dto.competenceMappingTitles)) { - for (var i=0; i 0) { - for (var i=0; i<_competenceMappings.length; i++) { - dto.competenceMappings.push(_competenceMappings[i]); - } - } - - /* THESE are internal flags, not part of the design - dto.supportsContribute = (_supportsContribute!=null) ? _supportsContribute: Config.BOOLEAN_NULL_VALUE; - dto.supportsDefineLater = (_supportsDefineLater!=null) ? _supportsDefineLater: Config.BOOLEAN_NULL_VALUE; - dto.supportsModeration = (_supportsModeration!=null) ? _supportsModeration: Config.BOOLEAN_NULL_VALUE; - dto.supportsRunOffline = (_supportsRunOffline!=null) ? _supportsRunOffline: Config.BOOLEAN_NULL_VALUE; - */ - - return dto; - } - - public function clone():ToolActivity{ - //var n:Activity = super.clone(); - - var n:ToolActivity = new ToolActivity(null); - - //parents properties: - n.objectType = _objectType; - - n.activityTypeID = _activityTypeID; - n.activityID = _activityID; - n.activityCategoryID = _activityCategoryID; - n.activityUIID = _activityUIID; - n.learningLibraryID = _learningLibraryID; - n.learningDesignID = _learningDesignID; - n.libraryActivityID = _libraryActivityID; - n.parentActivityID = _parentActivityID; - n.parentUIID = _parentUIID - n.orderID = _orderID - n.groupingID = _groupingID; - n.groupingUIID = _groupingUIID - n.title = _title; - n.description = _description; - n.helpText = _helpText; - n.yCoord = _yCoord; - n.xCoord = _xCoord; - n.libraryActivityUIImage = _libraryActivityUIImage; - n.applyGrouping = _applyGrouping; - n.runOffline = _runOffline; - n.defineLater = _defineLater; - n.createDateTime = _createDateTime; - n.groupingSupportType = _groupingSupportType; - - //class props - n.authoringURL = _authoringURL; - n.helpURL = _helpURL; - n.toolDisplayName = _toolDisplayName; - n.toolSignature = _toolSignature; - n.toolContentID = _toolContentID; - n.toolID = _toolID; - - n.supportsContribute = _supportsContribute; - n.supportsDefineLater = _supportsDefineLater; - n.supportsModeration = _supportsRunOffline; - n.supportsOutputs = _supportsOutputs; - n.extLmsId = _extLmsId; - - return n; - - - } - - public function addDefinition(dto:Object):Void { - _toolOutputDefinitions.put(dto.name, dto); - } - - public function removeDefinition(key:String):Void { - _toolOutputDefinitions.remove(key); - } - - public function get definitions():Array { - return _toolOutputDefinitions.values(); - } - - public function get competenceMappings():Array { - return _competenceMappings - } - - //GETTERS + SETTERS - - /** - * - * @usage - * @param newauthoringurl - * @return - */ - public function set authoringURL (newauthoringurl:String):Void { - _authoringURL = newauthoringurl; - } - /** - * - * @usage - * @return - */ - public function get authoringURL ():String { - return _authoringURL; - } - - /** - * - * @usage - * @param newtoolDisplayName - * @return - */ - public function set toolDisplayName (newtoolDisplayName:String):Void { - _toolDisplayName = newtoolDisplayName; - } - /** - * - * @usage - * @return - */ - public function get toolDisplayName ():String { - return _toolDisplayName; - } - - /** - * - * @usage - * @param newtoolSignature - * @return - */ - public function set toolSignature (newtoolSignature:String):Void { - _toolSignature = newtoolSignature; - } - /** - * - * @usage - * @return - */ - public function get toolSignature ():String { - return _toolSignature; - } - - /** - * - * @usage - * @param newtoolContentID - * @return - */ - public function set toolContentID (newtoolContentID:Number):Void { - _toolContentID = newtoolContentID; - } - /** - * - * @usage - * @return - */ - public function get toolContentID ():Number { - return _toolContentID; - } - - /** - * - * @usage - * @param newtoolID - * @return - */ - public function set toolID (newtoolID:Number):Void { - _toolID = newtoolID; - } - /** - * - * @usage - * @return - */ - public function get toolID ():Number { - return _toolID; - } - - /** - * - * @usage - * @param newsupportsContribute - * @return - */ - public function set supportsContribute (newsupportsContribute:Boolean):Void { - _supportsContribute = newsupportsContribute; - } - /** - * - * @usage - * @return - */ - public function get supportsContribute ():Boolean { - return _supportsContribute; - } - - /** - * - * @usage - * @param newsupportsDefineLater - * @return - */ - public function set supportsDefineLater (newsupportsDefineLater:Boolean):Void { - _supportsDefineLater = newsupportsDefineLater; - } - /** - * - * @usage - * @return - */ - public function get supportsDefineLater ():Boolean { - return _supportsDefineLater; - } - - /** - * - * @usage - * @param newsupportsModeration - * @return - */ - public function set supportsModeration (newsupportsModeration:Boolean):Void { - _supportsModeration = newsupportsModeration; - } - /** - * - * @usage - * @return - */ - public function get supportsModeration ():Boolean { - return _supportsModeration; - } - - /** - * - * @usage - * @param newsupportsRunOffline - * @return - */ - public function set supportsRunOffline (newsupportsRunOffline:Boolean):Void { - _supportsRunOffline = newsupportsRunOffline; - } - /** - * - * @usage - * @return - */ - public function get supportsRunOffline ():Boolean { - return _supportsRunOffline; - } - - /** - * - * @usage - * @param newsupportsRunOffline - * @return - */ - public function set supportsOutputs (newsupportsOutputs:Boolean):Void { - _supportsOutputs = newsupportsOutputs; - } - /** - * - * @usage - * @return - */ - public function get supportsOutputs ():Boolean { - return _supportsOutputs; - } - - /** - * - * @usage - * @param newmonitoringUrl - * @return - */ - public function set monitoringUrl (newmonitoringUrl:String):Void { - _monitoringURL = newmonitoringUrl; - } - /** - * - * @usage - * @return - */ - public function get monitoringUrl ():String { - return _monitoringURL; - } - - /** - * - * @usage - * @param newcontributeUrl - * @return - */ - public function set contributeUrl (newcontributeUrl:String):Void { - _contributeURL = newcontributeUrl; - } - /** - * - * @usage - * @return - */ - public function get contributeUrl ():String { - return _contributeURL; - } - - - /** - * - * @usage - * @param newhelpurl - * @return - */ - public function set helpURL (newhelpurl:String):Void { - _helpURL = newhelpurl; - } - /** - * - * @usage - * @return - */ - public function get helpURL ():String { - return _helpURL; - } - - /** - * - * @usage - * @param str - * @return - */ - public function set extLmsId (str:String):Void { - _extLmsId = str; - } - /** - * - * @usage - * @return - */ - public function get extLmsId ():String { - return _extLmsId; - } -} - +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.common.dict.* +import org.lamsfoundation.lams.common.* +import org.lamsfoundation.lams.common.util.* +/* +* +* @author DC +* @version 0.1 +* @comments Tool Activity Data storage class. +* @see Activity +*/ +class ToolActivity extends Activity{ + + private var _authoringURL:String; + private var _monitoringURL:String; + private var _contributeURL:String; + private var _helpURL:String; + + private var _toolDisplayName:String; + private var _toolSignature:String; + + //generated by the LAMS server, has to do a round trip to populate them + private var _toolContentID:Number; + private var _toolID:Number; + + private var _extLmsId:String; //external LMS id for tool adapter tools + + //flags to tell UI which to disable + private var _supportsContribute:Boolean; + private var _supportsDefineLater:Boolean; + private var _supportsModeration:Boolean; + private var _supportsRunOffline:Boolean; + private var _supportsOutputs:Boolean; + + private var _competenceMappings:Array; // competences to which this activity is mapped + + private var _toolOutputDefinitions:Hashtable; + + function ToolActivity(activityUIID:Number){ + super(activityUIID); + + _objectType = "ToolActivity"; + + _activityTypeID = TOOL_ACTIVITY_TYPE; + _toolOutputDefinitions = new Hashtable("_toolOutputDefinitions"); + + _competenceMappings = new Array(); + } + + //TODO: ADD A VALIDATE() FUNCTION + + /** + * Pass an object with all the fields of a ToolActivity into this function to populate: + *

+	 * //activity properties:
+	 * _activityTypeID = dto.activityTypeID;
+	 * _activityID = dto.activityID;
+	 * _activityCategoryID = dto.activityCategoryID;
+	 * _activityUIID = dto.activityUIID;
+	 * _learningLibraryID = dto.learningLibraryID;
+	 * _learningDesignID = dto.learningDesignID;
+	 * _libraryActivityID = dto.libraryActivityID;
+	 * _parentActivityID = dto.parentActivityID;
+	 * _parentUIID = dto.parentUIID;
+	 * _orderID = dto.orderID;
+	 * _groupingID = dto.groupingID;
+	 * _groupingUIID = dto.groupingUIID;
+	 * _title = dto.title;
+	 * _description = dto.description;
+	 * _helpText =  dto.helpText;
+	 * _yCoord = dto.yCoord;
+	 * _xCoord = dto.xCoord;
+	 * _libraryActivityUIImage = dto.libraryActivityUIImage;
+	 * _applyGrouping = dto.applyGrouping;
+	 * _runOffline = dto.runOffline;
+	 * //now removed
+	 * //_offlineInstructions = dto.offlineInstructions;
+	 * //_onlineInstructions = dto.onlineInstructions;
+	 * _defineLater = dto.defineLater;
+	 * _createDateTime = dto.createDateTime;
+	 * _groupingSupportType = dto.groupingSupportType;
+	 * 
+	 * //Toolactivity class props
+	 * _authoringURL = dto.authoringURL;
+	 * _toolDisplayName = dto.toolDisplayName;
+	 * _toolContentID = dto.toolContentID;
+	 * _toolID = dto.toolID;
+	 * _supportsContribute = dto.supportsContribute;
+	 * _supportsDefineLater = dto.supportsDefineLater;
+	 * _supportsModeration = dto.supportsRunOffline;
+	 * 
+ * @usage + * @param dto Object containing all ToolActivity fields: + * @return Noting + */ + public function populateFromDTO(dto:Object):Void{ + + //first do the super method for activity props + super.populateFromDTO(dto); + + //Tool Activity class props + if(StringUtils.isWDDXNull(dto.authoringURL)) { _authoringURL = null } + else { _authoringURL = dto.authoringURL; } + + if(StringUtils.isWDDXNull(dto.helpURL)) { _helpURL = null } + else { _helpURL = dto.helpURL; } + + if(StringUtils.isWDDXNull(dto.toolDisplayName)) { _toolDisplayName = null } + else { _toolDisplayName = dto.toolDisplayName; } + + if(StringUtils.isWDDXNull(dto.toolSignature)) { _toolSignature = null } + else { _toolSignature = dto.toolSignature; } + + if(StringUtils.isWDDXNull(dto.toolContentID)) { _toolContentID = null } + else { _toolContentID = dto.toolContentID; } + + if(StringUtils.isWDDXNull(dto.toolID)) { _toolID = null } + else { _toolID = dto.toolID; } + + if(StringUtils.isWDDXNull(dto.extLmsId)) { _extLmsId = null } + else { _extLmsId = dto.extLmsId; } + + _competenceMappings = new Array(); + if(!StringUtils.isWDDXNull(dto.competenceMappingTitles)) { + for (var i=0; i 0) { + for (var i=0; i<_competenceMappings.length; i++) { + dto.competenceMappings.push(_competenceMappings[i]); + } + } + + /* THESE are internal flags, not part of the design + dto.supportsContribute = (_supportsContribute!=null) ? _supportsContribute: Config.BOOLEAN_NULL_VALUE; + dto.supportsDefineLater = (_supportsDefineLater!=null) ? _supportsDefineLater: Config.BOOLEAN_NULL_VALUE; + dto.supportsModeration = (_supportsModeration!=null) ? _supportsModeration: Config.BOOLEAN_NULL_VALUE; + dto.supportsRunOffline = (_supportsRunOffline!=null) ? _supportsRunOffline: Config.BOOLEAN_NULL_VALUE; + */ + + return dto; + } + + public function clone():ToolActivity{ + //var n:Activity = super.clone(); + + var n:ToolActivity = new ToolActivity(null); + + //parents properties: + n.objectType = _objectType; + + n.activityTypeID = _activityTypeID; + n.activityID = _activityID; + n.activityCategoryID = _activityCategoryID; + n.activityUIID = _activityUIID; + n.learningLibraryID = _learningLibraryID; + n.learningDesignID = _learningDesignID; + n.libraryActivityID = _libraryActivityID; + n.parentActivityID = _parentActivityID; + n.parentUIID = _parentUIID + n.orderID = _orderID + n.groupingID = _groupingID; + n.groupingUIID = _groupingUIID + n.title = _title; + n.description = _description; + n.helpText = _helpText; + n.yCoord = _yCoord; + n.xCoord = _xCoord; + n.libraryActivityUIImage = _libraryActivityUIImage; + n.applyGrouping = _applyGrouping; + n.runOffline = _runOffline; + n.defineLater = _defineLater; + n.createDateTime = _createDateTime; + n.groupingSupportType = _groupingSupportType; + + //class props + n.authoringURL = _authoringURL; + n.helpURL = _helpURL; + n.toolDisplayName = _toolDisplayName; + n.toolSignature = _toolSignature; + n.toolContentID = _toolContentID; + n.toolID = _toolID; + + n.supportsContribute = _supportsContribute; + n.supportsDefineLater = _supportsDefineLater; + n.supportsModeration = _supportsRunOffline; + n.supportsOutputs = _supportsOutputs; + n.extLmsId = _extLmsId; + + return n; + + + } + + public function addDefinition(dto:Object):Void { + _toolOutputDefinitions.put(dto.name, dto); + } + + public function removeDefinition(key:String):Void { + _toolOutputDefinitions.remove(key); + } + + public function get definitions():Array { + return _toolOutputDefinitions.values(); + } + + public function get competenceMappings():Array { + return _competenceMappings + } + + //GETTERS + SETTERS + + /** + * + * @usage + * @param newauthoringurl + * @return + */ + public function set authoringURL (newauthoringurl:String):Void { + _authoringURL = newauthoringurl; + } + /** + * + * @usage + * @return + */ + public function get authoringURL ():String { + return _authoringURL; + } + + /** + * + * @usage + * @param newtoolDisplayName + * @return + */ + public function set toolDisplayName (newtoolDisplayName:String):Void { + _toolDisplayName = newtoolDisplayName; + } + /** + * + * @usage + * @return + */ + public function get toolDisplayName ():String { + return _toolDisplayName; + } + + /** + * + * @usage + * @param newtoolSignature + * @return + */ + public function set toolSignature (newtoolSignature:String):Void { + _toolSignature = newtoolSignature; + } + /** + * + * @usage + * @return + */ + public function get toolSignature ():String { + return _toolSignature; + } + + /** + * + * @usage + * @param newtoolContentID + * @return + */ + public function set toolContentID (newtoolContentID:Number):Void { + _toolContentID = newtoolContentID; + } + /** + * + * @usage + * @return + */ + public function get toolContentID ():Number { + return _toolContentID; + } + + /** + * + * @usage + * @param newtoolID + * @return + */ + public function set toolID (newtoolID:Number):Void { + _toolID = newtoolID; + } + /** + * + * @usage + * @return + */ + public function get toolID ():Number { + return _toolID; + } + + /** + * + * @usage + * @param newsupportsContribute + * @return + */ + public function set supportsContribute (newsupportsContribute:Boolean):Void { + _supportsContribute = newsupportsContribute; + } + /** + * + * @usage + * @return + */ + public function get supportsContribute ():Boolean { + return _supportsContribute; + } + + /** + * + * @usage + * @param newsupportsDefineLater + * @return + */ + public function set supportsDefineLater (newsupportsDefineLater:Boolean):Void { + _supportsDefineLater = newsupportsDefineLater; + } + /** + * + * @usage + * @return + */ + public function get supportsDefineLater ():Boolean { + return _supportsDefineLater; + } + + /** + * + * @usage + * @param newsupportsModeration + * @return + */ + public function set supportsModeration (newsupportsModeration:Boolean):Void { + _supportsModeration = newsupportsModeration; + } + /** + * + * @usage + * @return + */ + public function get supportsModeration ():Boolean { + return _supportsModeration; + } + + /** + * + * @usage + * @param newsupportsRunOffline + * @return + */ + public function set supportsRunOffline (newsupportsRunOffline:Boolean):Void { + _supportsRunOffline = newsupportsRunOffline; + } + /** + * + * @usage + * @return + */ + public function get supportsRunOffline ():Boolean { + return _supportsRunOffline; + } + + /** + * + * @usage + * @param newsupportsRunOffline + * @return + */ + public function set supportsOutputs (newsupportsOutputs:Boolean):Void { + _supportsOutputs = newsupportsOutputs; + } + /** + * + * @usage + * @return + */ + public function get supportsOutputs ():Boolean { + return _supportsOutputs; + } + + /** + * + * @usage + * @param newmonitoringUrl + * @return + */ + public function set monitoringUrl (newmonitoringUrl:String):Void { + _monitoringURL = newmonitoringUrl; + } + /** + * + * @usage + * @return + */ + public function get monitoringUrl ():String { + return _monitoringURL; + } + + /** + * + * @usage + * @param newcontributeUrl + * @return + */ + public function set contributeUrl (newcontributeUrl:String):Void { + _contributeURL = newcontributeUrl; + } + /** + * + * @usage + * @return + */ + public function get contributeUrl ():String { + return _contributeURL; + } + + + /** + * + * @usage + * @param newhelpurl + * @return + */ + public function set helpURL (newhelpurl:String):Void { + _helpURL = newhelpurl; + } + /** + * + * @usage + * @return + */ + public function get helpURL ():String { + return _helpURL; + } + + /** + * + * @usage + * @param str + * @return + */ + public function set extLmsId (str:String):Void { + _extLmsId = str; + } + /** + * + * @usage + * @return + */ + public function get extLmsId ():String { + return _extLmsId; + } +} + Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputBranchActivityEntry.as =================================================================== diff -u -rda1644d8e66121854689bf4c74caa46457502601 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputBranchActivityEntry.as (.../ToolOutputBranchActivityEntry.as) (revision da1644d8e66121854689bf4c74caa46457502601) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputBranchActivityEntry.as (.../ToolOutputBranchActivityEntry.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -29,16 +29,16 @@ * @version 2.1 **/ class ToolOutputBranchActivityEntry extends BranchActivityEntry { - + private var _condition:ToolOutputCondition; function ToolOutputBranchActivityEntry(entryID:Number, entryUIID:Number, condition:ToolOutputCondition, sequenceActivity:SequenceActivity, branchingActivity:BranchingActivity){ - this.entryID = entryID; - this.entryUIID = entryUIID; - this.sequenceActivity = sequenceActivity; - this.branchingActivity = branchingActivity; - - this.condition = condition; + this.entryID = entryID; + this.entryUIID = entryUIID; + this.sequenceActivity = sequenceActivity; + this.branchingActivity = branchingActivity; + + this.condition = condition; this.condition.branchingActivity = branchingActivity; } @@ -49,22 +49,22 @@ if(this.entryUIID) dto.entryUIID = this.entryUIID; if(this.sequenceActivity) dto.sequenceActivityUIID = this.sequenceActivity.activityUIID; if(this.branchingActivity) dto.branchingActivityUIID = this.branchingActivity.activityUIID; - + if(this.condition) dto.condition = _condition.toData(dto); return dto; } - public function get condition():ToolOutputCondition { - return _condition; - } - - public function set condition(a:ToolOutputCondition):Void { - _condition = a; - } - - public function get displayName():String { - return _condition.displayName; - } + public function get condition():ToolOutputCondition { + return _condition; + } + public function set condition(a:ToolOutputCondition):Void { + _condition = a; + } + + public function get displayName():String { + return _condition.displayName; + } + } \ No newline at end of file Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputCondition.as =================================================================== diff -u -r502e88647db22fac6375117685082590023dd682 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputCondition.as (.../ToolOutputCondition.as) (revision 502e88647db22fac6375117685082590023dd682) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputCondition.as (.../ToolOutputCondition.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -21,8 +21,8 @@ * ************************************************************************ */ -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.common.Config; +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.common.Config; import org.lamsfoundation.lams.common.util.Debugger; /** @@ -36,121 +36,121 @@ private var _conditionUIID:Number; private var _orderID:Number; - private var _name:String; + private var _name:String; private var _display_name:String; private var _type:String; private var _startValue:Object; private var _endValue:Object; private var _exactMatchValue:Object; - - private var _branchingActivity:BranchingActivity; - private var _toolActivity:ToolActivity; - - private var _isDefault:Boolean; + private var _branchingActivity:BranchingActivity; + private var _toolActivity:ToolActivity; + + private var _isDefault:Boolean; + function ToolOutputCondition(conditionID:Number, conditionUIID:Number, name:String, type:String, startValue:Object, endValue:Object, exactMatchValue:Object, displayName:String){ _conditionID = conditionID; _conditionUIID = conditionUIID; - _orderID = 1; + _orderID = 1; _type = type; _name = name; _startValue = startValue; _endValue = endValue; - _exactMatchValue = exactMatchValue; - - _display_name = displayName; - + _exactMatchValue = exactMatchValue; + + _display_name = displayName; + _isDefault = false; - } - - public static function createBoolCondition(UIID:Number, definition:ToolOutputDefinition, toolActivity:ToolActivity, branchingActivity:BranchingActivity, value:Boolean):ToolOutputCondition { - var condition:ToolOutputCondition = new ToolOutputCondition(); - condition.conditionUIID = UIID; - - if(definition.type == ToolOutputDefinition.BOOL) { - condition.type = definition.type; - condition.name = definition.name; - condition.displayName = definition.type + " (" + String(value) + ") "; - condition.exactMatchValue = value; - condition.toolActivity = toolActivity; - condition.branchingActivity = branchingActivity; - } - - return condition; - } - - public static function createLongCondition(UIID:Number, displayName:String, definition:ToolOutputDefinition, toolActivity:ToolActivity, branchingActivity:BranchingActivity, startValue:Number, endValue:Number):ToolOutputCondition { - var condition:ToolOutputCondition = new ToolOutputCondition(); - condition.conditionUIID = UIID; - - if(definition.type == ToolOutputDefinition.LONG) { - condition.name = definition.name; - condition.type = definition.type; - condition.displayName = displayName; - - if(startValue == endValue) { - condition.exactMatchValue = startValue; - } else { - condition.startValue = startValue; - condition.endValue = endValue; - } - - condition.toolActivity = toolActivity; - condition.branchingActivity = branchingActivity; - } - - return condition; } - - public function populateFromDTO(dto:Object):Void { - _conditionID = dto.conditionId; - _conditionUIID = dto.conditionUIID; - - _orderID = dto.orderID; - _name = dto.name; - _display_name = dto.displayName; - _type = dto.type; - _startValue = dto.startValue; - _endValue = dto.endValue; - _exactMatchValue = dto.exactMatchValue; - } - public function toData():Object { - var dto:Object = new Object(); - - if(_conditionID) dto.conditionId = conditionID; - if(_conditionUIID) dto.conditionUIID = _conditionUIID; + public static function createBoolCondition(UIID:Number, definition:ToolOutputDefinition, toolActivity:ToolActivity, branchingActivity:BranchingActivity, value:Boolean):ToolOutputCondition { + var condition:ToolOutputCondition = new ToolOutputCondition(); + condition.conditionUIID = UIID; + if(definition.type == ToolOutputDefinition.BOOL) { + condition.type = definition.type; + condition.name = definition.name; + condition.displayName = definition.type + " (" + String(value) + ") "; + condition.exactMatchValue = value; + condition.toolActivity = toolActivity; + condition.branchingActivity = branchingActivity; + } + + return condition; + } + + public static function createLongCondition(UIID:Number, displayName:String, definition:ToolOutputDefinition, toolActivity:ToolActivity, branchingActivity:BranchingActivity, startValue:Number, endValue:Number):ToolOutputCondition { + var condition:ToolOutputCondition = new ToolOutputCondition(); + condition.conditionUIID = UIID; + + if(definition.type == ToolOutputDefinition.LONG) { + condition.name = definition.name; + condition.type = definition.type; + condition.displayName = displayName; + + if(startValue == endValue) { + condition.exactMatchValue = startValue; + } else { + condition.startValue = startValue; + condition.endValue = endValue; + } + + condition.toolActivity = toolActivity; + condition.branchingActivity = branchingActivity; + } + + return condition; + } + + public function populateFromDTO(dto:Object):Void { + _conditionID = dto.conditionId; + _conditionUIID = dto.conditionUIID; + + _orderID = dto.orderID; + _name = dto.name; + _display_name = dto.displayName; + _type = dto.type; + _startValue = dto.startValue; + _endValue = dto.endValue; + _exactMatchValue = dto.exactMatchValue; + } + + public function toData():Object { + var dto:Object = new Object(); + + if(_conditionID) dto.conditionId = conditionID; + if(_conditionUIID) dto.conditionUIID = _conditionUIID; + if(_orderID) dto.orderID = _orderID; - if(_name) dto.name = _name; + if(_name) dto.name = _name; if(_display_name) dto.displayName = _display_name; if(_type) dto.type = _type; - - Debugger.log("start value: " + _startValue, Debugger.CRITICAL, "toData", "ToolOutputCondition"); - Debugger.log("end value: " + _endValue, Debugger.CRITICAL, "toData", "ToolOutputCondition"); - Debugger.log("exact value: " + _exactMatchValue, Debugger.CRITICAL, "toData", "ToolOutputCondition"); - + + Debugger.log("start value: " + _startValue, Debugger.CRITICAL, "toData", "ToolOutputCondition"); + Debugger.log("end value: " + _endValue, Debugger.CRITICAL, "toData", "ToolOutputCondition"); + Debugger.log("exact value: " + _exactMatchValue, Debugger.CRITICAL, "toData", "ToolOutputCondition"); + dto.startValue = (_startValue != null || _startValue instanceof Number) ? _startValue : Config.STRING_NULL_VALUE; - dto.endValue = (_endValue != null || _startValue instanceof Number) ? _endValue : Config.STRING_NULL_VALUE; + dto.endValue = (_endValue != null || _startValue instanceof Number) ? _endValue : Config.STRING_NULL_VALUE; dto.exactMatchValue = (_exactMatchValue != null || _startValue instanceof Number) ? _exactMatchValue : Config.STRING_NULL_VALUE; return dto; } public function set conditionID(a:Number) { - _conditionID = a; + _conditionID = a; } public function get conditionID():Number { - return _conditionID; + return _conditionID; } public function set conditionUIID(a:Number) { - _conditionUIID = a; + _conditionUIID = a; } public function get conditionUIID():Number { - return _conditionUIID; + return _conditionUIID; } public function set name(a:String) { @@ -159,16 +159,16 @@ public function get name():String { return _name; - } - - public function set displayName(a:String) { - _display_name = a; - } - - public function get displayName():String { - return _display_name; } + public function set displayName(a:String) { + _display_name = a; + } + + public function get displayName():String { + return _display_name; + } + public function set type(a:String) { _type = a; } @@ -207,30 +207,30 @@ public function get orderID():Number { return _orderID; - } - - public function set toolActivity(a:ToolActivity) { - _toolActivity = a; - } - - public function get toolActivity():ToolActivity { - return _toolActivity; - } - - public function set branchingActivity(a:BranchingActivity) { - _branchingActivity = a; - } - - public function get branchingActivity():BranchingActivity { - return _branchingActivity; } - - public function set isDefault(a:Boolean) { - _isDefault = a; - } - - public function get isDefault():Boolean { - return _isDefault; + + public function set toolActivity(a:ToolActivity) { + _toolActivity = a; } + + public function get toolActivity():ToolActivity { + return _toolActivity; + } + + public function set branchingActivity(a:BranchingActivity) { + _branchingActivity = a; + } + + public function get branchingActivity():BranchingActivity { + return _branchingActivity; + } + public function set isDefault(a:Boolean) { + _isDefault = a; + } + + public function get isDefault():Boolean { + return _isDefault; + } + } \ No newline at end of file Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputDefinition.as =================================================================== diff -u -r502e88647db22fac6375117685082590023dd682 -r7b65bab3de4ed5068c5631a245c30cb4eaa8f098 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputDefinition.as (.../ToolOutputDefinition.as) (revision 502e88647db22fac6375117685082590023dd682) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/ToolOutputDefinition.as (.../ToolOutputDefinition.as) (revision 7b65bab3de4ed5068c5631a245c30cb4eaa8f098) @@ -28,49 +28,49 @@ * @author Mitchell Seaton * @version 2.1 **/ -class ToolOutputDefinition { - - public static var LONG:String = "OUTPUT_LONG"; - public static var BOOL:String = "OUTPUT_BOOLEAN"; - public static var USER_DEFINED:String = "OUTPUT_SET_BOOLEAN"; - public static var COMPLEX:String = "OUTPUT_COMPLEX"; +class ToolOutputDefinition { - private var _name:String; + public static var LONG:String = "OUTPUT_LONG"; + public static var BOOL:String = "OUTPUT_BOOLEAN"; + public static var USER_DEFINED:String = "OUTPUT_SET_BOOLEAN"; + public static var COMPLEX:String = "OUTPUT_COMPLEX"; + + private var _name:String; private var _description:String; private var _type:String; private var _startValue:Object; - private var _endValue:Object; - private var _complexDefinition:Object; - private var _defaultConditions:Array; + private var _endValue:Object; + private var _complexDefinition:Object; + private var _defaultConditions:Array; private var _showConditionNameOnly:Boolean; - function ToolOutputDefinition(){ + function ToolOutputDefinition(){ _defaultConditions = new Array(); - } - - public function populateFromDTO(dto:Object):Void { - _name = dto.name; - _description = dto.description; - _type = dto.type; - _startValue = dto.startValue; - _endValue = dto.endValue; - if(dto.defaultConditions) { - for(var i=0; i