Search in sources :

Example 1 with GradingScaleDAO

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

Example 2 with GradingScaleDAO

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

Example 3 with GradingScaleDAO

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");
}
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 4 with GradingScaleDAO

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

Example 5 with GradingScaleDAO

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

Aggregations

GradingScaleDAO (fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO)14 GradingScale (fi.otavanopisto.pyramus.domainmodel.grading.GradingScale)11 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)3 CourseAssessmentDAO (fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO)3 GradeDAO (fi.otavanopisto.pyramus.dao.grading.GradeDAO)3 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)3 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)3 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)3 Grade (fi.otavanopisto.pyramus.domainmodel.grading.Grade)3 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)3 JSONArrayExtractor (fi.otavanopisto.pyramus.util.JSONArrayExtractor)3 EducationalTimeUnitDAO (fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO)2 TransferCreditDAO (fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO)2 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)2 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)2 TransferCredit (fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit)2 StringAttributeComparator (fi.otavanopisto.pyramus.util.StringAttributeComparator)2 JSONArray (net.sf.json.JSONArray)2 JSONObject (net.sf.json.JSONObject)2 AcademicTermDAO (fi.otavanopisto.pyramus.dao.base.AcademicTermDAO)1