コード例 #1
0
        public ActionResult Edit(int curriculumChapterTopicId)
        {
            var curriculumChapterTopic = Storage.GetCurriculumChapterTopic(curriculumChapterTopicId);
            var curriculumChapter = Storage.GetCurriculumChapter(curriculumChapterTopic.CurriculumChapterRef);
            var curriculum = Storage.GetCurriculum(curriculumChapter.CurriculumRef);

            var model = new CreateCurriculumChapterTopicModel(
                curriculumChapterTopic.ThresholdOfSuccess,
                curriculumChapterTopic.BlockTopicAtTesting,
                curriculumChapterTopic.BlockCurriculumAtTesting,
                curriculumChapterTopic.TestStartDate,
                curriculumChapterTopic.TestEndDate,
                curriculumChapterTopic.TheoryStartDate,
                curriculumChapterTopic.TheoryEndDate);

            Session["CurriculumChapterId"] = curriculumChapter.Id;
            ViewData["GroupName"] = Storage.GetGroup(curriculum.UserGroupRef) != null ? Storage.GetGroup(curriculum.UserGroupRef).Name : Localization.GetMessage("GroupNotExist");
            ViewData["ChapterName"] = Storage.GetChapter(curriculumChapter.ChapterRef).Name;
            return PartialView(model);
        }
コード例 #2
0
        public ActionResult Edit(int curriculumChapterTopicId, CreateCurriculumChapterTopicModel model)
        {
            var curriculumChapterTopic = Storage.GetCurriculumChapterTopic(curriculumChapterTopicId);
            curriculumChapterTopic.ThresholdOfSuccess = model.ThresholdOfSuccess;
            curriculumChapterTopic.BlockCurriculumAtTesting = model.BlockCurriculumAtTesting;
            curriculumChapterTopic.BlockTopicAtTesting = model.BlockTopicAtTesting;
            curriculumChapterTopic.TestStartDate = model.SetTestTimeline ? model.TestStartDate : (DateTime?)null;
            curriculumChapterTopic.TestEndDate = model.SetTestTimeline ? model.TestEndDate : (DateTime?)null;
            curriculumChapterTopic.TheoryStartDate = model.SetTheoryTimeline ? model.TheoryStartDate : (DateTime?)null;
            curriculumChapterTopic.TheoryEndDate = model.SetTheoryTimeline ? model.TheoryEndDate : (DateTime?)null;

            AddValidationErrorsToModelState(Validator.ValidateCurriculumChapterTopic(curriculumChapterTopic).Errors);

            if (ModelState.IsValid)
            {
                Storage.UpdateCurriculumChapterTopic(curriculumChapterTopic);
                return RedirectToRoute("CurriculumChapterTopics", new { action = "Index", CurriculumChapterId = Session["CurriculumChapterId"] });
            }
            return View(model);
        }
コード例 #3
0
        public ActionResult Edit(int curriculumChapterTopicId)
        {
            LoadValidationErrors();

            var curriculumChapterTopic = Storage.GetCurriculumChapterTopic(curriculumChapterTopicId);
            var curriculumChapter = Storage.GetCurriculumChapter(curriculumChapterTopic.CurriculumChapterRef);
            var curriculum = Storage.GetCurriculum(curriculumChapter.CurriculumRef);

            var model = new CreateCurriculumChapterTopicModel(curriculumChapterTopic.MaxScore,
                curriculumChapterTopic.BlockTopicAtTesting, curriculumChapterTopic.BlockCurriculumAtTesting,
                curriculumChapterTopic.TestStartDate, curriculumChapterTopic.TestEndDate,
                curriculumChapterTopic.TheoryStartDate, curriculumChapterTopic.TheoryEndDate);

            Session["CurriculumChapterId"] = curriculumChapter.Id;
            ViewData["GroupName"] = Storage.GetGroup(curriculum.UserGroupRef).Name;
            ViewData["DisciplineName"] = Storage.GetDiscipline(curriculum.DisciplineRef).Name;
            ViewData["ChapterName"] = Storage.GetChapter(curriculumChapter.ChapterRef).Name;
            ViewData["TopicName"] = Storage.GetTopic(curriculumChapterTopic.TopicRef).Name;
            return View(model);
        }
コード例 #4
0
        public ActionResult Edit(int curriculumChapterTopicId, CreateCurriculumChapterTopicModel model)
        {
           try {
              var curriculumChapterTopic = Storage.GetCurriculumChapterTopic(curriculumChapterTopicId);
              curriculumChapterTopic.ThresholdOfSuccess = model.ThresholdOfSuccess;
              curriculumChapterTopic.BlockCurriculumAtTesting = model.BlockCurriculumAtTesting;
              curriculumChapterTopic.BlockTopicAtTesting = model.BlockTopicAtTesting;
              curriculumChapterTopic.TestStartDate = model.SetTestTimeline ? model.TestStartDate : (DateTime?) null;
              curriculumChapterTopic.TestEndDate = model.SetTestTimeline ? model.TestEndDate : (DateTime?) null;
              curriculumChapterTopic.TheoryStartDate = model.SetTheoryTimeline ? model.TheoryStartDate : (DateTime?) null;
              curriculumChapterTopic.TheoryEndDate = model.SetTheoryTimeline ? model.TheoryEndDate : (DateTime?) null;

              AddValidationErrorsToModelState(Validator.ValidateCurriculumChapterTopic(curriculumChapterTopic).Errors);

              if (ModelState.IsValid) {
                 Storage.UpdateCurriculumChapterTopic(curriculumChapterTopic);
                 var curriculum = Storage.GetCurriculum(Storage.GetCurriculumChapter(curriculumChapterTopic.CurriculumChapterRef).CurriculumRef);
                 return Json(new {
                    success = true,
                    curriculumChapterTopicId = curriculumChapterTopicId,
                    curriculumChapterTopicRow = PartialViewAsString("CurriculumChapterTopicRow", new ViewCurriculumChapterTopicModel {
                       Id = curriculumChapterTopic.Id,
                       CurriculumChapterRef = curriculumChapterTopic.CurriculumChapterRef,
                       BlockCurriculumAtTesting = curriculumChapterTopic.BlockCurriculumAtTesting,
                       BlockTopicAtTesting = curriculumChapterTopic.BlockTopicAtTesting,
                       TestStartDate = Converter.ToString(curriculumChapterTopic.TestStartDate),
                       TestEndDate = Converter.ToString(curriculumChapterTopic.TestEndDate),
                       TheoryStartDate = Converter.ToString(curriculumChapterTopic.TheoryStartDate),
                       TheoryEndDate = Converter.ToString(curriculumChapterTopic.TheoryEndDate),
                       ThresholdOfSuccess = curriculumChapterTopic.ThresholdOfSuccess,
                       TopicName = Storage.GetTopic(curriculumChapterTopic.TopicRef).Name
                    }),
                    curriculumInfo = new { Id = curriculum.Id, IsValid = curriculum.IsValid }
                 });
              }
              return Json(new {success = false, curriculumChapterTopicId = curriculumChapterTopicId, html = PartialViewAsString("Edit", model)});
           } catch (Exception ex) {
              return Json(new {success = false, html = ex.Message});
           }
        }
コード例 #5
0
        public ActionResult Edit(int curriculumChapterTopicId, CreateCurriculumChapterTopicModel model)
        {
            var curriculumChapterTopic = Storage.GetCurriculumChapterTopic(curriculumChapterTopicId);
            curriculumChapterTopic.MaxScore = model.MaxScore;
            curriculumChapterTopic.BlockCurriculumAtTesting = model.BlockCurriculumAtTesting;
            curriculumChapterTopic.BlockTopicAtTesting = model.BlockTopicAtTesting;
            curriculumChapterTopic.TestStartDate = model.SetTestDate ? model.TestStartDate : (DateTime?)null;
            curriculumChapterTopic.TestEndDate = model.SetTestDate ? model.TestEndDate : (DateTime?)null;
            curriculumChapterTopic.TheoryStartDate = model.SetTheoryDate ? model.TheoryStartDate : (DateTime?)null;
            curriculumChapterTopic.TheoryEndDate = model.SetTheoryDate ? model.TheoryEndDate : (DateTime?)null;

            AddValidationErrorsToModelState(Validator.ValidateCurriculumChapterTopic(curriculumChapterTopic).Errors);

            if (ModelState.IsValid)
            {
                Storage.UpdateCurriculumChapterTopic(curriculumChapterTopic);
                return RedirectToRoute("CurriculumChapterTopics", new { action = "Index", CurriculumChapterId = Session["CurriculumChapterId"] });
            }
            else
            {
                SaveValidationErrors();
                return RedirectToAction("Edit");
            }
        }
コード例 #6
0
        public JsonResult EditTopic(int id, CreateCurriculumChapterTopicModel model)
        {
            try
            {
                var curriculumChapterTopic = Storage.GetCurriculumChapterTopic(id);
                curriculumChapterTopic.ThresholdOfSuccess = model.ThresholdOfSuccess;
                curriculumChapterTopic.BlockCurriculumAtTesting = model.BlockCurriculumAtTesting;
                curriculumChapterTopic.BlockTopicAtTesting = model.BlockTopicAtTesting;
                curriculumChapterTopic.TestStartDate = model.SetTestTimeline ? model.TestStartDate : (DateTime?)null;
                curriculumChapterTopic.TestEndDate = model.SetTestTimeline ? model.TestEndDate : (DateTime?)null;
                curriculumChapterTopic.TheoryStartDate = model.SetTheoryTimeline ? model.TheoryStartDate : (DateTime?)null;
                curriculumChapterTopic.TheoryEndDate = model.SetTheoryTimeline ? model.TheoryEndDate : (DateTime?)null;

                AddValidationErrorsToModelState(Validator.ValidateCurriculumChapterTopic(curriculumChapterTopic).Errors);

                if (ModelState.IsValid)
                {
                    Storage.UpdateCurriculumChapterTopic(curriculumChapterTopic);
                    return Json(new { success = "true" });
                }

                return Json(new { success = false, id = id, html = PartialViewAsString("EditTopic", model) });
            }
            catch (Exception ex)
            {
                return Json(new { success = false, html = ex.Message });
            }

        }
コード例 #7
0
 public ActionResult EditTopic(int id)
 {
     var topic = Storage.GetCurriculumChapterTopic(id);
     var model = new CreateCurriculumChapterTopicModel(
         topic.ThresholdOfSuccess,
         topic.BlockTopicAtTesting,
         topic.BlockCurriculumAtTesting,
         topic.TestStartDate,
         topic.TestEndDate,
         topic.TheoryStartDate,
         topic.TheoryEndDate);
     return PartialView("EditTopic", model);
 }