use of fi.otavanopisto.pyramus.rest.model.CourseStudent in project muikku by otavanopisto.
the class PyramusUpdater method updateActiveWorkspaceStudents.
/**
* Updates active course students from Pyramus
*
* @param courseId id of course in Pyramus
* @return count of updated course students
*/
public int updateActiveWorkspaceStudents(WorkspaceEntity workspaceEntity) {
int count = 0;
Long courseId = identifierMapper.getPyramusCourseId(workspaceEntity.getIdentifier());
CourseStudent[] courseStudents = pyramusClient.get().get("/courses/courses/" + courseId + "/students?filterArchived=false&activeStudents=true", CourseStudent[].class);
if (courseStudents != null) {
for (CourseStudent courseStudent : courseStudents) {
SchoolDataIdentifier workspaceUserIdentifier = toIdentifier(identifierMapper.getWorkspaceStudentIdentifier(courseStudent.getId()));
WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifierIncludeArchived(workspaceUserIdentifier);
if (courseStudent.getArchived()) {
if (workspaceUserEntity != null) {
fireCourseStudentRemoved(courseStudent.getId(), courseStudent.getStudentId(), courseStudent.getCourseId());
count++;
}
} else {
if (workspaceUserEntity == null) {
fireCourseStudentDiscovered(courseStudent, true);
count++;
} else {
fireCourseStudentUpdated(courseStudent, true);
}
}
}
}
return count;
}
use of fi.otavanopisto.pyramus.rest.model.CourseStudent in project muikku by otavanopisto.
the class PyramusGradingSchoolDataBridge method updateParticipationTypeByGrade.
private void updateParticipationTypeByGrade(Long courseStudentId, Long courseId, Grade grade) {
Long participationTypeId = courseParticipationTypeEvaluationMapper.getParticipationTypeId(grade);
if (participationTypeId != null) {
CourseStudent courseStudent = pyramusClient.get(String.format("/courses/courses/%d/students/%d", courseId, courseStudentId), CourseStudent.class);
if (courseStudent != null) {
if (!participationTypeId.equals(courseStudent.getParticipationTypeId())) {
courseStudent.setParticipationTypeId(participationTypeId);
pyramusClient.put(String.format("/courses/courses/%d/students/%d", courseId, courseStudentId), courseStudent);
}
} else {
logger.severe(String.format("Could not change course participation type because course student %d could not be found", courseStudentId));
}
}
}
use of fi.otavanopisto.pyramus.rest.model.CourseStudent in project muikku by otavanopisto.
the class PyramusWorkspaceSchoolDataBridge method createWorkspaceUser.
@Override
public WorkspaceUser createWorkspaceUser(Workspace workspace, User user, String roleSchoolDataSource, String roleIdentifier) {
Long courseId = identifierMapper.getPyramusCourseId(workspace.getIdentifier());
Long studentId = identifierMapper.getPyramusStudentId(user.getIdentifier());
CourseStudent courseStudent = new CourseStudent(null, courseId, studentId, OffsetDateTime.now(), Boolean.FALSE, null, null, Boolean.FALSE, CourseOptionality.OPTIONAL, null);
return Arrays.asList(entityFactory.createEntity(pyramusClient.post("/courses/courses/" + courseId + "/students", courseStudent))).get(0);
}
Aggregations