Search in sources :

Example 6 with CourseStudent

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;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) UserSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) CourseStudent(fi.otavanopisto.pyramus.rest.model.CourseStudent)

Example 7 with CourseStudent

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));
        }
    }
}
Also used : CourseStudent(fi.otavanopisto.pyramus.rest.model.CourseStudent)

Example 8 with CourseStudent

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);
}
Also used : CourseStudent(fi.otavanopisto.pyramus.rest.model.CourseStudent)

Aggregations

CourseStudent (fi.otavanopisto.pyramus.rest.model.CourseStudent)8 RoleSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier)3 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)3 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)3 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)2 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)2 WebhookCourseStaffMemberCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookCourseStaffMemberCreatePayload)2 WebhookCourseStudentCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookCourseStudentCreatePayload)2 OffsetDateTime (java.time.OffsetDateTime)2 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)1 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)1 CourseAssessment (fi.otavanopisto.pyramus.rest.model.CourseAssessment)1 CourseParticipationType (fi.otavanopisto.pyramus.rest.model.CourseParticipationType)1 CourseStaffMemberRole (fi.otavanopisto.pyramus.rest.model.CourseStaffMemberRole)1 Email (fi.otavanopisto.pyramus.rest.model.Email)1 Person (fi.otavanopisto.pyramus.rest.model.Person)1 StaffMember (fi.otavanopisto.pyramus.rest.model.StaffMember)1 Student (fi.otavanopisto.pyramus.rest.model.Student)1