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