コード例 #1
0
 // GET: api/Exams/5
 public IHttpActionResult Get(int id, bool student)
 {
     if (student == false)
     {
         var result = realExamProxy.GetRealExam(id);
         if (result == null)
         {
             EditExamController.currentExam = null;
             EditExamController.Editing     = false;
             return(NotFound());
         }
         RealExamProxy.UpdateRealExam(result.Id);
         EditExamController.currentExam = result;
         EditExamController.Editing     = true;
         return(Ok(result));
     }
     else
     {
         RealExam result = realExamProxy.GetRealExam(id);
         if (result == null)
         {
             StudentExamController.currentExam = null;
             return(NotFound());
         }
         foreach (RealExamQuestion question in result.examElements)
         {
             question.answerCount = question.answer.Count();
             question.answer      = new string[] { };
         }
         RealExamProxy.UpdateRealExam(id);
         StudentExamController.currentExam = result;
         return(Ok());
     }
 }
コード例 #2
0
        public static RealExam[] GetRealExamArray(List <Exam> allExams, RealExamProxy realExamProxy)
        {
            List <RealExam> allRealExams = new List <RealExam>();

            foreach (Exam exam in allExams)
            {
                allRealExams.Add(realExamProxy.GetRealExam(exam.Id));
            }
            return(allRealExams.ToArray());
        }