use of fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO in project pyramus by otavanopisto.
the class GradingService method createGrade.
public GradeEntity createGrade(@WebParam(name = "gradingScaleId") Long gradingScaleId, @WebParam(name = "name") String name, @WebParam(name = "description") String description, @WebParam(name = "passingGrade") Boolean passingGrade, @WebParam(name = "GPA") Double GPA, @WebParam(name = "qualification") String qualification) {
GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
GradeDAO gradeDAO = DAOFactory.getInstance().getGradeDAO();
Grade grade = gradeDAO.create(gradingScaleDAO.findById(gradingScaleId), name, description, passingGrade, GPA, qualification);
validateEntity(grade);
return EntityFactoryVault.buildFromDomainObject(grade);
}
use of fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO in project pyramus by otavanopisto.
the class GradingService method updateGradingScale.
public void updateGradingScale(@WebParam(name = "gradingScaleId") Long gradingScaleId, @WebParam(name = "name") String name, @WebParam(name = "description") String description) {
GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
GradingScale gradingScale = gradingScaleDAO.findById(gradingScaleId);
gradingScaleDAO.update(gradingScale, name, description);
validateEntity(gradingScale);
}
use of fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO in project pyramus by otavanopisto.
the class EditStudentSubjectGradeDialogViewController method process.
public void process(PageRequestContext requestContext) {
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
StudentSubjectGradeDAO studentSubjectGradeDAO = DAOFactory.getInstance().getStudentSubjectGradeDAO();
GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
Long studentId = requestContext.getLong("studentId");
Long subjectId = requestContext.getLong("subjectId");
if (studentId == null || subjectId == null) {
logger.log(Level.WARNING, String.format("Unable to load view due to missing studentId (%d) or subjectId (%d).", studentId, subjectId));
try {
requestContext.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
} catch (Exception e) {
logger.log(Level.SEVERE, "Couldn't send response", e);
}
return;
}
Student student = studentDAO.findById(studentId);
Subject subject = subjectDAO.findById(subjectId);
StudentSubjectGrade studentSubjectGrade = studentSubjectGradeDAO.findBy(student, subject);
List<GradingScale> gradingScales = gradingScaleDAO.listUnarchived();
List<StaffMember> studyApprovers = staffMemberDAO.listByProperty(StaffMemberProperties.STUDY_APPROVER.getKey(), "1");
StaffMember selectedStudyApprover = studentSubjectGrade != null && studentSubjectGrade.getGradeApprover() != null ? studentSubjectGrade.getGradeApprover() : null;
if (selectedStudyApprover != null) {
Long selectedStudyApproverId = selectedStudyApprover.getId();
boolean isSelectedInList = studyApprovers.stream().map(StaffMember::getId).anyMatch(selectedStudyApproverId::equals);
if (!isSelectedInList) {
studyApprovers.add(selectedStudyApprover);
}
}
studyApprovers.sort(Comparator.comparing(StaffMember::getLastName).thenComparing(StaffMember::getFirstName));
requestContext.getRequest().setAttribute("student", student);
requestContext.getRequest().setAttribute("subject", subject);
requestContext.getRequest().setAttribute("studentSubjectGrade", studentSubjectGrade);
requestContext.getRequest().setAttribute("gradingScales", gradingScales);
requestContext.getRequest().setAttribute("studyApprovers", studyApprovers);
requestContext.setIncludeJSP("/templates/students/editstudentsubjectgradedialog.jsp");
}
use of fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO in project pyramus by otavanopisto.
the class EditGradingScaleViewController method process.
/**
* Processes the page request by including the corresponding JSP page to the response.
*
* In order for the JSP page to build the view, gradingScale object is loaded in to "gradingScale" attribute
*
* @param pageRequestContext Page request context
*/
public void process(PageRequestContext pageRequestContext) {
GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
Long gradingScaleId = NumberUtils.createLong(pageRequestContext.getRequest().getParameter("gradingScaleId"));
GradingScale gradingScale = gradingScaleDAO.findById(gradingScaleId);
pageRequestContext.getRequest().setAttribute("gradingScale", gradingScale);
String jsonGrades = new JSONArrayExtractor("passingGrade", "name", "qualification", "GPA", "description", "id").extractString(gradingScale.getGrades());
this.setJsDataVariable(pageRequestContext, "grades", jsonGrades);
pageRequestContext.setIncludeJSP("/templates/settings/editgradingscale.jsp");
}
use of fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO in project pyramus by otavanopisto.
the class CreateGradingScaleJSONRequestController method process.
/**
* Processes the request to create a new grading scale.
*
* @param jsonRequestContext The JSON request context
*/
public void process(JSONRequestContext jsonRequestContext) {
GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
GradeDAO gradeDAO = DAOFactory.getInstance().getGradeDAO();
String name = jsonRequestContext.getRequest().getParameter("name");
String description = jsonRequestContext.getRequest().getParameter("description");
GradingScale gradingScale = gradingScaleDAO.create(name, description);
int rowCount = NumberUtils.createInteger(jsonRequestContext.getRequest().getParameter("gradesTable.rowCount")).intValue();
for (int i = 0; i < rowCount; i++) {
String colPrefix = "gradesTable." + i;
String gradeName = jsonRequestContext.getRequest().getParameter(colPrefix + ".name");
String gradeQualification = jsonRequestContext.getRequest().getParameter(colPrefix + ".qualification");
Double gradeGPA = NumberUtils.createDouble(jsonRequestContext.getRequest().getParameter(colPrefix + ".GPA"));
String gradeDescription = jsonRequestContext.getRequest().getParameter(colPrefix + ".description");
Boolean passingGrade = "1".equals(jsonRequestContext.getRequest().getParameter(colPrefix + ".passingGrade"));
gradeDAO.create(gradingScale, gradeName, gradeDescription, passingGrade, gradeGPA, gradeQualification);
}
String redirectURL = jsonRequestContext.getRequest().getContextPath() + "/settings/editgradingscale.page?gradingScaleId=" + gradingScale.getId();
String refererAnchor = jsonRequestContext.getRefererAnchor();
if (!StringUtils.isBlank(refererAnchor))
redirectURL += "#" + refererAnchor;
jsonRequestContext.setRedirectURL(redirectURL);
}
Aggregations