public void SetTaskData(TaskStep taskstepdata) { mTaskStepData = taskstepdata; distance.Uid = mTaskStepData.mDistanceValue + " " + mTaskStepData.mDistanceUnit; direction.Uid = mTaskStepData.mDirectionValue; symbol.Uid = mTaskStepData.mSymbolValue; }
public void ReadScript(string filename) { mTotalTaskSteps = 0; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(filename); XmlNodeList nodes = xmlDocument.SelectNodes("/scenario/activities/steps"); mTaskSteps = new List<TaskStep>(); int rowCount = 0; int stepCounter = 0; string trailID = "z"; foreach (XmlNode node in nodes) { TaskStep stepInfo = new TaskStep(); stepInfo.mId = int.Parse(node.Attributes["id"].Value); stepInfo.mStepId = node.Attributes["id"].InnerText; stepInfo.mTrailId = node.SelectSingleNode("trail-id").InnerText; if (node.SelectSingleNode("step-speech") != null) { stepInfo.mStepSpeech = node.SelectSingleNode("step-speech").InnerText; stepInfo.mStepSpeech = stepInfo.mStepSpeech.Replace("/student/", mWOZManager.mparticipantDetails.mName); } else { stepInfo.mStepSpeech = "none"; } // Question stepInfo.mQuestion = node.SelectSingleNode("name").InnerText; if (stepInfo.mTrailId.Equals(trailID) == false) { stepCounter = 0; trailID = stepInfo.mTrailId; } if (node.SelectSingleNode("distance") != null) { // Distance stepInfo.mDistanceReq = Convert.ToBoolean(node.SelectSingleNode("distance").InnerText); if (stepInfo.mDistanceReq) { stepInfo.mDistanceUnit = node.SelectSingleNode("distance-units").InnerText; stepInfo.mDistanceValue = double.Parse(node.SelectSingleNode("distance-required").InnerText); } } if (node.SelectSingleNode("direction") != null) { // Direction stepInfo.mDirectionReq = Convert.ToBoolean(node.SelectSingleNode("direction").InnerText); if (stepInfo.mDirectionReq) { stepInfo.mDirectionUnit = node.SelectSingleNode("direction-units").InnerText; stepInfo.mDirectionValue = node.SelectSingleNode("direction-required").InnerText; } } if (node.SelectSingleNode("symbol") != null) { // Symbol stepInfo.mSymbolReq = Convert.ToBoolean(node.SelectSingleNode("symbol").InnerText); if (stepInfo.mSymbolReq) { stepInfo.mSymbolValue = node.SelectSingleNode("symbol-name-required").InnerText; } } stepInfo.mComplete = false; /* Add the step to the list */ rowCount++; stepCounter++; stepInfo.mLabel = "Step " + stepCounter;// stepInfo.mStepId; stepInfo.mRowID = rowCount; stepInfo.mColumnID = 4; stepInfo.mIsHeading = false; /* Set the first Step as Active */ if (stepInfo.mId == GetActiveStepID()) { stepInfo.mIsActive = true; } mTaskSteps.Add(stepInfo); mTotalTaskSteps++; } }
/* * Use the Skill and Strategy Selection to set the Utterances */ public int SetUtterancesList(participantDetails participant, TaskStep taskstepdata, ListBox listBox, UtteranceType type, int strategy, int activeStepID, int firstActivityStep, SkillSelection skillSelection, List<UtteranceSet> ut) { listBox.Items.Clear(); int counter = 0; int problemCounter = 0; foreach (XmlNode node in nodes) { if (node.SelectSingleNode("strategy") != null && node.SelectSingleNode("skill") != null && node.SelectSingleNode("dynamic") != null) { if (type == UtteranceType.FEEDBACK) { if (int.Parse(node.SelectSingleNode("strategy").InnerText) == strategy) { if (int.Parse(node.SelectSingleNode("strategy").InnerText) == 4) // Requestion { if (int.Parse(node.SelectSingleNode("skill").InnerText) == GetTaskScriptOffset(activeStepID)) { UtteranceSet utterance = new UtteranceSet(); utterance = ProcessUtterance(participant, taskstepdata, node, skillSelection); ut.Add(utterance); AddUtteranceItem(utterance, listBox, utterance.mText); counter++; } } else if (int.Parse(node.SelectSingleNode("skill").InnerText) == skillSelection.mSkill || skillSelection.mSkill == 0 || strategy > 9) //Allow Generic Behaviours { UtteranceSet utterance = new UtteranceSet(); utterance = ProcessUtterance(participant, taskstepdata, node, skillSelection); ut.Add(utterance); AddUtteranceItem(utterance, listBox, utterance.mText); counter++; } } } } else { string[] info = new string[3]; info[0] = "O.K"; info[1] = "O.K"; info[2] = "O.K"; if (node.SelectSingleNode("strategy") == null) info[0] = "NULL"; if (node.SelectSingleNode("skill") == null) info[1] = "NULL"; if (node.SelectSingleNode("dynamic") == null) info[2] = "NULL"; Console.WriteLine("Something Missing == ID = " + problemCounter.ToString() + " TYPE = " + type + info[0] + "," + info[1] + "," + info[2]); } problemCounter++; } if (counter == 0) { UtteranceSet utterance = new UtteranceSet(); utterance.mText = "There is nothing to choose from here?"; utterance.mNonTaggedText = "There is nothing to choose from here?"; ut.Add(utterance); AddUtteranceItem(utterance, listBox, utterance.mText); counter++; } return counter; }
///* //* Use the Skill and Strategy Selection to set the Utterances //*/ //public int SetUtterancesList(participantDetails participant, TaskStep taskstepdata, ListBox listBox, UtteranceType type, int strategy, int activeStepID, int firstActivityStep, SkillSelection skillSelection) //{ // listBox.Items.Clear(); // int counter = 0; // int problemCounter = 0; // foreach (XmlNode node in nodes) // { // if (node.SelectSingleNode("strategy") != null && node.SelectSingleNode("skill") != null && node.SelectSingleNode("dynamic") != null) // { // if (type == UtteranceType.FEEDBACK) // { // if (int.Parse(node.SelectSingleNode("strategy").InnerText) == strategy) // { // if (int.Parse(node.SelectSingleNode("strategy").InnerText) == 4) // Requestion // { // if (int.Parse(node.SelectSingleNode("skill").InnerText) == GetTaskScriptOffset(activeStepID)) // { // UtteranceSet utterance = new UtteranceSet(); // utterance = ProcessUtterance(participant, taskstepdata, node, skillSelection); // AddUtteranceItem(listBox, utterance.mText); // counter++; // } // } // else if (int.Parse(node.SelectSingleNode("skill").InnerText) == skillSelection.mSkill || skillSelection.mSkill == 0 || strategy > 9) //Allow Generic Behaviours // { // UtteranceSet utterance = new UtteranceSet(); // utterance = ProcessUtterance(participant, taskstepdata, node, skillSelection); // AddUtteranceItem(listBox, utterance.mText); // counter++; // } // } // } // } // else // { // string[] info = new string[3]; // info[0] = "O.K"; // info[1] = "O.K"; // info[2] = "O.K"; // if (node.SelectSingleNode("strategy") == null) // info[0] = "NULL"; // if (node.SelectSingleNode("skill") == null) // info[1] = "NULL"; // if (node.SelectSingleNode("dynamic") == null) // info[2] = "NULL"; // Console.WriteLine("Something Missing == ID = " + problemCounter.ToString() + " TYPE = " + type + info[0] + "," + info[1] + "," + info[2]); // } // problemCounter++; // } // if (counter == 0) // { // UtteranceSet utterance = new UtteranceSet(); // utterance.mText = "There is nothing to choose from here?"; // AddUtteranceItem(listBox, utterance.mText); // } // return counter; //} private UtteranceSet ProcessUtterance(participantDetails participant, TaskStep taskstepdata, XmlNode node, SkillSelection skillSelection) { UtteranceSet tempUtteranceSet = new UtteranceSet(); tempUtteranceSet.mText = node.SelectSingleNode("text").InnerText; tempUtteranceSet.mStrategy = int.Parse(node.SelectSingleNode("strategy").InnerText); tempUtteranceSet.mSkill = int.Parse(node.SelectSingleNode("skill").InnerText); tempUtteranceSet.mDynamic = int.Parse(node.SelectSingleNode("dynamic").InnerText); tempUtteranceSet.mText = tempUtteranceSet.mText.Replace("/distance/", taskstepdata.mDistanceValue.ToString() + " " + taskstepdata.mDistanceUnit); tempUtteranceSet.mText = tempUtteranceSet.mText.Replace("/interDirection/", taskstepdata.mDirectionValue); tempUtteranceSet.mText = tempUtteranceSet.mText.Replace("/interSecDirection/", taskstepdata.mDirectionValue); tempUtteranceSet.mText = tempUtteranceSet.mText.Replace("/direction/", taskstepdata.mDirectionValue); tempUtteranceSet.mText = tempUtteranceSet.mText.Replace("/symbol/", taskstepdata.mSymbolValue + " symbol"); tempUtteranceSet.mText = tempUtteranceSet.mText.Replace("/student/", participant.mName); tempUtteranceSet.mText = tempUtteranceSet.mText.Replace("/skill/", skillSelection.mSkillText); tempUtteranceSet.mNonTaggedText = Regex.Replace(tempUtteranceSet.mText, @"\s*?(?:\(.*?\)|\<.*?\>|\{.*?\})", String.Empty); tempUtteranceSet.mNonTaggedText = Regex.Replace(tempUtteranceSet.mNonTaggedText, @"\s*?(?:\(.*?\)|\\.*?\\|\{.*?\})", String.Empty); return tempUtteranceSet; }
public void CreateLabelDynamically(TaskStep step)// String content, int rowId, int colId, bool active, bool heading = false) { bool printStepLabel = true; /* Check if this is the start of a new trail */ if (!String.Equals(mSavedTrailID, step.mTrailId)) { mRowOffSet++; Label trailLabel = new Label(); trailLabel.Name = "McLabel"; trailLabel.Width = 125; trailLabel.Height = 25; trailLabel.FontSize = 11; printStepLabel = true; if (step.mId == mTaskScriptManager.GetActiveStepID()) { trailLabel.Foreground = new SolidColorBrush(Colors.Green); } else trailLabel.Foreground = new SolidColorBrush(Colors.White); if (step.mTrailId.Equals("X")) { trailLabel.Content = "Introduction"; printStepLabel = false; } else if (step.mTrailId.Equals("Y")) { trailLabel.Content = "Tool Introduction"; } else if (step.mTrailId.Equals("Z")) { trailLabel.Content = "Activity Debrief"; printStepLabel = false; } else if (step.mTrailId.Equals("D")) { trailLabel.Content = "Object Placement"; printStepLabel = false; } else trailLabel.Content = "Map Trail " + step.mTrailId; Grid.SetRow(trailLabel, step.mRowID + mRowOffSet); Grid.SetColumn(trailLabel, 2); this.ScriptGrid.Children.Add(trailLabel); mSavedTrailID = step.mTrailId; } if (printStepLabel == true) { Label stepLabel = new Label(); stepLabel.Name = "McLabel"; stepLabel.Width = 125; stepLabel.Height = 25; stepLabel.FontSize = 10; if (step.mId == mTaskScriptManager.GetActiveStepID()) { stepLabel.Foreground = new SolidColorBrush(Colors.Green); } else stepLabel.Foreground = new SolidColorBrush(Colors.White); stepLabel.HorizontalAlignment = HorizontalAlignment.Left; stepLabel.Content = step.mLabel; Grid.SetRow(stepLabel, step.mRowID + mRowOffSet); Grid.SetColumn(stepLabel, 4); this.ScriptGrid.Children.Add(stepLabel); } if (step.mId == mTaskScriptManager.GetActiveStepID()) { // Restart Button Button restartButton = new Button(); Grid.SetRow(restartButton, step.mRowID + mRowOffSet); Grid.SetColumn(restartButton, 5); var resource = FindResource("SmallResetButton") as ControlTemplate; restartButton.Template = resource; restartButton.Click += new RoutedEventHandler(ResetStep); this.ScriptGrid.Children.Add(restartButton); // Arrow Button Image arrowImage = new Image(); var uri = new Uri("pack://application:,,,/Images/Generic/ArrowGreen.png"); var bitmap = new BitmapImage(uri); arrowImage.Source = bitmap; Grid.SetRow(arrowImage, step.mRowID + mRowOffSet); Grid.SetColumn(arrowImage, 0); this.ScriptGrid.Children.Add(arrowImage); } }