use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest in project pyramus by otavanopisto.
the class CompositeRESTService method listAssessmentRequestsByCourse.
@Path("/course/{COURSEID:[0-9]*}/assessmentRequests")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response listAssessmentRequestsByCourse(@PathParam("COURSEID") Long courseId, @QueryParam("courseStudentIds") String courseStudentIds) {
Course course = courseController.findCourseById(courseId);
if (course == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (!sessionController.hasPermission(CourseAssessmentPermissions.LIST_STUDENT_COURSEASSESSMENTS, course)) {
return Response.status(Status.FORBIDDEN).build();
}
List<CourseStudent> courseStudents;
if (courseStudentIds != null) {
courseStudents = new ArrayList<CourseStudent>();
// Empty courseStudentIds can be provided but is interpreted as empty array
if (StringUtils.isNotBlank(courseStudentIds)) {
String[] courseStudentIdArray = courseStudentIds.split(",");
for (int i = 0; i < courseStudentIdArray.length; i++) {
CourseStudent courseStudent = courseController.findCourseStudentById(new Long(courseStudentIdArray[i]));
if (courseStudent != null && !courseStudent.getArchived() && !courseStudent.getStudent().getArchived()) {
courseStudents.add(courseStudent);
}
}
}
} else {
courseStudents = courseController.listCourseStudentsByCourse(course);
}
List<CompositeAssessmentRequest> assessmentRequests = new ArrayList<CompositeAssessmentRequest>();
if (CollectionUtils.isNotEmpty(courseStudents)) {
boolean isStudyGuider = sessionController.hasEnvironmentPermission(StudentPermissions.FEATURE_OWNED_GROUP_STUDENTS_RESTRICTION);
for (CourseStudent courseStudent : courseStudents) {
if (isStudyGuider) {
StaffMember staffMember = sessionController.getUser() instanceof StaffMember ? (StaffMember) sessionController.getUser() : null;
if (staffMember == null || !studentController.isStudentGuider(staffMember, courseStudent.getStudent()))
continue;
}
CourseAssessmentRequest courseAssessmentRequest = assessmentController.findLatestCourseAssessmentRequestByCourseStudent(courseStudent);
CourseAssessment courseAssessment = assessmentController.findLatestCourseAssessmentByCourseStudentAndArchived(courseStudent, Boolean.FALSE);
CompositeAssessmentRequest assessmentRequest = new CompositeAssessmentRequest();
assessmentRequest.setCourseStudentId(courseStudent.getId());
assessmentRequest.setAssessmentRequestDate(courseAssessmentRequest == null ? null : courseAssessmentRequest.getCreated());
assessmentRequest.setCourseEnrollmentDate(courseStudent.getEnrolmentTime());
assessmentRequest.setEvaluationDate(courseAssessment == null ? null : courseAssessment.getDate());
assessmentRequest.setPassing(courseAssessment != null && courseAssessment.getGrade() != null && courseAssessment.getGrade().getPassingGrade());
assessmentRequest.setCourseId(course.getId());
assessmentRequest.setCourseName(course.getName());
assessmentRequest.setCourseNameExtension(course.getNameExtension());
String firstName = courseStudent.getStudent().getFirstName();
if (courseStudent.getStudent().getNickname() != null) {
firstName = String.format("%s \"%s\"", firstName, courseStudent.getStudent().getNickname());
}
assessmentRequest.setFirstName(firstName);
assessmentRequest.setLastName(courseStudent.getStudent().getLastName());
assessmentRequest.setStudyProgramme(courseStudent.getStudent().getStudyProgramme().getName());
assessmentRequest.setUserId(courseStudent.getStudent().getId());
assessmentRequests.add(assessmentRequest);
}
}
return Response.ok(assessmentRequests).build();
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest in project pyramus by otavanopisto.
the class StudentController method listCourseActivities.
/* Course activity */
public List<CourseActivity> listCourseActivities(List<CourseStudent> courseStudents, boolean includeTransferCredits) {
if (courseStudents.isEmpty()) {
return Collections.emptyList();
}
Student student = courseStudents.get(0).getStudent();
List<CourseActivity> courseActivities = new ArrayList<>();
List<CreditLink> linkedAssessments = creditLinkDAO.listByStudentAndType(student, CreditType.CourseAssessment);
for (CourseStudent courseStudent : courseStudents) {
Course course = courseStudent.getCourse();
// Construct course base information and assume it's ongoing
CourseActivity courseActivity = new CourseActivity();
courseActivity.setCourseId(course.getId());
courseActivity.setCurriculumIds(course.getCurriculums().stream().map(Curriculum::getId).collect(Collectors.toList()));
String courseName = course.getName();
if (!StringUtils.isEmpty(course.getNameExtension())) {
courseName = String.format("%s (%s)", courseName, course.getNameExtension());
}
courseActivity.setCourseName(courseName);
courseActivity.setActivityDate(courseStudent.getEnrolmentTime());
courseActivity.setState(CourseActivityState.ONGOING);
// Status override if course has been graded
CourseAssessment courseAssessment = courseAssessmentDAO.findLatestByCourseStudentAndArchived(courseStudent, Boolean.FALSE);
if (courseAssessment != null && courseAssessment.getGrade() != null) {
courseActivity.setText(courseAssessment.getVerbalAssessment());
courseActivity.setGrade(courseAssessment.getGrade().getName());
courseActivity.setPassingGrade(courseAssessment.getGrade().getPassingGrade());
courseActivity.setActivityDate(courseAssessment.getDate());
courseActivity.setGradeDate(courseAssessment.getDate());
courseActivity.setState(CourseActivityState.GRADED);
}
// Status override if course has been graded as linked credit
CreditLink linkedAssessment = linkedAssessments.stream().filter(creditLink -> course.getId().equals(((CourseAssessment) creditLink.getCredit()).getCourseStudent().getCourse().getId())).findAny().orElse(null);
if (linkedAssessment != null) {
courseActivity.setText(((CourseAssessment) linkedAssessment.getCredit()).getVerbalAssessment());
courseActivity.setGrade(((CourseAssessment) linkedAssessment.getCredit()).getGrade().getName());
courseActivity.setPassingGrade(((CourseAssessment) linkedAssessment.getCredit()).getGrade().getPassingGrade());
courseActivity.setActivityDate(linkedAssessment.getCreated());
courseActivity.setGradeDate(linkedAssessment.getCreated());
courseActivity.setState(CourseActivityState.GRADED);
}
// Status override if student has requested the course to be assessed
CourseAssessmentRequest request = courseAssessmentRequestDAO.findLatestByCourseStudent(courseStudent);
if (request != null && !request.getHandled() && request.getCreated().after(courseActivity.getActivityDate())) {
courseActivity.setText(request.getRequestText());
courseActivity.setActivityDate(request.getCreated());
courseActivity.setState(CourseActivityState.ASSESSMENT_REQUESTED);
}
courseActivities.add(courseActivity);
}
if (includeTransferCredits) {
List<TransferCredit> transferCredits = listStudentTransferCredits(student);
for (TransferCredit transferCredit : transferCredits) {
CourseActivity courseActivity = new CourseActivity();
courseActivity.setCurriculumIds(Collections.emptyList());
courseActivity.setCourseName(transferCredit.getCourseName());
courseActivity.setGrade(transferCredit.getGrade().getName());
courseActivity.setPassingGrade(transferCredit.getGrade().getPassingGrade());
courseActivity.setActivityDate(transferCredit.getDate());
courseActivity.setState(CourseActivityState.TRANSFERRED);
courseActivities.add(courseActivity);
}
// Linked transfer credits
List<CreditLink> linkedTransferCredits = includeTransferCredits ? listStudentLinkedTransferCredits(student) : Collections.emptyList();
for (CreditLink creditLink : linkedTransferCredits) {
TransferCredit transferCredit = (TransferCredit) creditLink.getCredit();
CourseActivity courseActivity = new CourseActivity();
courseActivity.setCurriculumIds(Collections.emptyList());
courseActivity.setCourseName(transferCredit.getCourseName());
courseActivity.setGrade(transferCredit.getGrade().getName());
courseActivity.setPassingGrade(transferCredit.getGrade().getPassingGrade());
courseActivity.setActivityDate(transferCredit.getDate());
courseActivity.setState(CourseActivityState.TRANSFERRED);
courseActivities.add(courseActivity);
}
}
return courseActivities;
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest in project pyramus by otavanopisto.
the class StudentRESTService method listStudentAssessmentRequests.
@Path("/students/{STUDENTID:[0-9]*}/assessmentRequests/")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response listStudentAssessmentRequests(@PathParam("STUDENTID") Long studentId) {
Student student = studentController.findStudentById(studentId);
Status studentStatus = checkStudent(student);
if (studentStatus != Status.OK)
return Response.status(studentStatus).build();
if (!restSecurity.hasPermission(new String[] { CourseAssessmentPermissions.LIST_COURSEASSESSMENTREQUESTS, StudentPermissions.STUDENT_OWNER }, student, Style.OR)) {
return Response.status(Status.FORBIDDEN).build();
}
List<CourseAssessmentRequest> assessmentRequests = assessmentController.listCourseAssessmentRequestsByStudent(student);
return Response.ok(objectFactory.createModel(assessmentRequests)).build();
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest in project pyramus by otavanopisto.
the class AssessmentController method createCourseAssessment.
public CourseAssessment createCourseAssessment(CourseStudent courseStudent, StaffMember assessingUser, Grade grade, Date date, String verbalAssessment) {
CourseAssessment courseAssessment = courseAssessmentDAO.create(courseStudent, assessingUser, grade, date, verbalAssessment);
// Mark respective course assessment requests as handled
List<CourseAssessmentRequest> courseAssessmentRequests = courseAssessmentRequestDAO.listByCourseStudentAndHandledAndArchived(courseStudent, Boolean.FALSE, Boolean.FALSE);
for (CourseAssessmentRequest courseAssessmentRequest : courseAssessmentRequests) {
courseAssessmentRequestDAO.updateHandled(courseAssessmentRequest, Boolean.TRUE);
}
return courseAssessment;
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest in project pyramus by otavanopisto.
the class AssessmentController method updateCourseAssessment.
public CourseAssessment updateCourseAssessment(CourseAssessment courseAssessment, StaffMember assessingUser, Grade grade, Date assessmentDate, String verbalAssessment) {
// Update course assessment...
courseAssessment = courseAssessmentDAO.update(courseAssessment, assessingUser, grade, assessmentDate, verbalAssessment);
// ...and mark respective course assessment requests as handled
List<CourseAssessmentRequest> courseAssessmentRequests = courseAssessmentRequestDAO.listByCourseStudentAndHandledAndArchived(courseAssessment.getCourseStudent(), Boolean.FALSE, Boolean.FALSE);
for (CourseAssessmentRequest courseAssessmentRequest : courseAssessmentRequests) {
courseAssessmentRequestDAO.updateHandled(courseAssessmentRequest, Boolean.TRUE);
}
return courseAssessment;
}
Aggregations