Search in sources :

Example 1 with CourseAssessment

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);
}
Also used : CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) StudentProjectModule(fi.otavanopisto.pyramus.domainmodel.projects.StudentProjectModule) ProjectAssessment(fi.otavanopisto.pyramus.domainmodel.grading.ProjectAssessment) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) TransferCredit(fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit)

Example 2 with CourseAssessment

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);
}
Also used : CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)

Example 3 with 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();
}
Also used : CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentGroupStudent(fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Example 4 with CourseAssessment

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();
}
Also used : Status(javax.ws.rs.core.Response.Status) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentGroupStudent(fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Example 5 with CourseAssessment

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();
}
Also used : CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentGroupStudent(fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)43 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)28 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)24 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)21 CourseAssessmentDAO (fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO)15 TransferCredit (fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit)14 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)14 CreditLink (fi.otavanopisto.pyramus.domainmodel.grading.CreditLink)11 Grade (fi.otavanopisto.pyramus.domainmodel.grading.Grade)10 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)10 ArrayList (java.util.ArrayList)10 Path (javax.ws.rs.Path)10 StudentGroupStudent (fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent)9 Date (java.util.Date)9 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)8 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)8 HashMap (java.util.HashMap)8 CreditLinkDAO (fi.otavanopisto.pyramus.dao.grading.CreditLinkDAO)7 TransferCreditDAO (fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO)7 Subject (fi.otavanopisto.pyramus.domainmodel.base.Subject)7