public ActionResult AnswerTest(int id) { //inititalize the index of the questions IndexQuestion = 0; //get the test chosen TestToAnswer = new TestToRender(); foreach (TestToRender test in RenderList) { if (test.ID == id) { TestToAnswer = test; } } //initialize the map answers mapAnswers = new Dictionary <Question, PossibleResponse>(); //prepare the first question of the test to be rendered to the view //, we use the static indexquestion defined above var model = PrepareNextQuestion(IndexQuestion); return(View(model)); }
public ActionResult AutoTests() { IEnumerable <t_evaluationtest> list = _sr.DisplayTests(logger, "Auto"); RenderList = new List <TestToRender>(); TestToRender render; Question question; PossibleResponse response; foreach (t_evaluationtest test in list) { render = new TestToRender(); render.ID = test.ET_ID; render.Type = test.ET_Type; render.tType = test.Et_tType; render.globaloNoteSoFar = test.globaloNoteSoFar; render.NbreQuestions = test.t_criteria.Count(); render.NbreParticipants = test.t_answertestaffectation.Count(); render.questions = new List <Question>(); //add the questions foreach (t_criteria c in test.t_criteria) { question = new Question(); question.ID = c.Cr_ID; question.coefficient = c.Cr_coefficient; question.Content = c.Cr_Content; question.PossibleResponses = new List <PossibleResponse>(); //add the responses of each question foreach (t_possibleresponse rep in c.t_possibleresponse) { response = new PossibleResponse(); response.ID = rep.Pr_ID; response.Content = rep.Pr_Content; response.Score = rep.Pr_score; question.PossibleResponses.Add(response); } render.questions.Add(question); } RenderList.Add(render); } RenderTestList model = new RenderTestList(); model.TestsList = RenderList; return(View(model)); }
public ActionResult Tests360() { IEnumerable <t_evaluationtest> list = _sr.DisplayTests(logger, "360"); RenderList = new List <TestToRender>(); TestToRender render; Question question; PossibleResponse response; foreach (t_evaluationtest test in list) { render = new TestToRender(); render.ID = test.ET_ID; render.Type = test.ET_Type; render.tType = test.Et_tType; render.globaloNoteSoFar = test.globaloNoteSoFar; render.NbreQuestions = test.t_criteria.Count(); render.NbreParticipants = test.t_answertestaffectation.Count(); render.questions = new List <Question>(); //add target list of the test render.targetList = new List <CollaboratorModel>(); CollaboratorModel colab; foreach (t_evaluationtargetaffectation aff in test.t_evaluationtargetaffectation) { colab = new CollaboratorModel(); t_collaborator target = aff.t_collaborator; colab.C_Lastname = target.C_Lastname; colab.C_Forname = target.C_Forname; colab.C_ID = target.C_ID; render.targetList.Add(colab); } //add the questions foreach (t_criteria c in test.t_criteria) { question = new Question(); question.ID = c.Cr_ID; question.coefficient = c.Cr_coefficient; question.Content = c.Cr_Content; question.PossibleResponses = new List <PossibleResponse>(); //add the responses of each question foreach (t_possibleresponse rep in c.t_possibleresponse) { response = new PossibleResponse(); response.ID = rep.Pr_ID; response.Content = rep.Pr_Content; response.Score = rep.Pr_score; question.PossibleResponses.Add(response); } render.questions.Add(question); } RenderList.Add(render); } RenderTestList model = new RenderTestList(); model.TestsList = RenderList; return(View(model)); }