示例#1
0
 public bool Save(Exam exam)
 {
     try
     {
         password  = exam.Password;
         SaverName = exam.Name;
         ExamFileService fileService = ExamFileService.GetInstance();
         fileService.SaveExam(exam, filePath);
         openedExam = exam;
         return(true);
     }
     catch (Exception ex)
     {
         LastExceptionMessage = ex.Message;
         return(false);
     }
 }
示例#2
0
        public bool SaveResult(ExecutionResult executionResults)
        {
            Exam exam = GetExam();

            if (exam is null)
            {
                return(false);
            }
            exam.ExecutionResults.Add(executionResults);
            try
            {
                password  = exam.Password;
                SaverName = exam.Name;
                ExamFileService fileService = ExamFileService.GetInstance();
                fileService.SaveExam(exam, filePath);
                return(true);
            }
            catch (Exception ex)
            {
                LastExceptionMessage = ex.Message;
                return(false);
            }
        }
示例#3
0
        public Exam GetExam()
        {
            if (openedExam != null)
            {
                return(openedExam);
            }
            Exam exam;

            try
            {
                ExamFileService fileService = ExamFileService.GetInstance();
                exam      = fileService.OpenExam(filePath, password);
                password  = exam.Password;
                SaverName = exam.Name;
            }
            catch (Exception ex)
            {
                LastExceptionMessage = ex.Message;
                exam = null;
            }
            openedExam = exam;
            return(exam);
        }
示例#4
0
        public IList <Question> GetQuestions()
        {
            List <Question> result;

            if (openedExam != null)
            {
                result = new List <Question>();
                for (int i = 0; i < openedExam.Tickets.Count; i++)
                {
                    result.AddRange(openedExam.Tickets[i].GetQuestions());
                }
                return(result);
            }
            Exam exam;

            try
            {
                result = new List <Question>();
                ExamFileService fileService = ExamFileService.GetInstance();
                exam       = fileService.OpenExam(filePath, password);
                password   = exam.Password;
                SaverName  = exam.Name;
                openedExam = exam;
                for (int i = 0; i < openedExam.Tickets.Count; i++)
                {
                    result.AddRange(openedExam.Tickets[i].GetQuestions());
                }
            }
            catch (Exception ex)
            {
                LastExceptionMessage = ex.Message;
                result = null;
                exam   = null;
            }
            openedExam = exam;
            return(result);
        }