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