private void loadNeededCourses() throws AlreadyExistsException, VersionMismatchException, CircularRelationshipException, DependentObjectsExistException, UnsupportedActionException, DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { String code = "MATH101"; ContextInfo contextInfo; String math101Id = dataLoader.createCourse( FA2012_TERM, code.substring(0, 4), code, contextInfo = getContext("system")); MATH101 = courseService.getCourse(math101Id, contextInfo); // loadCourse(code, "2012FA", code.substring(0, 4), code, "Math 101", // "description 1", code + "-FORMAT1", // LuServiceConstants.COURSE_ACTIVITY_LECTURE_TYPE_KEY, // LuServiceConstants.COURSE_ACTIVITY_DISCUSSION_TYPE_KEY); code = "ENGL101"; String engl101Id = dataLoader.createCourse(FA2012_TERM, code.substring(0, 4), code, contextInfo); ENGL101 = courseService.getCourse(engl101Id, contextInfo); // courseLoader.loadCourse(code, "2012FA", code.substring(0, 4), code, "English // 101", "description 1", code + "-FORMAT1", // LuServiceConstants.COURSE_ACTIVITY_LECTURE_TYPE_KEY, // LuServiceConstants.COURSE_ACTIVITY_DISCUSSION_TYPE_KEY); code = "PHYS101"; String phys101Id = dataLoader.createCourse(FA2012_TERM, code.substring(0, 4), code, contextInfo); PHYS101 = courseService.getCourse(phys101Id, contextInfo); // courseLoader.loadCourse(code, "2012FA", code.substring(0, 4), code, "Physics // 101", "description 1", code + "-FORMAT1", // LuServiceConstants.COURSE_ACTIVITY_LECTURE_TYPE_KEY, // LuServiceConstants.COURSE_ACTIVITY_DISCUSSION_TYPE_KEY); }
public CourseOfferingInfo testCRUDCourseOffering() throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { // get course CourseInfo course; course = courseService.getCourse("COURSE1", ContextUtils.getContextInfo()); // create co from course List<String> optionKeys = new ArrayList<String>(); CourseOfferingInfo orig = new CourseOfferingInfo(); orig.setCourseId(course.getId()); orig.setTermId("testAtpId1"); orig.setTypeKey(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY); orig.setStateKey(LuiServiceConstants.LUI_CO_STATE_DRAFT_KEY); orig.setCourseOfferingTitle("my name"); orig.setWaitlistLevelTypeKey("waitlist key"); orig.setHasWaitlist(true); orig.setFinalExamType(FinalExam.STANDARD.toString()); orig.setIsEvaluated(true); orig.setIsFeeAtActivityOffering(false); orig.setFundingSource("funding source"); orig.setCourseOfferingCode("CODE"); orig.setCourseNumberSuffix(""); orig.setCourseOfferingTitle("Title"); orig.getStudentRegistrationGradingOptions() .add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_AUDIT); orig.getStudentRegistrationGradingOptions() .add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL); orig.setGradingOptionId(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER); CourseOfferingInfo info = courseOfferingService.createCourseOffering( orig.getCourseId(), orig.getTermId(), orig.getTypeKey(), orig, optionKeys, callContext); assertNotNull(info); assertNotNull(info.getId()); assertEquals(orig.getCourseId(), info.getCourseId()); assertEquals(orig.getTermId(), info.getTermId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getWaitlistLevelTypeKey(), info.getWaitlistLevelTypeKey()); assertEquals(orig.getHasWaitlist(), info.getHasWaitlist()); assertEquals(orig.getFinalExamType(), info.getFinalExamType()); assertEquals(orig.getIsFeeAtActivityOffering(), info.getIsFeeAtActivityOffering()); assertEquals(orig.getFundingSource(), info.getFundingSource()); assertEquals(course.getCode() + info.getCourseNumberSuffix(), info.getCourseOfferingCode()); assertEquals(orig.getCourseNumberSuffix(), info.getCourseNumberSuffix()); assertEquals(course.getSubjectArea(), info.getSubjectArea()); if (course.getDescr() != null) { assertEquals(course.getDescr().getPlain(), info.getDescr().getPlain()); assertEquals(course.getDescr().getFormatted(), info.getDescr().getFormatted()); } // assertEquals(2,info.getStudentRegistrationOptionIds().size()); // // assertTrue(info.getStudentRegistrationOptionIds().contains(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_AUDIT)); // // assertTrue(info.getStudentRegistrationOptionIds().contains(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL)); // // assertEquals(2,info.getGradingOptionIds().size()); // // assertTrue(info.getGradingOptionIds().contains(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER)); // // assertTrue(info.getGradingOptionIds().contains(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PERCENTAGE)); // TODO: test for these things // assertEquals(course.getUnitsContentOwnerOrgIds(), info.getUnitsContentOwnerOrgIds()); // assertEquals(course.getUnitsDeploymentOrgIds(), info.getUnitsDeploymentOrgIds()); // assertEquals(course.getGradingOptions(), info.getGradingOptionIds()); // assertEquals(course.getCreditOptionIds(), info.getCreditOptionIds()); // refetch co orig = info; info = courseOfferingService.getCourseOffering(orig.getId(), callContext); assertNotNull(info); assertEquals(orig.getId(), info.getId()); assertEquals(orig.getCourseId(), info.getCourseId()); assertEquals(orig.getTermId(), info.getTermId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); // update co orig = info; orig.setIsHonorsOffering(true); orig.setMaximumEnrollment(40); orig.setMinimumEnrollment(10); List<OfferingInstructorInfo> instructors = new ArrayList<OfferingInstructorInfo>(); // OfferingInstructorInfo instructor = new OfferingInstructorInfo(); // instructor.setPersonId("Pers-1"); // instructor.setPercentageEffort(Float.valueOf("60")); // instructor.setTypeKey(LprServiceConstants.INSTRUCTOR_MAIN_TYPE_KEY); // instructor.setStateKey(LprServiceConstants.ASSIGNED_STATE_KEY); // TODO: add this back in and test for it // instructors.add(instructor); orig.setInstructors(instructors); info = courseOfferingService.updateCourseOffering(orig.getId(), orig, callContext); assertNotNull(info); assertEquals(orig.getId(), info.getId()); assertEquals(orig.getCourseId(), info.getCourseId()); assertEquals(orig.getTermId(), info.getTermId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getIsHonorsOffering(), info.getIsHonorsOffering()); assertEquals(orig.getMaximumEnrollment(), info.getMaximumEnrollment()); assertEquals(orig.getMinimumEnrollment(), info.getMinimumEnrollment()); assertEquals(orig.getInstructors().size(), info.getInstructors().size()); // OfferingInstructorInfo origInst1 = orig.getInstructors().get(0); // OfferingInstructorInfo infoInst1 = info.getInstructors().get(0); // assertEquals(origInst1.getPersonId(), infoInst1.getPersonId()); // assertEquals(origInst1.getPercentageEffort(), infoInst1.getPercentageEffort()); // assertEquals(origInst1.getTypeKey(), infoInst1.getTypeKey()); // assertEquals(origInst1.getStateKey(), infoInst1.getStateKey()); return info; }