Esempio n. 1
0
 public void EditPropertiesTest([Values("ControlMode",
                                        "LimitConditions",
                                        "ConstrainedChoiceConsiderations",
                                        "RandomizationControls",
                                        "DeliveryControls",
                                        "RollupRules",
                                        "RollupConsiderations")]
                                string type)
 {
     try
     {
         // create new node with name "SomeNode", id=ID, courseId=1, and add it to storage
         this.createNode();
         // create new xml serializer
         var xml = new XmlSerializer(typeof(Sequencing));
         // get Sequencing from node with id = ID
         var xelement = this.Storage.GetNode(ID).Sequencing;
         // deserialize sequencing from xelement
         var sequencing = xelement == null ? new Sequencing() : (Sequencing)xml.DeserializeXElement(xelement);
         // new model
         object model;
         // for different type initialise sequencing property
         if (type == "ControlMode")
         {
             model = new ControlMode();
             
             //TryUpdateModel(model as ControlMode);
             sequencing.ControlMode = model as ControlMode;
         }
         else if (type == "LimitConditions")
         {
             model = new LimitConditions();
             //TryUpdateModel(model as LimitConditions);
             sequencing.LimitConditions = model as LimitConditions;
         }
         else if (type == "ConstrainedChoiceConsiderations")
         {
             model = new ConstrainedChoiceConsiderations();
             //TryUpdateModel(model as ConstrainedChoiceConsiderations);
             sequencing.ConstrainedChoiceConsiderations = model as ConstrainedChoiceConsiderations;
         }
         else if (type == "RandomizationControls")
         {
             model = new RandomizationControls();
             //TryUpdateModel(model as RandomizationControls);
             sequencing.RandomizationControls = model as RandomizationControls;
         }
         else if (type == "DeliveryControls")
         {
             model = new DeliveryControls();
             //TryUpdateModel(model as DeliveryControls);
             sequencing.DeliveryControls = model as DeliveryControls;
         }
         else if (type == "RollupRules")
         {
             model = new RollupRules();
             //TryUpdateModel(model as RollupRules);
             sequencing.RollupRules = model as RollupRules;
         }
         else if (type == "RollupConsiderations")
         {
             model = new RollupConsiderations();
             //TryUpdateModel(model as RollupConsiderations);
             sequencing.RollupConsiderations = model as RollupConsiderations;
         }
         else
         {
             throw new NotImplementedException();
         }
         // serialize sequencing
         xelement = xml.SerializeToXElemet(sequencing);
         // update node
         this.Storage.UpdateNode(ID, this.Storage.GetNode(ID));
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Esempio n. 2
0
        public JsonResult SaveProperties(int nodeId, string type)
        {
            var node = _Storage.GetNode(nodeId);
            var xml = new XmlSerializer(typeof(Sequencing));

            var xelement = nodeId == 0 ? _CurrentCourse.Sequencing : node.Sequencing;

            var sequencing = xelement == null ? new Sequencing() : (Sequencing)xml.DeserializeXElement(xelement);
            
            object model;

            if (type == "ControlMode")
            {
                model = new ControlMode();
                TryUpdateModel(model as ControlMode);
                sequencing.ControlMode = model as ControlMode;
            }
            else if (type == "LimitConditions")
            {
                model = new LimitConditions();
                TryUpdateModel(model as LimitConditions);
                sequencing.LimitConditions = model as LimitConditions;
            }
            else if (type == "ConstrainedChoiceConsiderations")
            {
                model = new ConstrainedChoiceConsiderations();
                TryUpdateModel(model as ConstrainedChoiceConsiderations);
                sequencing.ConstrainedChoiceConsiderations = model as ConstrainedChoiceConsiderations;
            }
            else if (type == "RandomizationControls")
            {
                model = new RandomizationControls();
                TryUpdateModel(model as RandomizationControls);
                sequencing.RandomizationControls = model as RandomizationControls;
            }
            else if (type == "DeliveryControls")
            {
                model = new DeliveryControls();
                TryUpdateModel(model as DeliveryControls);
                sequencing.DeliveryControls = model as DeliveryControls;
            }
            else if (type == "RollupRules")
            {
                model = new RollupRules();
                TryUpdateModel(model as RollupRules);
                sequencing.RollupRules = model as RollupRules;
            }
            else if (type == "RollupConsiderations")
            {
                model = new RollupConsiderations();
                TryUpdateModel(model as RollupConsiderations);
                sequencing.RollupConsiderations = model as RollupConsiderations;
            }
            else
            {
                throw new NotImplementedException();
            }

            if(nodeId == 0)
            {
                _CurrentCourse.Sequencing = xml.SerializeToXElemet(sequencing);
                _Storage.UpdateCourse(_CurrentCourse.Id, _CurrentCourse);
            }
            else
            {
                node.Sequencing = xml.SerializeToXElemet(sequencing);
                _Storage.UpdateNode(nodeId, node);
            }
            

            return Json(new { status = true });
        }
Esempio n. 3
0
        public void SequencingTest()
        {
            var sequencing = new Sequencing();
            sequencing.AdlObjectives = new AdlObjectives();
            sequencing.AdlObjectives.Objectives = new List<AdlObjective>();
            sequencing.AuxiliaryResources = "res";
            sequencing.ConstrainedChoiceConsiderations = new ConstrainedChoiceConsiderations
                {
                   ConstrainChoice = true, CourseId = 1, NodeId = 2, PreventActivation = false, Type = "type" 
                };
            sequencing.ControlMode = new ControlMode
                {
                    Choice = true, 
                    ChoiceExit = false, 
                    CourseId = 1, 
                    Flow = false, 
                    ForwardOnly = false, 
                    NodeId = 2, 
                    Type = "type", 
                    UseCurrentAttemptObjectiveInfo = false, 
                    UseCurrentAttemptProgressInfo = true
                };
            sequencing.DeliveryControls = new DeliveryControls
                {
                    CompletionSetByContent = true, 
                    CourseId = 1, 
                    NodeId = 2, 
                    ObjectiveSetByContent = false, 
                    Tracked = false, 
                    Type = "type"
                };
            sequencing.Id = "id";
            sequencing.IdRef = "ref";
            sequencing.LimitConditions = new LimitConditions
                {
                   AttemptAbsoluteDurationLimit = "1", AttemptLimit = 0, CourseId = 1, NodeId = 2, Type = "type" 
                };

            sequencing.Objectives = new Objectives();
            sequencing.RandomizationControls = new RandomizationControls
                {
                    CourseId = 1, 
                    NodeId = 2, 
                    RandomizationTiming = Timing.Once, 
                    ReorderChildren = true, 
                    SelectCount = 1, 
                    SelectionTiming = Timing.Never
                };
            sequencing.RollupConsiderations = new RollupConsiderations
                {
                    CourseId = 1, 
                    NodeId = 2, 
                    MeasureSatisfactionIfActive = false, 
                    RequiredForCompleted = Required.IfNotSkipped, 
                    RequiredForIncomplete = Required.IfNotSuspended, 
                    RequiredForNotSatisfied = Required.Always, 
                    RequiredForSatisfied = Required.IfAttempted, 
                    Type = "type", 
                };
            sequencing.RollupRules = new RollupRules
                {
                    CourseId = 1, 
                    NodeId = 2, 
                    ObjectiveMeasureWeight = 1, 
                    RollupObjectiveSatisfied = false, 
                    RollupProgressCompletion = true, 
                    RollupRulesList = new List<RollupRule>()
                };
            sequencing.SequencingRules = new SequencingRules
                {
                    ExitConditionRule =
                        new Rule
                            {
                                RuleAction = new RuleAction { Action = Action.Previous }, 
                                RuleConditions =
                                    new RuleConditions
                                        {
                                            ConditionCombination = ConditionCombination.All, 
                                            RuleConditionsList = new List<RuleCondition>()
                                        }
                            }
                };
            var rule = new RollupRule
                {
                    ChildActivitySet = ChildActivitySet.All, 
                    CourseId = 1, 
                    NodeId = 2, 
                    Type = "type", 
                    MinimumCount = 1, 
                    MinimumPercent = 1, 
                    RollupAction = new RollupAction { Action = RollupActions.Completed }
                };
            var con = new RollupConsiderations
                {
                    CourseId = 1, 
                    NodeId = 2, 
                    MeasureSatisfactionIfActive = false, 
                    RequiredForCompleted = Required.Always, 
                    RequiredForIncomplete = Required.IfNotSkipped, 
                    RequiredForNotSatisfied = Required.IfNotSkipped, 
                    RequiredForSatisfied = Required.IfAttempted, 
                    Type = "type"
                };
            sequencing.RollupConsiderations = con;
            sequencing.RollupRules = new RollupRules
                {
                    CourseId = 1, 
                    NodeId = 2, 
                    ObjectiveMeasureWeight = 1, 
                    RollupObjectiveSatisfied = false, 
                    RollupProgressCompletion = true, 
                    RollupRulesList = new List<RollupRule>()
                };

            sequencing.RollupRules.RollupRulesList.Add(rule);

            var manifest = new Manifest();
            manifest.SequencingCollection = new SequencingCollection();
            manifest.SequencingCollection.Sequencings = new List<Sequencing>();
            manifest.SequencingCollection.Sequencings.Add(sequencing);

            var path = Path.Combine(this.root, "sequencing.xml");
            manifest.Serialize(new StreamWriter(path));
            Assert.IsTrue(File.Exists(path));
        }