private static StudentGradeSubmissionBundle MakeStudentGradeSubmissionBundle() { var assignmentAnswerKey = CreateAssignmentAnswerKey(); var studentAssignmentSubmission = new StudentAssignmentSubmission(Guid.Empty, Guid.Empty, Guid.Empty, assignmentAnswerKey.MultipleChoiceQuestionAnswerCollection.Select(x => new StudentAssignmentSubmissionMultipleChoiceQuestionAnswer(x.QuestionID, x.AnswerID))); return(new StudentGradeSubmissionBundle(assignmentAnswerKey, studentAssignmentSubmission)); }
public ActionResult Submit(int id) { StudentAssignment studentassignment = db.StudentAssignments.Find(id); int studentid = 0; int roleid = Convert.ToInt16(Session["RoleID"].ToString()); if (roleid == 5) { int userid = Convert.ToInt16(Session["UserID"].ToString()); Student student = db.Students.Where(t => t.UserID == userid).FirstOrDefault(); studentid = student.StudentID; ViewBag.StudentID = new SelectList(db.Students.Where(s => s.ClassID == studentassignment.ClassID && s.SectionID == studentassignment.SectionID).OrderByDescending(e => e.Name), "StudentID", "Name", studentid); } if (studentid == 0) { ViewBag.StudentID = new SelectList(db.Students.Where(s => s.ClassID == studentassignment.ClassID && s.SectionID == studentassignment.SectionID).OrderByDescending(e => e.Name), "StudentID", "Name"); } StudentAssignmentSubmission studentassignmentsubmission = new StudentAssignmentSubmission(); studentassignmentsubmission.StudentAssignmentID = id; studentassignmentsubmission.StudentID = studentid; studentassignmentsubmission.Remarks = "Submitted asignment"; studentassignmentsubmission.SubmittedDate = DateTime.Now; ViewBag.Message = Session["msg"]; ViewBag.Error = Session["err"]; Session["err"] = ""; Session["msg"] = ""; return(View(studentassignmentsubmission)); }
private async Task DisplayGrade(StudentAssignmentSubmission completedAssignment) { var grade = await ViewModel.GradeAssignment(completedAssignment); await DisplayAlert("Assignment Submitted", $"{grade.NumberOfCorrectAnswers} / {grade.NumberOfQuestions}", "OK"); await Navigation.PopToRootAsync(); }
public ActionResult EditSubmit(int id) { StudentAssignmentSubmission studentassignmentsubmission = db.StudentAssignmentSubmissions.Find(id); StudentAssignment studentassignment = db.StudentAssignments.Find(studentassignmentsubmission.StudentAssignmentID); ViewBag.Message = Session["msg"]; ViewBag.Error = Session["err"]; Session["err"] = ""; Session["msg"] = ""; ViewBag.StudentID = new SelectList(db.Students.Where(s => s.ClassID == studentassignment.ClassID && s.SectionID == studentassignment.SectionID).OrderByDescending(e => e.Name), "StudentID", "Name", studentassignmentsubmission.StudentID); ViewBag.Existing = studentassignmentsubmission.StudentID.ToString(); return(View(studentassignmentsubmission)); }
public ActionResult DeleteConfirmSubmit(int id) { Session["err"] = "Error, Please check dependent data"; Session["msg"] = ""; StudentAssignmentSubmission studentassignmentsubmission = db.StudentAssignmentSubmissions.Find(id); try { db.StudentAssignmentSubmissions.Remove(studentassignmentsubmission); db.SaveChanges(); Session["err"] = ""; Session["msg"] = "Deleted Successfully"; } catch { } return(Redirect("/StudentAssignment/IndexSubmit/" + studentassignmentsubmission.StudentAssignmentID)); }
public ActionResult EditSubmit([Bind(Include = "StudentAssignmentSubmissionID,StudentAssignmentID,StudentID,Remarks,SubmittedDate")] StudentAssignmentSubmission studentassignmentsubmission, string existing) { Session["err"] = "Error, Please check input fields"; Session["msg"] = ""; StudentAssignment studentassignment = db.StudentAssignments.Find(studentassignmentsubmission.StudentAssignmentID); ViewBag.Existing = existing; try { int studentidexist = Convert.ToInt16(existing); if (studentassignmentsubmission.StudentID != studentidexist) { StudentAssignmentSubmission exist = db.StudentAssignmentSubmissions.Include(t => t.CurrentStudentAssignment).Include(t => t.CurrentStudent).Include(t => t.CurrentStudent.CurrentSection).Include(t => t.CurrentStudent.CurrentClass).Where(t => t.CurrentStudent.StudentID == studentassignmentsubmission.StudentID && t.CurrentStudent.StudentID != studentidexist).FirstOrDefault(); if (exist != null) { Session["err"] = "Student already submitted for this assignment"; Session["msg"] = ""; ViewBag.Message = Session["msg"]; ViewBag.Error = Session["err"]; Session["err"] = ""; Session["msg"] = ""; ViewBag.StudentID = new SelectList(db.Students.Where(s => s.ClassID == studentassignment.ClassID && s.SectionID == studentassignment.SectionID).OrderByDescending(e => e.Name), "StudentID", "Name", studentassignmentsubmission.StudentID); return(View(studentassignmentsubmission)); } } db.Entry(studentassignmentsubmission).State = EntityState.Modified; db.SaveChanges(); Session["err"] = ""; Session["msg"] = "Modified Successfully"; return(Redirect("/StudentAssignment/IndexSubmit/" + studentassignmentsubmission.StudentAssignmentID)); } catch { } ViewBag.Message = Session["msg"]; ViewBag.Error = Session["err"]; Session["err"] = ""; Session["msg"] = ""; ViewBag.StudentID = new SelectList(db.Students.Where(s => s.ClassID == studentassignment.ClassID && s.SectionID == studentassignment.SectionID).OrderByDescending(e => e.Name), "StudentID", "Name", studentassignmentsubmission.StudentID); return(View(studentassignmentsubmission)); }
public ActionResult Submit([Bind(Include = "StudentAssignmentSubmissionID,StudentAssignmentID,StudentID,Remarks,SubmittedDate")] StudentAssignmentSubmission studentassignmentsubmission) { Session["err"] = "Error, Please check input fields"; Session["msg"] = ""; StudentAssignment studentassignment = db.StudentAssignments.Find(studentassignmentsubmission.StudentAssignmentID); try { StudentAssignmentSubmission exist = db.StudentAssignmentSubmissions.Include(t => t.CurrentStudentAssignment).Include(t => t.CurrentStudent).Include(t => t.CurrentStudent.CurrentSection).Include(t => t.CurrentStudent.CurrentClass).Where(t => t.CurrentStudent.StudentID == studentassignmentsubmission.StudentID).FirstOrDefault(); if (exist != null) { Session["err"] = "Student already submitted for this assignment"; Session["msg"] = ""; ViewBag.Message = Session["msg"]; ViewBag.Error = Session["err"]; Session["err"] = ""; Session["msg"] = ""; ViewBag.StudentID = new SelectList(db.Students.Where(s => s.ClassID == studentassignment.ClassID && s.SectionID == studentassignment.SectionID).OrderByDescending(e => e.Name), "StudentID", "Name", studentassignmentsubmission.StudentID); return(View(studentassignmentsubmission)); } db.StudentAssignmentSubmissions.Add(studentassignmentsubmission); db.SaveChanges(); Session["err"] = ""; Session["msg"] = "Submitted Successfully"; //return RedirectToAction("Index"); } catch { } ViewBag.Message = Session["msg"]; ViewBag.Error = Session["err"]; Session["err"] = ""; Session["msg"] = ""; ViewBag.StudentID = new SelectList(db.Students.Where(s => s.ClassID == studentassignment.ClassID && s.SectionID == studentassignment.SectionID).OrderByDescending(e => e.Name), "StudentID", "Name", studentassignmentsubmission.StudentID); return(View(studentassignmentsubmission)); }
public async Task <StudentGrade> GradeAssignment(StudentAssignmentSubmission completedAssignment) { var answerKey = (await _getAssignmentAsyncQueryHandler.Handle(new GetAssignmentAnswerKeyQuery(completedAssignment.EducatorID, completedAssignment.AssignmentID))).EnsureSuccess(); return(new StudentGradeSubmissionBundle(answerKey, completedAssignment).ComputeGrade()); }
public static StudentAssignmentSubmissionDataSpecification ToStudentAssignmentSubmissionDataSpecification(this StudentAssignmentSubmission source) { return(new StudentAssignmentSubmissionDataSpecification { EducatorID = source.EducatorID, AssignmentID = source.AssignmentID, StudentID = source.StudentID, AnswerCollection = source.MultipleChoiceQuestionAnswerCollection.Select(x => StudentAssignmentSubmissionMultipleChoiceQuestionAnswerDataSpecificationExtensions.ToStudentAssignmentSubmissionAnswerEntryDataSpecification(x)).ToArray() }); }
public SubmitStudentAssignmentCommand(StudentAssignmentSubmission data) { Data = data ?? throw new ArgumentNullException(nameof(data)); }
public StudentGradeSubmissionBundle(AssignmentAnswerKey assignment, StudentAssignmentSubmission studentAssignmentSubmission) { AssignmentAnswerKey = assignment ?? throw new ArgumentNullException(nameof(assignment)); StudentAssignmentSubmission = studentAssignmentSubmission ?? throw new ArgumentNullException(nameof(studentAssignmentSubmission)); }
private static async Task <Result <Unit, Exception> > WriteAssignmentSubmission(StudentAssignmentSubmission data) { await Task.Delay(1000); return(Result.Try(() => { var jsonContents = JsonConvert.SerializeObject(data.ToStudentAssignmentSubmissionDataSpecification()); File.WriteAllText(new StudentAssignmentSubmissionFileInfo(data.EducatorID, data.AssignmentID, data.StudentID).ToFilePath(), jsonContents, Encoding.UTF8); return Unit.Value; })); }