Esempio n. 1
0
        public IActionResult SynthesisExam(int testId, byte[] timeStamp)
        {
            var stsEntity = _synthesisRepository.GetAssignmentWithTaskAndTemplate(UserId, testId);

            if (stsEntity == null)
            {
                return(Unauthorized());
            }

            if (!stsEntity.TakenTest)
            {
                _synthesisRepository.MarkExamAsTaken(testId, UserId, ref timeStamp);
            }

            var taskEntity = stsEntity.SynthesisTest.Task;
            var vm         = new SynthesisExamVM()
            {
                Title            = stsEntity.SynthesisTest.Name,
                TestId           = stsEntity.SynthesisTestId,
                StudentId        = stsEntity.StudentId,
                TimeStamp        = Convert.ToBase64String(timeStamp),
                NameOnServer     = taskEntity.Template.NameOnServer,
                SqlScript        = stsEntity.SqlScript ?? string.Empty,
                TaskDescription  = taskEntity.Description,
                ModelDescription = taskEntity.Template.ModelDescription
            };

            return(View(vm));
        }
Esempio n. 2
0
        public IActionResult SynthesisExamReadonly(Guid studentId, int testId)
        {
            var stsEntity = _synthesisRepository.GetAssignmentWithTaskAndTemplate(studentId, testId);

            if (stsEntity == null || !stsEntity.TakenTest)
            {
                throw new Exception("Test not found or taken");
            }

            var taskEntity = stsEntity.SynthesisTest.Task;
            var vm         = new SynthesisExamVM()
            {
                Title            = stsEntity.SynthesisTest.Name,
                TestId           = stsEntity.SynthesisTestId,
                StudentId        = stsEntity.StudentId,
                NameOnServer     = taskEntity.Template.NameOnServer,
                SqlScript        = stsEntity.SqlScript ?? string.Empty,
                TaskDescription  = taskEntity.Description,
                ModelDescription = taskEntity.Template.ModelDescription,
                ReadOnly         = true
            };

            return(View("SynthesisExam", vm));
        }