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