Search in sources :

Example 1 with GradingScale

use of fi.otavanopisto.pyramus.domainmodel.grading.GradingScale 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);
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO)

Example 2 with GradingScale

use of fi.otavanopisto.pyramus.domainmodel.grading.GradingScale 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");
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) StudentSubjectGradeDAO(fi.otavanopisto.pyramus.dao.students.StudentSubjectGradeDAO) StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)

Example 3 with GradingScale

use of fi.otavanopisto.pyramus.domainmodel.grading.GradingScale 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");
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO) JSONArrayExtractor(fi.otavanopisto.pyramus.util.JSONArrayExtractor)

Example 4 with GradingScale

use of fi.otavanopisto.pyramus.domainmodel.grading.GradingScale 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);
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO) GradeDAO(fi.otavanopisto.pyramus.dao.grading.GradeDAO)

Example 5 with GradingScale

use of fi.otavanopisto.pyramus.domainmodel.grading.GradingScale in project pyramus by otavanopisto.

the class EditGradingScaleJSONRequestController method process.

public void process(JSONRequestContext jsonRequestContext) {
    GradeDAO gradeDAO = DAOFactory.getInstance().getGradeDAO();
    GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
    Long gradingScaleId = NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("gradingScaleId"));
    String name = jsonRequestContext.getRequest().getParameter("name");
    String description = jsonRequestContext.getRequest().getParameter("description");
    GradingScale gradingScale = gradingScaleDAO.findById(gradingScaleId);
    gradingScaleDAO.update(gradingScale, name, description);
    Set<Long> existingGrades = new HashSet<>();
    int rowCount = NumberUtils.createInteger(jsonRequestContext.getRequest().getParameter("gradesTable.rowCount")).intValue();
    for (int i = 0; i < rowCount; i++) {
        String colPrefix = "gradesTable." + i;
        String gradeIdParam = jsonRequestContext.getRequest().getParameter(colPrefix + ".gradeId");
        Long gradeId = StringUtils.isBlank(gradeIdParam) ? null : NumberUtils.createLong(gradeIdParam);
        String gradeName = jsonRequestContext.getRequest().getParameter(colPrefix + ".name");
        String gradeQualification = jsonRequestContext.getRequest().getParameter(colPrefix + ".qualification");
        String gradeGPAParam = jsonRequestContext.getRequest().getParameter(colPrefix + ".GPA");
        String gradeDescription = jsonRequestContext.getRequest().getParameter(colPrefix + ".description");
        Boolean passingGrade = "1".equals(jsonRequestContext.getRequest().getParameter(colPrefix + ".passingGrade"));
        Double gradeGPA = StringUtils.isBlank(gradeGPAParam) ? null : NumberUtils.createDouble(gradeGPAParam);
        if (gradeId != null) {
            Grade grade = gradeDAO.findById(gradeId);
            gradeDAO.update(grade, gradeName, gradeDescription, passingGrade, gradeGPA, gradeQualification);
            existingGrades.add(grade.getId());
        } else {
            Grade grade = gradeDAO.create(gradingScale, gradeName, gradeDescription, passingGrade, gradeGPA, gradeQualification);
            existingGrades.add(grade.getId());
        }
    }
    List<Grade> grades = gradingScale.getGrades();
    for (int i = grades.size() - 1; i >= 0; i--) {
        Grade grade = grades.get(i);
        if (!existingGrades.contains(grade.getId()))
            gradingScale.removeGrade(grade);
    }
    jsonRequestContext.setRedirectURL(jsonRequestContext.getReferer(true));
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO) Grade(fi.otavanopisto.pyramus.domainmodel.grading.Grade) GradeDAO(fi.otavanopisto.pyramus.dao.grading.GradeDAO) HashSet(java.util.HashSet)

Aggregations

GradingScale (fi.otavanopisto.pyramus.domainmodel.grading.GradingScale)20 GradingScaleDAO (fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO)11 Grade (fi.otavanopisto.pyramus.domainmodel.grading.Grade)8 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)7 Path (javax.ws.rs.Path)7 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)4 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)4 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)4 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)3 CourseAssessmentDAO (fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO)3 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)3 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)3 TransferCredit (fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit)3 HashMap (java.util.HashMap)3 GET (javax.ws.rs.GET)3 EducationalTimeUnitDAO (fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO)2 GradeDAO (fi.otavanopisto.pyramus.dao.grading.GradeDAO)2 TransferCreditDAO (fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO)2 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)2 Tag (fi.otavanopisto.pyramus.domainmodel.base.Tag)2