Esempio n. 1
0
 /// <summary>
 /// this happens when a scenario is loaded for the first time (they push play on the scenarios page)
 /// </summary>
 /// <param name="scenarioID">the scenario identify they want to play</param>
 /// <param name="nextQuestion">the starting question of the scenario</param>
 private void LoadScenario(int scenarioID, int nextQuestion)
 {
     try
     {
         Session["currentScenario"] = DatabaseUtils.getScenario(scenarioID);
         DatabaseUtils.getQuestionsAndAnswers(((Scenario)Session["currentScenario"]));
         Session["answersToGrade"] = new AnswersToGrade();
     }
     catch (Exception ex)
     {
         Singleton.errorCode = "PLYSENCON05";
         Singleton.writeErrorToFile(Singleton.errorCode, ex.Message, ex.StackTrace);
         throw ex;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// this is called when they initially start a scenario and after every answer and comment unless it is the end of the scenario
 /// </summary>
 /// <param name="scenarioID">scenario identifier for the scenario they are playing</param>
 /// <param name="nextQuestion">the next question in the scenario</param>
 /// <param name="newGame">if they just started a new game of if they are continuing a game (T/F)</param>
 /// <param name="wasAnswered">if a question was answered (T/F)</param>
 /// <returns></returns>
 public ActionResult playScenario(int scenarioID, int nextQuestion, bool newGame, bool wasAnswered)
 {
     if (String.IsNullOrEmpty((string)Session["userId"]))
     {
         return(RedirectToAction("Login", "Account"));
     }
     try
     {
         if (newGame)
         {
             ModelState.Clear();
             Session["currentScenario"] = new Scenario();
             Session["answersToGrade"]  = new AnswersToGrade();
             LoadScenario(scenarioID, nextQuestion);
             ((Scenario)Session["currentScenario"]).currentQuestion = nextQuestion;
         }
         else
         {
             if (wasAnswered)
             {
                 addAnswerToList();
                 ((Scenario)Session["currentScenario"]).currentQuestion = this.nextQuestion(((Scenario)Session["currentScenario"]).questions[((Scenario)Session["currentScenario"]).currentQuestion].selectedAnswer, ((Scenario)Session["currentScenario"]).currentQuestion);
             }
             if (nextQuestion == 0)
             {
                 return(RedirectToAction("ScenarioComplete", "PlayScenario"));
             }
         }
     }
     catch (Exception ex)
     {
         Singleton.errorCode = "PLYSENCON01";
         Singleton.writeErrorToFile(Singleton.errorCode, ex.Message, ex.StackTrace);
         throw ex;
     }
     return(View("PlayScenario", ((Scenario)Session["currentScenario"])));
 }