public IActionResult Index(UserCodeDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(View("../Home/Index"));
            }
            var exercise = exerciseManager.GetById(model.ExerciseId);

            return(View(new CodeStartViewModel()
            {
                UserCodeDTO = model,
                ExerciseTaskText = exercise.TaskTextField
            }));
        }
        public IActionResult TaskView(int id)
        {
            var task        = exerciseManager.GetById(id);
            var commentList = commentManager.Get(g => g.ExerciseId == id).ToList();

            return(View(new GetExerciseViewModel()
            {
                Id = id,
                Course = task.Course,
                CommentList = commentList,
                TaskName = task.TaskName,
                TaskTextField = task.TaskTextField,
                TaskBaseCodeField = task.TaskBaseCodeField
            }));
        }
Esempio n. 3
0
        public UserCodeDTO BuildCodeModel(UserCodeDTO model)
        {
            var exercise = exerciseManager.GetById(model.ExerciseId);

            model.Exercise = exercise;
            if (model.CodeText == null)
            {
                model.CodeText = exercise.TaskBaseCodeField;
            }
            var user = userManager.FindByNameAsync(model.UserId).Result;

            model.UserId = user.Id;
            var code = unitOfWork.CodeRepo.Get(c => c.ExerciseId == model.ExerciseId && c.UserId == model.UserId).FirstOrDefault();

            if (code != null)
            {
                model.CodeText        = code.CodeText;
                model.CodeStatus      = code.CodeStatus;
                model.Mark            = code.Mark;
                model.TeachersComment = code.TeachersComment;
            }
            string text = IsUserDidExercise(user.Id, exercise.Id);

            if (text != null)
            {
                model.CodeText = text;
            }
            return(model);
        }
Esempio n. 4
0
        public UserCodeDTO BuildCodeModel(UserCodeDTO model)
        {
            var exercise = exerciseManager.GetById(model.ExerciseId);

            model.Exercise = exercise;
            var user = userManager.FindByNameAsync(model.UserId).Result;

            model.UserId = user.Id;
            if (model.CodeText != null)
            {
                model.CodeStatus = CodeStatus.FromHistory;
                return(model);
            }
            else
            {
                var code = unitOfWork.CodeRepo.Get(c => c.ExerciseId == model.ExerciseId && c.UserId == model.UserId).FirstOrDefault();
                if (code != null)
                {
                    model.CodeText        = code.CodeText;
                    model.CodeStatus      = code.CodeStatus;
                    model.Mark            = code.Mark;
                    model.TeachersComment = code.TeachersComment;
                }
                else
                {
                    model.CodeStatus = CodeStatus.InProgress;
                    model.CodeText   = exercise.TaskBaseCodeField;
                }
            }
            return(model);
        }
Esempio n. 5
0
        public UserCodeReviewViewModel Get(int id)
        {
            var userCode = codeManager.Get(c => c.Id == id).First();
            var exercise = exerciseManager.GetById(userCode.ExerciseId);

            return(new UserCodeReviewViewModel()
            {
                UserCodeDTO = userCode,
                ExerciseName = exercise.TaskName,
                ExerciseTask = exercise.TaskTextField
            });
        }
Esempio n. 6
0
        public IActionResult Update(int id)
        {
            var courseList = courseManager.Get(g => g.IsActive).ToList();
            var task       = exerciseManager.GetById(id);

            if (task == null)
            {
                return(NotFound());
            }
            return(View(new UpdateExerciseViewModel()
            {
                Id = id,
                CourseList = courseList,
                TaskName = task.TaskName,
                TaskTextField = task.TaskTextField,
                TaskBaseCodeField = task.TaskBaseCodeField,
                TestCases = task.TestCasesCode
            }));
        }
        public GetExerciseViewModel Get(int id)
        {
            var task = exerciseManager.GetById(id);

            var client  = new RestClient(configuration.GetConnectionString("WebAppRouteAPI"));
            var request = new RestRequest("api/CommentApi/{id}", Method.GET);

            request.AddUrlSegment("id", id);
            IRestResponse <List <CommentDTO> > response = client.Execute <List <CommentDTO> >(request);
            // var commentList = response.Data;
            var all = new GetExerciseViewModel()
            {
                Id                = id,
                Course            = task.Course,
                CommentList       = response.Data,
                TaskName          = task.TaskName,
                TaskTextField     = task.TaskTextField,
                TaskBaseCodeField = task.TaskBaseCodeField
            };

            return(all);
        }