예제 #1
0
        public ActionResult CreateTest(CreateTestVM testVM)
        {
            int templateID = -1;

            templateID = testVM.selectedTemplateID;
            string key     = testService.RandomString();
            Test   newTest = testService.CreateTest(templateID, testVM.userName, key, testVM.timeLimit.Days * 24 * 60 + testVM.timeLimit.Hours * 60 + testVM.timeLimit.Minutes, testVM.Deadline);

            testService.AddTest(newTest);

            return(View("ShowKey", new ShowKeyVM(key)));
        }
예제 #2
0
        public async Task <ActionResult <Test> > PostTest(CreateTestVM vm)
        {
            Test test = new Test
            {
                AuditionId = vm.AuditionId,
                Title      = vm.Title,
                Topic      = vm.Topic,
                Questions  = vm.Questions
            };

            test = await testService.Create(test);

            return(CreatedAtAction("GetTest", new { id = test.Id }, test));
        }
예제 #3
0
        public ActionResult CreateTest()
        {
            List <templateInfo> schemaIDsList = new List <templateInfo>();
            List <TestTemplate> testTemplates = new List <TestTemplate>();

            testTemplates = testService.GetTestTemplates().ToList();
            foreach (TestTemplate t in testTemplates)
            {
                if (t.templateName == null)
                {
                    t.templateName = "Unnamed templated";
                }
                if (t.description == null)
                {
                    t.description = "No description";
                }
                schemaIDsList.Add(new templateInfo(t.testTemplateID, t.templateName, t.description));
            }

            CreateTestVM vm = new CreateTestVM(schemaIDsList);

            return(View(vm));
        }