private static string[] GetStudentAnswers(StudentQuestionTable studentExamQuestion, OptionAssignController optionAssignController)
        {
            if (studentExamQuestion == null)
            {
                return new string[] { "" }
            }
            ;
            string[]   studentAnswerIds = studentExamQuestion.studentAnswerIds.Split(',');
            List <int> answerIds        = new List <int>();

            foreach (string studentAnswerId in studentAnswerIds)
            {
                int.TryParse(studentAnswerId, out int result);

                answerIds.Add(result);
            }
            List <string> answers = new List <string>();

            foreach (int answerId in answerIds)
            {
                OptionAssign answer = optionAssignController.GetById(answerId);
                if (answer != null)
                {
                    answers.Add(answer.optionTitle);
                }
            }
            return(answers.ToArray());
        }
Beispiel #2
0
 private void AssignOptionsToQuestion(int questionId, RealOption[] options, string[] answers)
 {
     foreach (RealOption option in options)
     {
         OptionAssign optionAssign = OptionUtils.OptionToOptionAssign(questionId, option, answers);
         optionAssignController.AssignNewOption(optionAssign);
     }
 }
Beispiel #3
0
        public void DeleteOption(int optionId)
        {
            OptionAssign model = optionAssignRepository.GetById(optionId);

            if (model == null)
            {
                return;
            }
            Delete(optionId);
        }
Beispiel #4
0
        private void EditOption(OptionAssign newOption)
        {
            OptionAssign model = GetByNameAndQuestionId(newOption.optionTitle, newOption.questionId);

            model.optionTitle = newOption.optionTitle;
            model.questionId  = newOption.questionId;
            model.answer      = newOption.answer;
            optionAssignRepository.Update(model);
            optionAssignRepository.Save();
        }
 public static List<OptionAssign> OneWayCompareOptions(List<OptionAssign> completeList, List<OptionAssign> actualList)
 {
     List<OptionAssign> differentItems = new List<OptionAssign>();
     foreach (OptionAssign listElement in completeList)
     {
         OptionAssign foundElement = actualList.Find(optionElement => optionElement.optionTitle == listElement.optionTitle);
         OptionAssign foundAnswer = actualList.Find(optionElement => optionElement.answer[0] == listElement.answer[0]);
         if (foundElement == null || foundAnswer == null)
             differentItems.Add(listElement);
     }
     return differentItems;
 }
Beispiel #6
0
        public void AssignNewOption(OptionAssign assignment)
        {
            var allOptionAssignments = optionAssignRepository.GetAll();
            int lastId = 0;

            if (allOptionAssignments.Count() > 0)
            {
                lastId = allOptionAssignments[allOptionAssignments.Count() - 1].Id;
            }
            assignment.Id = lastId + 1;
            optionAssignRepository.Insert(assignment);
            optionAssignRepository.Save();
        }
        public static OptionAssign OptionToOptionAssign(int questionId, RealOption option, string[] answers)
        {
            byte[] answer = new byte[] { 0 };
            if (answers.Contains(option.title))
                answer[0] = 1;
            OptionAssign optionAssign = new OptionAssign
            {
                questionId = questionId,
                optionTitle = option.title,
                answer = answer,
            };

            return optionAssign;
        }
Beispiel #8
0
        public static OptionAssign OptionToOptionAssign(int questionId, RealOption option, string[] answers)
        {
            bool answer = false;

            if (answers.Contains(option.title))
            {
                answer = true;
            }
            OptionAssign optionAssign = new OptionAssign
            {
                questionId  = questionId,
                optionTitle = option.title,
                answer      = answer,
            };

            return(optionAssign);
        }