Search in sources :

Example 6 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO 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 7 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO in project pyramus by otavanopisto.

the class CourseStudentDetailsDialogViewController method process.

public void process(PageRequestContext pageRequestContext) {
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    RoomTypeDAO roomTypeDAO = DAOFactory.getInstance().getRoomTypeDAO();
    RoomDAO roomDAO = DAOFactory.getInstance().getRoomDAO();
    Long courseStudentId = pageRequestContext.getLong("courseStudentId");
    if (courseStudentId == null) {
        throw new SmvcRuntimeException(PyramusStatusCode.UNDEFINED, "Missing courseStudentId parameter");
    }
    CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
    if (courseStudent == null) {
        throw new SmvcRuntimeException(PyramusStatusCode.UNDEFINED, "Invalid courseStudentId parameter");
    }
    Map<RoomType, List<Room>> rooms = new TreeMap<>(new Comparator<RoomType>() {

        @Override
        public int compare(RoomType o1, RoomType o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    List<RoomType> roomTypes = roomTypeDAO.listAll();
    for (RoomType roomType : roomTypes) {
        List<Room> typeRooms = roomDAO.listByType(roomType);
        rooms.put(roomType, typeRooms);
    }
    // Support other currencies
    List<Currency> currencies = Arrays.asList(Currency.getInstance("EUR"));
    List<BillingDetails> existingBillingDetails = getExistingBillingDetails(courseStudent);
    pageRequestContext.getRequest().setAttribute("courseStudent", courseStudent);
    pageRequestContext.getRequest().setAttribute("rooms", rooms);
    pageRequestContext.getRequest().setAttribute("currencies", currencies);
    pageRequestContext.getRequest().setAttribute("existingBillingDetails", existingBillingDetails);
    pageRequestContext.setIncludeJSP("/templates/courses/studentdetailsdialog.jsp");
}
Also used : RoomDAO(fi.otavanopisto.pyramus.dao.accommodation.RoomDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) SmvcRuntimeException(fi.internetix.smvc.SmvcRuntimeException) TreeMap(java.util.TreeMap) BillingDetails(fi.otavanopisto.pyramus.domainmodel.base.BillingDetails) RoomType(fi.otavanopisto.pyramus.domainmodel.accommodation.RoomType) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Currency(java.util.Currency) RoomTypeDAO(fi.otavanopisto.pyramus.dao.accommodation.RoomTypeDAO) ArrayList(java.util.ArrayList) List(java.util.List) Room(fi.otavanopisto.pyramus.domainmodel.accommodation.Room)

Example 8 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO in project pyramus by otavanopisto.

the class ManageCourseAssessmentsViewController 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();
    CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
    CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
    Course course = courseDAO.findById(NumberUtils.createLong(pageRequestContext.getRequest().getParameter("course")));
    List<GradingScale> gradingScales = gradingScaleDAO.listUnarchived();
    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;
        }
    });
    Map<Long, CourseAssessment> courseAssessments = new HashMap<>();
    Map<Long, String> verbalAssessments = new HashMap<>();
    Iterator<CourseStudent> students = courseStudents.iterator();
    while (students.hasNext()) {
        CourseStudent courseStudent = students.next();
        CourseAssessment courseAssessment = courseAssessmentDAO.findLatestByCourseStudentAndArchived(courseStudent, Boolean.FALSE);
        if (courseAssessment != null) {
            courseAssessments.put(courseStudent.getId(), courseAssessment);
            // Shortened descriptions
            String description = courseAssessment.getVerbalAssessment();
            if (description != null) {
                description = StringEscapeUtils.unescapeHtml(description.replaceAll("\\<.*?>", ""));
                description = description.replaceAll("\\n", "");
                verbalAssessments.put(courseAssessment.getId(), description);
            }
        }
    }
    List<CourseParticipationType> courseParticipationTypes = participationTypeDAO.listUnarchived();
    Collections.sort(courseParticipationTypes, new Comparator<CourseParticipationType>() {

        public int compare(CourseParticipationType o1, CourseParticipationType o2) {
            return o1.getIndexColumn() == null ? -1 : o2.getIndexColumn() == null ? 1 : o1.getIndexColumn().compareTo(o2.getIndexColumn());
        }
    });
    pageRequestContext.getRequest().setAttribute("course", course);
    pageRequestContext.getRequest().setAttribute("courseStudents", courseStudents);
    pageRequestContext.getRequest().setAttribute("courseParticipationTypes", courseParticipationTypes);
    pageRequestContext.getRequest().setAttribute("assessments", courseAssessments);
    pageRequestContext.getRequest().setAttribute("verbalAssessments", verbalAssessments);
    pageRequestContext.getRequest().setAttribute("gradingScales", gradingScales);
    pageRequestContext.setIncludeJSP("/templates/courses/managecourseassessments.jsp");
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) CourseParticipationTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO) HashMap(java.util.HashMap) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)

Example 9 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO 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 10 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO in project pyramus by otavanopisto.

the class CoursesService method listCourseStudentsByCourse.

public CourseStudentEntity[] listCourseStudentsByCourse(@WebParam(name = "courseId") Long courseId) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    Course course = courseDAO.findById(courseId);
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    return (CourseStudentEntity[]) EntityFactoryVault.buildFromDomainObjects(courseStudentDAO.listByCourse(course));
}
Also used : CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Aggregations

CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)34 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)30 CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)16 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)16 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)14 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)14 CourseAssessmentDAO (fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO)9 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)9 CourseParticipationType (fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)9 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)8 Currency (java.util.Currency)8 HashMap (java.util.HashMap)8 CourseParticipationTypeDAO (fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO)7 Room (fi.otavanopisto.pyramus.domainmodel.accommodation.Room)7 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)7 Date (java.util.Date)7 SmvcRuntimeException (fi.internetix.smvc.SmvcRuntimeException)6 CourseOptionality (fi.otavanopisto.pyramus.domainmodel.base.CourseOptionality)6 BigDecimal (java.math.BigDecimal)6 Locale (java.util.Locale)6