Пример #1
0
        public void SaveMarkOnTaskOfStudent(N_To_N_TaskStudent __model)
        {
            N_To_N_TaskStudent model = _dataBaseContext.N_To_N_TaskStudent.FirstOrDefault(x => x.TaskId == __model.TaskId &&
                                                                                          x.StudentId == __model.StudentId);

            model.MarkValue       = __model.MarkValue;
            model.MarkDescription = __model.MarkDescription;

            _dataBaseContext.SaveChanges();
        }
Пример #2
0
        public void DeleteTaskMark(int taskId, int studentId)
        {
            N_To_N_TaskStudent model = _dataBaseContext.N_To_N_TaskStudent.FirstOrDefault(x => x.TaskId == taskId &&
                                                                                          x.StudentId == studentId);

            if (model != null)
            {
                model.MarkValue       = -1;
                model.MarkDescription = "";

                _dataBaseContext.SaveChanges();
            }
        }
Пример #3
0
        public void RemoveSolutionOnTask(N_To_N_TaskStudent __model)
        {
            N_To_N_TaskStudent model =
                _dataBaseContext.N_To_N_TaskStudent.FirstOrDefault(x => x.TaskId == __model.TaskId &&
                                                                   x.StudentId == __model.StudentId);

            if (model != null)
            {
                _fileService.DeleteFile(model.SolutionPath);
                _dataBaseContext.Remove(model);
                _dataBaseContext.SaveChanges();
            }
        }
Пример #4
0
        public async System.Threading.Tasks.Task SendSolutionOnTask(Student student, Models.Task task, IFormFile uploadedFile)
        {
            N_To_N_TaskStudent model = new N_To_N_TaskStudent
            {
                MarkValue = -1,
                StudentId = student.Id,
                TaskId    = task.Id,
                LoadTime  = DateTime.Now
            };

            RemoveSolutionOnTask(model);

            _dataBaseContext.N_To_N_TaskStudent.Add(model);
            _dataBaseContext.SaveChanges();

            await _fileService.UploadTaskSolutionFile(model, uploadedFile);
        }
Пример #5
0
        public async Task <IActionResult> IndexStudent(int taskId, int subjectId)
        {
            Student student = await _authentication.GetCurrentStudentAsync();

            Models.Task task = _databaseWorker.GetTaskById(taskId);

            // check taskId

            N_To_N_TaskStudent  taskStudent = _taskService.GetTaskStudent(task, student);
            StatusTaskViewModel model       = new StatusTaskViewModel
            {
                Task        = task,
                TaskStudent = taskStudent,
                PresentTime = DateTime.Now,
                SubjectId   = subjectId
            };

            return(View(model));
        }
Пример #6
0
        public async System.Threading.Tasks.Task UploadTaskSolutionFile(N_To_N_TaskStudent __model, IFormFile uploadedFile)
        {
            if (uploadedFile != null)
            {
                N_To_N_TaskStudent model = _dataBaseContext.N_To_N_TaskStudent.FirstOrDefault(x => x.Id == __model.Id);
                string             path  = _appEnvironment.WebRootPath + "/files/task_answers/" + model.Id + "/";

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                using (FileStream fileStream = new FileStream(path + uploadedFile.FileName, FileMode.Create))
                {
                    await uploadedFile.CopyToAsync(fileStream);
                }

                model.SolutionPath = "/files/task_answers/" + model.Id + "/" + uploadedFile.FileName;

                _dataBaseContext.SaveChanges();
            }
        }
Пример #7
0
        public IActionResult MarkTask(int taskId, int studentId)
        {
            N_To_N_TaskStudent model = _taskService.GetTaskStudent(taskId, studentId);

            return(View(model));
        }
Пример #8
0
 public IActionResult MarkTask(N_To_N_TaskStudent model)
 {
     _taskService.SaveMarkOnTaskOfStudent(model);
     return(RedirectToAction("IndexTeacher", new { taskId = model.TaskId }));
 }