Search in sources :

Example 96 with SchoolDataIdentifier

use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.

the class PyramusSchoolDataEntityFactory method createEntity.

public WorkspaceUser createEntity(CourseStudent courseStudent) {
    if (courseStudent == null) {
        return null;
    }
    SchoolDataIdentifier identifier = toIdentifier(identifierMapper.getWorkspaceStudentIdentifier(courseStudent.getId()));
    SchoolDataIdentifier userIdentifier = toIdentifier(identifierMapper.getStudentIdentifier(courseStudent.getStudentId()));
    SchoolDataIdentifier workspaceIdentifier = toIdentifier(identifierMapper.getWorkspaceIdentifier(courseStudent.getCourseId()));
    SchoolDataIdentifier roleIdentifier = toIdentifier(createCourseStudentRoleEntity().getIdentifier());
    return new PyramusWorkspaceUser(identifier, userIdentifier, workspaceIdentifier, roleIdentifier, courseStudent.getEnrolmentTime());
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)

Example 97 with SchoolDataIdentifier

use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.

the class PyramusSchoolDataEntityFactory method createEntity.

public Workspace createEntity(Course course, SchoolDataIdentifier educationTypeIdentifier, SchoolDataIdentifier educationSubtypeIdentifier, Map<String, List<String>> educationTypeCodeMap) {
    if (course == null) {
        return null;
    }
    OffsetDateTime modified = course.getLastModified();
    if (modified == null) {
        modified = course.getCreated();
    }
    boolean courseFeeApplicable = true;
    for (Map.Entry<String, List<String>> typeCodeEntry : educationTypeCodeMap.entrySet()) {
        String educationTypeCode = typeCodeEntry.getKey();
        for (String educationSubtypeCode : typeCodeEntry.getValue()) {
            if ((Objects.equals(educationTypeCode, "lukio") && Objects.equals(educationSubtypeCode, "pakollinen")) || (Objects.equals(educationTypeCode, "lukio") && Objects.equals(educationSubtypeCode, "valtakunnallinensyventava")) || (Objects.equals(educationTypeCode, "peruskoulu") && Objects.equals(educationSubtypeCode, "pakollinen")) || (Objects.equals(educationTypeCode, "peruskoulu") && Objects.equals(educationSubtypeCode, "valinnainen"))) {
                courseFeeApplicable = false;
                break;
            }
        }
    }
    String viewLink = String.format("https://%s/courses/viewcourse.page?course=%d", pyramusHost, course.getId());
    Set<SchoolDataIdentifier> curriculumIdentifiers = new HashSet<>();
    if (course.getCurriculumIds() != null) {
        for (Long curriculumId : course.getCurriculumIds()) {
            curriculumIdentifiers.add(identifierMapper.getCurriculumIdentifier(curriculumId));
        }
    }
    return new PyramusWorkspace(identifierMapper.getWorkspaceIdentifier(course.getId()), course.getName(), course.getNameExtension(), viewLink, identifierMapper.getWorkspaceTypeIdentifier(course.getTypeId()), identifierMapper.getWorkspaceCourseIdentifier(course.getSubjectId(), course.getCourseNumber()), course.getDescription(), identifierMapper.getSubjectIdentifier(course.getSubjectId()), educationTypeIdentifier, modified != null ? Date.from(modified.toInstant()) : null, course.getLength(), identifierMapper.getCourseLengthUnitIdentifier(course.getLengthUnitId()), course.getBeginDate(), course.getEndDate(), course.getArchived(), courseFeeApplicable, curriculumIdentifiers, course.getCourseNumber(), educationSubtypeIdentifier);
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) OffsetDateTime(java.time.OffsetDateTime) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashSet(java.util.HashSet)

Example 98 with SchoolDataIdentifier

use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.

the class PyramusSchoolDataEntityFactory method createEntity.

public TransferCredit createEntity(fi.otavanopisto.pyramus.rest.model.TransferCredit transferCredit) {
    SchoolDataIdentifier identifier = identifierMapper.getTransferCreditIdentifier(transferCredit.getId());
    SchoolDataIdentifier studentIdentifier = transferCredit.getStudentId() != null ? toIdentifier(identifierMapper.getStudentIdentifier(transferCredit.getStudentId())) : null;
    SchoolDataIdentifier gradeIdentifier = transferCredit.getGradeId() != null ? identifierMapper.getGradeIdentifier(transferCredit.getGradeId()) : null;
    SchoolDataIdentifier gradingScaleIdentifier = transferCredit.getGradingScaleId() != null ? identifierMapper.getGradingScaleIdentifier(transferCredit.getGradingScaleId()) : null;
    SchoolDataIdentifier assessorIdentifier = transferCredit.getAssessorId() != null ? toIdentifier(identifierMapper.getStaffIdentifier(transferCredit.getAssessorId())) : null;
    SchoolDataIdentifier lengthUnitIdentifier = transferCredit.getLengthUnitId() != null ? toIdentifier(identifierMapper.getCourseLengthUnitIdentifier(transferCredit.getLengthUnitId())) : null;
    SchoolDataIdentifier subjectIdentifier = transferCredit.getSubjectId() != null ? toIdentifier(identifierMapper.getSubjectIdentifier(transferCredit.getSubjectId())) : null;
    SchoolDataIdentifier schoolIdentifier = transferCredit.getSchoolId() != null ? identifierMapper.getSchoolIdentifier(transferCredit.getSchoolId()) : null;
    SchoolDataIdentifier curriculumIdentifier = transferCredit.getCurriculumId() != null ? identifierMapper.getCurriculumIdentifier(transferCredit.getCurriculumId()) : null;
    return new PyramusTransferCredit(identifier, studentIdentifier, transferCredit.getDate(), gradeIdentifier, gradingScaleIdentifier, transferCredit.getVerbalAssessment(), assessorIdentifier, transferCredit.getCourseName(), transferCredit.getCourseNumber(), transferCredit.getLength(), lengthUnitIdentifier, schoolIdentifier, subjectIdentifier, curriculumIdentifier, transferCredit.getOptionality() == CourseOptionality.OPTIONAL ? Optionality.OPTIONAL : Optionality.MANDATORY);
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)

Example 99 with SchoolDataIdentifier

use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.

the class GuiderRESTService method listTranscriptOfRecordsFiles.

@GET
@Path("/users/{IDENTIFIER}/files")
@RESTPermit(GuiderPermissions.GUIDER_LIST_TORFILES)
public Response listTranscriptOfRecordsFiles(@PathParam("IDENTIFIER") String identifierString) {
    SchoolDataIdentifier identifier = SchoolDataIdentifier.fromId(identifierString);
    UserEntity ue = userEntityController.findUserEntityByUserIdentifier(identifier);
    if (ue == null) {
        return Response.status(Status.NOT_FOUND).entity("User entity not found").build();
    }
    List<TranscriptOfRecordsFile> torFiles = torFileController.listFiles(ue);
    return Response.ok().entity(torFiles).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) TranscriptOfRecordsFile(fi.otavanopisto.muikku.plugins.transcriptofrecords.model.TranscriptOfRecordsFile) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 100 with SchoolDataIdentifier

use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.

the class GuiderRESTService method getWorkspaceAssessmentsStudyProgressAnalysis.

@GET
@Path("/workspaces/{WORKSPACEENTITYID}/studentactivity/{USERIDENTIFIER}")
@RESTPermit(GuiderPermissions.GUIDER_FIND_STUDENT_WORKSPACE_ACTIVITY)
public Response getWorkspaceAssessmentsStudyProgressAnalysis(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("USERIDENTIFIER") String userId) {
    SchoolDataIdentifier userIdentifier = SchoolDataIdentifier.fromId(userId);
    if (userIdentifier == null) {
        return Response.status(Status.BAD_REQUEST).entity("Invalid userIdentifier").build();
    }
    WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
    }
    WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceAndUserIdentifier(workspaceEntity, userIdentifier);
    if (workspaceUserEntity == null) {
        return Response.status(Status.NOT_FOUND).entity("WorkspaceUserEntity not found").build();
    }
    GuiderStudentWorkspaceActivity activity = guiderController.getStudentWorkspaceActivity(workspaceEntity, userIdentifier);
    if (activity == null) {
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(String.format("Failed to analyze assignments progress for student %s in workspace %d", userIdentifier, workspaceEntity.getId())).build();
    }
    WorkspaceAssessmentState assessmentState = assessmentRequestController.getWorkspaceAssessmentState(workspaceUserEntity);
    return Response.ok(toRestModel(activity, assessmentState)).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceAssessmentState(fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)130 Path (javax.ws.rs.Path)63 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)59 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)58 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)53 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)50 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)48 ArrayList (java.util.ArrayList)38 GET (javax.ws.rs.GET)36 User (fi.otavanopisto.muikku.schooldata.entity.User)30 HashMap (java.util.HashMap)19 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)13 SearchResult (fi.otavanopisto.muikku.search.SearchResult)13 WorkspaceUser (fi.otavanopisto.muikku.schooldata.entity.WorkspaceUser)12 Date (java.util.Date)11 POST (javax.ws.rs.POST)11 GradingScaleItem (fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem)10 WorkspaceAssessment (fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment)10 HashSet (java.util.HashSet)9 PUT (javax.ws.rs.PUT)9