Search in sources :

Example 1 with Grade

use of fi.otavanopisto.pyramus.rest.model.Grade in project muikku by otavanopisto.

the class PyramusGradingSchoolDataBridge method updateWorkspaceAssessment.

@Override
public WorkspaceAssessment updateWorkspaceAssessment(String identifier, String workspaceUserIdentifier, String workspaceUserSchoolDataSource, String workspaceIdentifier, String studentIdentifier, String assessingUserIdentifier, String assessingUserSchoolDataSource, String gradeIdentifier, String gradeSchoolDataSource, String gradingScaleIdentifier, String gradingScaleSchoolDataSource, String verbalAssessment, Date date) {
    Long courseStudentId = identifierMapper.getPyramusCourseStudentId(workspaceUserIdentifier);
    Long assessingUserId = identifierMapper.getPyramusStaffId(assessingUserIdentifier);
    Long courseId = identifierMapper.getPyramusCourseId(workspaceIdentifier);
    Long studentId = identifierMapper.getPyramusStudentId(studentIdentifier);
    Long id = identifierMapper.getPyramusCourseAssessmentId(identifier);
    Long gradeId = identifierMapper.getPyramusGradeId(gradeIdentifier);
    Long gradingScaleId = identifierMapper.getPyramusGradingScaleId(gradingScaleIdentifier);
    if (courseStudentId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus course student", workspaceUserIdentifier));
        return null;
    }
    if (assessingUserId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus staff member", assessingUserIdentifier));
        return null;
    }
    if (courseId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus course", workspaceIdentifier));
        return null;
    }
    if (studentId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus student", studentIdentifier));
        return null;
    }
    if (id == null) {
        logger.severe(String.format("Could not translate %s to Pyramus assessment", identifier));
        return null;
    }
    if (gradeId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus grade", gradeIdentifier));
        return null;
    }
    if (gradingScaleId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus grading scale", gradingScaleIdentifier));
        return null;
    }
    Grade grade = pyramusClient.get(String.format("/common/gradingScales/%d/grades/%d", gradingScaleId, gradeId), fi.otavanopisto.pyramus.rest.model.Grade.class);
    if (grade == null) {
        logger.severe(String.format("Could not update workspace assessment because grade %d could not be found from Pyramus", gradeId));
        return null;
    }
    CourseAssessment courseAssessment = new CourseAssessment(id, courseStudentId, gradeId, gradingScaleId, assessingUserId, fromDateToOffsetDateTime(date), verbalAssessment, grade.getPassingGrade());
    updateParticipationTypeByGrade(courseStudentId, courseId, grade);
    return entityFactory.createEntity(pyramusClient.put(String.format("/students/students/%d/courses/%d/assessments/%d", studentId, courseId, id), courseAssessment));
}
Also used : CompositeGrade(fi.otavanopisto.muikku.schooldata.entity.CompositeGrade) PyramusCompositeGrade(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade) Grade(fi.otavanopisto.pyramus.rest.model.Grade) CourseAssessment(fi.otavanopisto.pyramus.rest.model.CourseAssessment)

Example 2 with Grade

use of fi.otavanopisto.pyramus.rest.model.Grade in project muikku by otavanopisto.

the class PyramusGradingSchoolDataBridge method createWorkspaceAssessment.

@Override
public WorkspaceAssessment createWorkspaceAssessment(String workspaceUserIdentifier, String workspaceUserSchoolDataSource, String workspaceIdentifier, String studentIdentifier, String assessingUserIdentifier, String assessingUserSchoolDataSource, String gradeIdentifier, String gradeSchoolDataSource, String gradingScaleIdentifier, String gradingScaleSchoolDataSource, String verbalAssessment, Date date) {
    Long courseStudentId = identifierMapper.getPyramusCourseStudentId(workspaceUserIdentifier);
    Long assessingUserId = identifierMapper.getPyramusStaffId(assessingUserIdentifier);
    Long courseId = identifierMapper.getPyramusCourseId(workspaceIdentifier);
    Long studentId = identifierMapper.getPyramusStudentId(studentIdentifier);
    Long gradeId = identifierMapper.getPyramusGradeId(gradeIdentifier);
    Long gradingScaleId = identifierMapper.getPyramusGradingScaleId(gradingScaleIdentifier);
    if (courseStudentId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus course student", workspaceUserIdentifier));
        return null;
    }
    if (assessingUserId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus staff member", assessingUserIdentifier));
        return null;
    }
    if (courseId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus course", workspaceIdentifier));
        return null;
    }
    if (studentId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus student", studentIdentifier));
        return null;
    }
    if (gradeId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus grade", gradeIdentifier));
        return null;
    }
    if (gradingScaleId == null) {
        logger.severe(String.format("Could not translate %s to Pyramus grading scale", gradingScaleIdentifier));
        return null;
    }
    Grade grade = pyramusClient.get(String.format("/common/gradingScales/%d/grades/%d", gradingScaleId, gradeId), fi.otavanopisto.pyramus.rest.model.Grade.class);
    if (grade == null) {
        logger.severe(String.format("Could not create workspace assessment because grade %d could not be found from Pyramus", gradeId));
        return null;
    }
    CourseAssessment courseAssessment = new CourseAssessment(null, courseStudentId, gradeId, gradingScaleId, assessingUserId, fromDateToOffsetDateTime(date), verbalAssessment, grade.getPassingGrade());
    WorkspaceAssessment workspaceAssessment = entityFactory.createEntity(pyramusClient.post(String.format("/students/students/%d/courses/%d/assessments/", studentId, courseId), courseAssessment));
    updateParticipationTypeByGrade(courseStudentId, courseId, grade);
    return workspaceAssessment;
}
Also used : WorkspaceAssessment(fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment) CompositeGrade(fi.otavanopisto.muikku.schooldata.entity.CompositeGrade) PyramusCompositeGrade(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade) Grade(fi.otavanopisto.pyramus.rest.model.Grade) CourseAssessment(fi.otavanopisto.pyramus.rest.model.CourseAssessment)

Example 3 with Grade

use of fi.otavanopisto.pyramus.rest.model.Grade in project muikku by otavanopisto.

the class PyramusMocks method mockCommons.

public static void mockCommons() throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Subject subject = new Subject((long) 1, "tc_11", "Test course", (long) 1, false);
    String subjectJson = objectMapper.writeValueAsString(subject);
    stubFor(get(urlMatching("/1/common/subjects/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(subjectJson).withStatus(200)));
    Subject[] subjectArray = { subject };
    String subjectArrayJson = objectMapper.writeValueAsString(subjectArray);
    stubFor(get(urlEqualTo("/1/common/subjects")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(subjectArrayJson).withStatus(200)));
    EducationType educationType = new EducationType((long) 1, "testEduType", "ET", false);
    String educationTypeJson = objectMapper.writeValueAsString(educationType);
    stubFor(get(urlEqualTo("/1/common/educationTypes/1")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(educationTypeJson).withStatus(200)));
    EducationType[] educationTypeArray = { educationType };
    String educationTypeArrayJson = objectMapper.writeValueAsString(educationTypeArray);
    stubFor(get(urlEqualTo("/1/common/educationTypes")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(educationTypeArrayJson).withStatus(200)));
    EducationalTimeUnit educationalTimeUnit = new EducationalTimeUnit((long) 1, "test time unit", "h", (double) 1, false);
    String eduTimeUnitJson = objectMapper.writeValueAsString(educationalTimeUnit);
    stubFor(get(urlEqualTo("/1/common/educationalTimeUnits/1")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(eduTimeUnitJson).withStatus(200)));
    EducationalTimeUnit[] eduTimeUnitArray = { educationalTimeUnit };
    String eduTimeUnitArrayJson = objectMapper.writeValueAsString(eduTimeUnitArray);
    stubFor(get(urlEqualTo("/1/common/educationalTimeUnits")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(eduTimeUnitArrayJson).withStatus(200)));
    List<GradingScale> gradingScales = new ArrayList<GradingScale>();
    GradingScale gs = new GradingScale(1l, "Pass/Fail", "Passed or failed scale", false);
    gradingScales.add(gs);
    stubFor(get(urlEqualTo("/1/common/gradingScales")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(gradingScales)).withStatus(200)));
    stubFor(get(urlEqualTo(String.format("/1/common/gradingScales/%d", gs.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(gs)).withStatus(200)));
    Grade grade1 = new Grade(1l, "Excellent", "Excellent answer showing expertise in area of study", 1l, true, "0", null, false);
    Grade grade2 = new Grade(2l, "Failed", "Failed answer. Not proving any expertise in the matter.", 1l, false, "1", null, false);
    List<Grade> grades = new ArrayList<Grade>();
    grades.add(grade1);
    grades.add(grade2);
    stubFor(get(urlEqualTo(String.format("/1/common/gradingScales/%d/grades", gs.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(grades)).withStatus(200)));
    stubFor(get(urlEqualTo(String.format("/1/common/gradingScales/%d/grades/%d", gs.getId(), grade1.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(grade1)).withStatus(200)));
    stubFor(get(urlEqualTo(String.format("/1/common/gradingScales/%d/grades/%d", gs.getId(), grade2.getId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(grade2)).withStatus(200)));
    stubFor(get(urlEqualTo(String.format("/1/common/gradingScales/?filterArchived=true"))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(gradingScales)).withStatus(200)));
}
Also used : GradingScale(fi.otavanopisto.pyramus.rest.model.GradingScale) EducationType(fi.otavanopisto.pyramus.rest.model.EducationType) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ArrayList(java.util.ArrayList) Grade(fi.otavanopisto.pyramus.rest.model.Grade) Subject(fi.otavanopisto.pyramus.rest.model.Subject) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EducationalTimeUnit(fi.otavanopisto.pyramus.rest.model.EducationalTimeUnit)

Aggregations

Grade (fi.otavanopisto.pyramus.rest.model.Grade)3 PyramusCompositeGrade (fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade)2 CompositeGrade (fi.otavanopisto.muikku.schooldata.entity.CompositeGrade)2 CourseAssessment (fi.otavanopisto.pyramus.rest.model.CourseAssessment)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)1 WorkspaceAssessment (fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment)1 EducationType (fi.otavanopisto.pyramus.rest.model.EducationType)1 EducationalTimeUnit (fi.otavanopisto.pyramus.rest.model.EducationalTimeUnit)1 GradingScale (fi.otavanopisto.pyramus.rest.model.GradingScale)1 Subject (fi.otavanopisto.pyramus.rest.model.Subject)1 ArrayList (java.util.ArrayList)1