use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment in project pyramus by otavanopisto.
the class ListStudentProjectsJSONRequestController method beanify.
private StudentProjectBean beanify(StudentProject studentProject, CourseDAO courseDAO, CourseStudentDAO courseStudentDAO, TransferCreditDAO transferCreditDAO, CourseAssessmentDAO courseAssessmentDAO, ProjectAssessmentDAO projectAssessmentDAO) {
int mandatoryModuleCount = 0;
int optionalModuleCount = 0;
int passedMandatoryModuleCount = 0;
int passedOptionalModuleCount = 0;
/**
* Go through project modules to
* a) count mandatory/optional modules
* b) count mandatory/optional modules that have passing grade on them
* c) create beans to be passed to jsp
*/
List<TransferCredit> transferCreditsByStudent = transferCreditDAO.listByStudent(studentProject.getStudent());
for (StudentProjectModule studentProjectModule : studentProject.getStudentProjectModules()) {
boolean hasPassingGrade = false;
List<CourseStudent> courseStudentList = courseStudentDAO.listByModuleAndStudent(studentProjectModule.getModule(), studentProject.getStudent());
// Find out if there is a course that has passing grade for the module
if (courseStudentList != null) {
for (CourseStudent cs : courseStudentList) {
CourseAssessment ca = courseAssessmentDAO.findLatestByCourseStudentAndArchived(cs, Boolean.FALSE);
if (ca != null && ca.getGrade() != null && ca.getGrade().getPassingGrade()) {
hasPassingGrade = true;
break;
}
}
}
if (!hasPassingGrade) {
if ((studentProjectModule.getModule().getCourseNumber() != null) && (studentProjectModule.getModule().getCourseNumber() != -1) && (studentProjectModule.getModule().getSubject() != null)) {
for (TransferCredit tc : transferCreditsByStudent) {
if ((tc.getCourseNumber() != null) && (tc.getCourseNumber() != -1) && (tc.getSubject() != null)) {
if (tc.getCourseNumber().equals(studentProjectModule.getModule().getCourseNumber()) && tc.getSubject().equals(studentProjectModule.getModule().getSubject())) {
if (tc.getGrade() != null && tc.getGrade().getPassingGrade()) {
hasPassingGrade = true;
break;
}
}
}
}
}
}
if (studentProjectModule.getOptionality() == CourseOptionality.MANDATORY) {
mandatoryModuleCount++;
if (hasPassingGrade)
passedMandatoryModuleCount++;
} else if (studentProjectModule.getOptionality() == CourseOptionality.OPTIONAL) {
optionalModuleCount++;
if (hasPassingGrade)
passedOptionalModuleCount++;
}
}
List<ProjectAssessment> projectAssessments = projectAssessmentDAO.listByProjectAndArchived(studentProject, Boolean.FALSE);
Collections.sort(projectAssessments, new Comparator<ProjectAssessment>() {
@Override
public int compare(ProjectAssessment o1, ProjectAssessment o2) {
return o2.getDate().compareTo(o1.getDate());
}
});
return new StudentProjectBean(studentProject, mandatoryModuleCount, optionalModuleCount, passedMandatoryModuleCount, passedOptionalModuleCount, projectAssessments);
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment in project pyramus by otavanopisto.
the class GradingService method getCourseAssessmentByCourseStudentId.
public CourseAssessmentEntity getCourseAssessmentByCourseStudentId(@WebParam(name = "courseStudentId") Long courseStudentId) {
CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
CourseAssessment courseAssessment = courseAssessmentDAO.findLatestByCourseStudentAndArchived(courseStudent, Boolean.FALSE);
return EntityFactoryVault.buildFromDomainObject(courseAssessment);
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment in project pyramus by otavanopisto.
the class StudentRESTService method findLatestStudentWorkspaceAssessment.
@Path("/students/{STUDENTID:[0-9]*}/latestCourseAssessment/")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response findLatestStudentWorkspaceAssessment(@PathParam("STUDENTID") Long studentId) {
Student student = studentController.findStudentById(studentId);
if (student == null) {
return Response.status(Status.NOT_FOUND).build();
}
if (student.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!restSecurity.hasPermission(new String[] { CourseAssessmentPermissions.LIST_ALL_STUDENT_COURSEASSESSMENTS, PersonPermissions.PERSON_OWNER }, student.getPerson(), Style.OR)) {
return Response.status(Status.FORBIDDEN).build();
}
List<CourseAssessment> courseAssessments = assessmentController.listByStudent(student);
if (CollectionUtils.isEmpty(courseAssessments)) {
return Response.status(Status.NOT_FOUND).build();
}
Collections.sort(courseAssessments, new Comparator<CourseAssessment>() {
public int compare(CourseAssessment o1, CourseAssessment o2) {
return o2.getDate().compareTo(o1.getDate());
}
});
return Response.ok(objectFactory.createModel(courseAssessments.get(0))).build();
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment in project pyramus by otavanopisto.
the class StudentRESTService method listStudentAssessments.
@Path("/students/{STUDENTID:[0-9]*}/assessments/")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response listStudentAssessments(@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_ALL_STUDENT_COURSEASSESSMENTS, StudentPermissions.STUDENT_OWNER }, student, Style.OR)) {
return Response.status(Status.FORBIDDEN).build();
}
List<CourseAssessment> assessments = assessmentController.listByStudent(student);
return Response.ok(objectFactory.createModel(assessments)).build();
}
use of fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment in project pyramus by otavanopisto.
the class StudentRESTService method listCourseAssessments.
@Path("/students/{STUDENTID:[0-9]*}/courses/{COURSEID:[0-9]*}/assessments/")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response listCourseAssessments(@PathParam("STUDENTID") Long studentId, @PathParam("COURSEID") Long courseId) {
if (!sessionController.isLoggedIn()) {
return Response.status(Status.FORBIDDEN).build();
}
Student student = studentController.findStudentById(studentId);
if (student == null || student.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
Course course = courseController.findCourseById(courseId);
if (course == null || course.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!(UserUtils.isOwnerOf(sessionController.getUser(), student.getPerson()) || sessionController.hasPermission(CourseAssessmentPermissions.LIST_STUDENT_COURSEASSESSMENTS, course))) {
return Response.status(Status.FORBIDDEN).build();
} else {
// User has the required permission, check if it's restricted to limited group of students
if (sessionController.hasEnvironmentPermission(StudentPermissions.FEATURE_OWNED_GROUP_STUDENTS_RESTRICTION)) {
StaffMember staffMember = sessionController.getUser() instanceof StaffMember ? (StaffMember) sessionController.getUser() : null;
if (staffMember != null) {
if (!(courseController.isCourseStaffMember(course, staffMember) || studentController.isStudentGuider(staffMember, student))) {
return Response.status(Status.FORBIDDEN).build();
}
} else {
return Response.status(Status.FORBIDDEN).build();
}
}
}
List<CourseAssessment> courseAssessments = assessmentController.listByCourseAndStudent(course, student);
return Response.ok(objectFactory.createModel(courseAssessments)).build();
}
Aggregations