use of fi.otavanopisto.muikku.plugins.transcriptofrecords.rest.Mandatority in project muikku by otavanopisto.
the class VopsLister method processTransferCredits.
private VopsRESTModel.VopsEntry processTransferCredits(Subject subject, int courseNumber) {
for (TransferCredit transferCredit : transferCredits) {
boolean subjectsMatch = Objects.equals(transferCredit.getSubjectIdentifier(), new SchoolDataIdentifier(subject.getIdentifier(), subject.getSchoolDataSource()));
boolean courseNumbersMatch = Objects.equals(transferCredit.getCourseNumber(), courseNumber);
if (subjectsMatch && courseNumbersMatch) {
String grade = "";
GradingScaleItem gradingScaleItem = null;
Mandatority mandatority = Mandatority.MANDATORY;
if (transferCredit.getOptionality() == Optionality.OPTIONAL) {
mandatority = Mandatority.UNSPECIFIED_OPTIONAL;
}
if (transferCredit.getGradeIdentifier() != null && transferCredit.getGradingScaleIdentifier() != null) {
gradingScaleItem = findGradingScaleItemCached(transferCredit.getGradingScaleIdentifier(), transferCredit.getGradeIdentifier());
String gradeName = gradingScaleItem.getName();
if (!StringUtils.isBlank(gradeName)) {
if (gradeName.length() > 2)
grade = gradeName.substring(0, 2);
else
grade = gradeName;
}
}
numCourses++;
if (mandatority == Mandatority.MANDATORY) {
numMandatoryCourses++;
}
return new VopsRESTModel.VopsItem(courseNumber, CourseCompletionState.ASSESSED, (String) null, mandatority, grade, false, transferCredit.getCourseName(), "");
}
}
return null;
}
use of fi.otavanopisto.muikku.plugins.transcriptofrecords.rest.Mandatority in project muikku by otavanopisto.
the class VopsLister method processCourse.
private VopsRESTModel.VopsEntry processCourse(Subject subject, int courseNumber) {
VopsRESTModel.VopsEntry transferCreditEntry = processTransferCredits(subject, courseNumber);
if (transferCreditEntry != null) {
return transferCreditEntry;
}
List<VopsWorkspace> workspaces = vopsController.listWorkspaceIdentifiersBySubjectIdentifierAndCourseNumber(subject.getSchoolDataSource(), subject.getIdentifier(), courseNumber);
List<WorkspaceAssessment> workspaceAssessments = new ArrayList<>();
if (curriculumIdentifier != null) {
workspaces.removeIf((VopsWorkspace workspace) -> !workspace.getCurriculumIdentifiers().contains(curriculumIdentifier));
}
if (!workspaces.isEmpty()) {
SchoolDataIdentifier educationSubtypeIdentifier = null;
boolean workspaceUserExists = false;
String name = "";
String description = "";
boolean canSignUp = false;
for (VopsWorkspace workspace : workspaces) {
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityById(workspace.getWorkspaceIdentifier());
WorkspaceUserEntity workspaceUser = workspaceUserEntityController.findWorkspaceUserByWorkspaceEntityAndUserIdentifier(workspaceEntity, studentIdentifier);
WorkspaceAssessment workspaceAssesment = studentAssessments.get(workspace.getWorkspaceIdentifier());
List<UserGroupEntity> userGroupEntities = userGroupEntityController.listUserGroupsByUserIdentifier(studentIdentifier);
Permission permission = permissionController.findByName(MuikkuPermissions.WORKSPACE_SIGNUP);
for (UserGroupEntity userGroupEntity : userGroupEntities) {
if (permissionController.hasWorkspaceGroupPermission(workspaceEntity, userGroupEntity, permission)) {
canSignUp = true;
break;
}
}
if (workspaceAssesment != null) {
workspaceAssessments.add(workspaceAssesment);
}
if (workspaceUser != null) {
workspaceUserExists = true;
}
}
for (VopsWorkspace workspace : workspaces) {
name = workspace.getName();
if (name != null) {
break;
}
}
for (VopsWorkspace workspace : workspaces) {
description = workspace.getDescription();
if (description != null) {
break;
}
}
for (VopsWorkspace workspace : workspaces) {
educationSubtypeIdentifier = workspace.getEducationSubtypeIdentifier();
if (educationSubtypeIdentifier != null) {
break;
}
}
Mandatority mandatority = educationTypeMapping.getMandatority(educationSubtypeIdentifier);
CourseCompletionState state = CourseCompletionState.NOT_ENROLLED;
String grade = null;
if (workspaceUserExists) {
state = CourseCompletionState.ENROLLED;
}
for (WorkspaceAssessment workspaceAssessment : workspaceAssessments) {
if (!Boolean.TRUE.equals(workspaceAssessment.getPassing())) {
state = CourseCompletionState.FAILED;
break;
}
}
for (WorkspaceAssessment workspaceAssessment : workspaceAssessments) {
if (Boolean.TRUE.equals(workspaceAssessment.getPassing())) {
state = CourseCompletionState.ASSESSED;
numCourses++;
if (mandatority == Mandatority.MANDATORY) {
numMandatoryCourses++;
}
SchoolDataIdentifier gradingScaleIdentifier = workspaceAssessment.getGradingScaleIdentifier();
if (gradingScaleIdentifier == null) {
break;
}
SchoolDataIdentifier gradeIdentifier = workspaceAssessment.getGradeIdentifier();
if (gradeIdentifier == null) {
break;
}
GradingScaleItem gradingScaleItem = findGradingScaleItemCached(gradingScaleIdentifier, gradeIdentifier);
String gradeName = gradingScaleItem.getName();
if (!StringUtils.isBlank(gradeName)) {
if (gradeName.length() > 2)
grade = gradeName.substring(0, 2);
else
grade = gradeName;
}
break;
}
}
if (state == CourseCompletionState.NOT_ENROLLED && !canSignUp) {
return new VopsRESTModel.VopsPlaceholder();
}
StudiesViewCourseChoice courseChoice = studiesViewCourseChoiceController.find(new SchoolDataIdentifier(subject.getIdentifier(), subject.getSchoolDataSource()).toId(), courseNumber, studentIdentifierString);
if (state == CourseCompletionState.NOT_ENROLLED && courseChoice != null) {
state = CourseCompletionState.PLANNED;
}
return new VopsRESTModel.VopsItem(courseNumber, state, educationSubtypeIdentifier != null ? educationSubtypeIdentifier.toId() : null, mandatority, grade, workspaceUserExists, clean(name), clean(description));
}
return new VopsRESTModel.VopsPlaceholder();
}
Aggregations