Search in sources :

Example 1 with CourseAssessmentRequestDAO

use of fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO in project pyramus by otavanopisto.

the class ViewCourseViewController method process.

/**
 * Processes the page request by including the corresponding JSP page to the response.
 *
 * @param pageRequestContext Page request context
 */
public void process(PageRequestContext pageRequestContext) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseDescriptionDAO descriptionDAO = DAOFactory.getInstance().getCourseDescriptionDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    CourseComponentDAO courseComponentDAO = DAOFactory.getInstance().getCourseComponentDAO();
    CourseStaffMemberDAO courseStaffMemberDAO = DAOFactory.getInstance().getCourseStaffMemberDAO();
    ReportDAO reportDAO = DAOFactory.getInstance().getReportDAO();
    CourseAssessmentRequestDAO courseAssessmentRequestDAO = DAOFactory.getInstance().getCourseAssessmentRequestDAO();
    // The course to be edited
    Course course = courseDAO.findById(pageRequestContext.getLong("course"));
    pageRequestContext.getRequest().setAttribute("course", course);
    Map<Long, CourseAssessmentRequest> courseAssessmentRequests = new HashMap<>();
    List<CourseStudent> courseStudents = courseStudentDAO.listByCourse(course);
    Collections.sort(courseStudents, new Comparator<CourseStudent>() {

        @Override
        public int compare(CourseStudent o1, CourseStudent o2) {
            int cmp = o1.getStudent().getLastName().compareToIgnoreCase(o2.getStudent().getLastName());
            if (cmp == 0)
                cmp = o1.getStudent().getFirstName().compareToIgnoreCase(o2.getStudent().getFirstName());
            return cmp;
        }
    });
    List<CourseStaffMember> courseUsers = courseStaffMemberDAO.listByCourse(course);
    Collections.sort(courseUsers, new Comparator<CourseStaffMember>() {

        @Override
        public int compare(CourseStaffMember o1, CourseStaffMember o2) {
            int cmp = o1.getStaffMember().getLastName().compareToIgnoreCase(o2.getStaffMember().getLastName());
            if (cmp == 0)
                cmp = o1.getStaffMember().getFirstName().compareToIgnoreCase(o2.getStaffMember().getFirstName());
            return cmp;
        }
    });
    JSONArray courseReportsJSON = new JSONArray();
    List<Report> courseReports = reportDAO.listByContextType(ReportContextType.Course);
    Collections.sort(courseReports, new StringAttributeComparator("getName"));
    for (Report report : courseReports) {
        JSONObject obj = new JSONObject();
        obj.put("id", report.getId().toString());
        obj.put("name", report.getName());
        courseReportsJSON.add(obj);
    }
    for (CourseStudent courseStudent : courseStudents) {
        List<CourseAssessmentRequest> courseAssessmentRequestsByCourseStudent = courseAssessmentRequestDAO.listByCourseStudent(courseStudent);
        Collections.sort(courseAssessmentRequestsByCourseStudent, new Comparator<CourseAssessmentRequest>() {

            @Override
            public int compare(CourseAssessmentRequest o1, CourseAssessmentRequest o2) {
                return o2.getCreated().compareTo(o1.getCreated());
            }
        });
        if (!courseAssessmentRequestsByCourseStudent.isEmpty()) {
            courseAssessmentRequests.put(courseStudent.getId(), courseAssessmentRequestsByCourseStudent.get(0));
        }
    }
    setJsDataVariable(pageRequestContext, "courseReports", courseReportsJSON.toString());
    pageRequestContext.getRequest().setAttribute("courseStudents", courseStudents);
    pageRequestContext.getRequest().setAttribute("courseUsers", courseUsers);
    pageRequestContext.getRequest().setAttribute("courseComponents", courseComponentDAO.listByCourse(course));
    pageRequestContext.getRequest().setAttribute("courseDescriptions", descriptionDAO.listByCourseBase(course));
    pageRequestContext.getRequest().setAttribute("courseAssessmentRequests", courseAssessmentRequests);
    pageRequestContext.setIncludeJSP("/templates/courses/viewcourse.jsp");
}
Also used : HashMap(java.util.HashMap) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseDescriptionDAO(fi.otavanopisto.pyramus.dao.courses.CourseDescriptionDAO) StringAttributeComparator(fi.otavanopisto.pyramus.util.StringAttributeComparator) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseComponentDAO(fi.otavanopisto.pyramus.dao.courses.CourseComponentDAO) Report(fi.otavanopisto.pyramus.domainmodel.reports.Report) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) JSONArray(net.sf.json.JSONArray) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO) JSONObject(net.sf.json.JSONObject) CourseStaffMember(fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMember) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) ReportDAO(fi.otavanopisto.pyramus.dao.reports.ReportDAO)

Example 2 with CourseAssessmentRequestDAO

use of fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO in project pyramus by otavanopisto.

the class GradingService method listCourseAssessmentRequestsByStudent.

public CourseAssessmentRequestEntity[] listCourseAssessmentRequestsByStudent(@WebParam(name = "studentId") Long studentId) {
    CourseAssessmentRequestDAO courseAssessmentRequestDAO = DAOFactory.getInstance().getCourseAssessmentRequestDAO();
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    Student student = studentDAO.findById(studentId);
    return (CourseAssessmentRequestEntity[]) EntityFactoryVault.buildFromDomainObjects(courseAssessmentRequestDAO.listByStudent(student));
}
Also used : CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO)

Example 3 with CourseAssessmentRequestDAO

use of fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO in project pyramus by otavanopisto.

the class GradingService method listCourseAssessmentRequestsByCourse.

public CourseAssessmentRequestEntity[] listCourseAssessmentRequestsByCourse(@WebParam(name = "courseId") Long courseId) {
    CourseAssessmentRequestDAO courseAssessmentRequestDAO = DAOFactory.getInstance().getCourseAssessmentRequestDAO();
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    Course course = courseDAO.findById(courseId);
    return (CourseAssessmentRequestEntity[]) EntityFactoryVault.buildFromDomainObjects(courseAssessmentRequestDAO.listByCourse(course));
}
Also used : CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO)

Example 4 with CourseAssessmentRequestDAO

use of fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO in project pyramus by otavanopisto.

the class GradingService method createCourseAssessmentRequest.

public CourseAssessmentRequestEntity createCourseAssessmentRequest(@WebParam(name = "courseStudentId") Long courseStudentId, @WebParam(name = "created") Date created, @WebParam(name = "requestText") String requestText) {
    CourseAssessmentRequestDAO courseAssessmentRequestDAO = DAOFactory.getInstance().getCourseAssessmentRequestDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
    CourseAssessmentRequest courseAssessmentRequest = courseAssessmentRequestDAO.create(courseStudent, created, requestText);
    validateEntity(courseAssessmentRequest);
    return EntityFactoryVault.buildFromDomainObject(courseAssessmentRequest);
}
Also used : CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)

Example 5 with CourseAssessmentRequestDAO

use of fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO in project pyramus by otavanopisto.

the class GradingService method listCourseAssessmentRequestsByCourseStudent.

public CourseAssessmentRequestEntity[] listCourseAssessmentRequestsByCourseStudent(@WebParam(name = "courseStudentId") Long courseStudentId) {
    CourseAssessmentRequestDAO courseAssessmentRequestDAO = DAOFactory.getInstance().getCourseAssessmentRequestDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
    return (CourseAssessmentRequestEntity[]) EntityFactoryVault.buildFromDomainObjects(courseAssessmentRequestDAO.listByCourseStudent(courseStudent));
}
Also used : CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO)

Aggregations

CourseAssessmentRequestDAO (fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO)7 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)6 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)6 CourseAssessmentRequest (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)4 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)3 CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)2 ReportDAO (fi.otavanopisto.pyramus.dao.reports.ReportDAO)2 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)2 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)2 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 PageRequestContext (fi.internetix.smvc.controllers.PageRequestContext)1 RequestContext (fi.internetix.smvc.controllers.RequestContext)1 Messages (fi.otavanopisto.pyramus.I18N.Messages)1 Breadcrumbable (fi.otavanopisto.pyramus.breadcrumbs.Breadcrumbable)1 DAOFactory (fi.otavanopisto.pyramus.dao.DAOFactory)1 CurriculumDAO (fi.otavanopisto.pyramus.dao.base.CurriculumDAO)1 PersonDAO (fi.otavanopisto.pyramus.dao.base.PersonDAO)1 CourseComponentDAO (fi.otavanopisto.pyramus.dao.courses.CourseComponentDAO)1