コード例 #1
0
        public ActionResult CreateClosedQuestion(ExamTestQuestion question, IEnumerable<HttpPostedFileBase> fileUpload, string variantText)
        {
            JournalContext.ExamTestQuestions.InsertOnSubmit(question);
            JournalContext.SubmitChanges();
            var tVariant = new ExamTestVariant()
                               {
                                   ExamTestQuestionID = question.ExamTestQuestionID,
                                   IsCorrect = true,
                                   VariantText = variantText,
                               };
            JournalContext.ExamTestVariants.InsertOnSubmit(tVariant);

            UploadFiles(fileUpload, question);

            JournalContext.SubmitChanges();
            return RedirectToAction("Index");
        }
コード例 #2
0
 partial void DeleteExamTestVariant(ExamTestVariant instance);
コード例 #3
0
 partial void UpdateExamTestVariant(ExamTestVariant instance);
コード例 #4
0
 partial void InsertExamTestVariant(ExamTestVariant instance);
コード例 #5
0
		private void detach_ExamTestVariants(ExamTestVariant entity)
		{
			this.SendPropertyChanging();
			entity.ExamTestQuestion = null;
		}
コード例 #6
0
        public ActionResult CreateOpenQuestion(ExamTestQuestion question, IEnumerable<HttpPostedFileBase> fileUpload,
            IEnumerable<string> variants, IEnumerable<int> corrected)
        {
            var correctedCount = corrected.Count();
            if (corrected == null) RedirectToAction("Index"); // ошибка - не выбрано ни одного правильного ответа
            if (correctedCount == 0) RedirectToAction("Index"); // вопрос должен имеять хотя бы один правильный ответ
            question.AllowMultiAnswer = correctedCount > 1 ? true : false;
            //question.ExamTestID = int.Parse(ExamTestID.ToString());
            JournalContext.ExamTestQuestions.InsertOnSubmit(question);
            JournalContext.SubmitChanges();
            //question = JournalContext.ExamTestQuestions.First(q => q.ExamTestQuestionID == question.ExamTestQuestionID);

            var variantsList = variants.ToList();
            for (int i = 0; i < variantsList.Count; ++i)
            {
                if (string.IsNullOrEmpty(variantsList[i])) continue;
                //var nextVariantId = JournalContext.ExamTestVariants.Max(x => x.ExamTestVariantID) + 1;
                var tVariant = new ExamTestVariant()
                                   {
                                       ExamTestQuestionID = question.ExamTestQuestionID,
                                       //ExamTestVariantID = nextVariantId,
                                       IsCorrect = corrected.Contains(i),
                                       VariantText = variantsList[i],
                                   };
                JournalContext.ExamTestVariants.InsertOnSubmit(tVariant);
            }

            UploadFiles(fileUpload, question);

            JournalContext.SubmitChanges();
            return RedirectToAction("Index");
        }