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");
}
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));
}
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));
}
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);
}
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));
}
Aggregations