Example to create course offering in REM 4.2

Below is the example for creating a course offering via API in REM 4.2:

 

	    string url = "http://exampleserver/sites/rem";
            using (EnrollmentAddon rem = ObjectFactory.CreateAddonSite(url))
            {
                //Get course offering to enroll to
                int courseOfferingId = 2;
                ICourseOffering courseOffering = rem.CourseOfferings.Get(courseOfferingId);

                //Create enrollment context
                EnrollmentContext context = new EnrollmentContext(courseOffering, "REG-TEST #1");

                // Set value to necessary registration item fields (use field internal name as property key)
                EnrollmentExtraPropertiesSaver extraProperties = new EnrollmentExtraPropertiesSaver();
                extraProperties.Add("Email", "testemail@mail.com");
                extraProperties.Add("Company", "Elearningforce");

                ISaveEnrollmentsStrategy saveStrategy = ObjectFactory.CreateSaveEnrollmentStrategy(rem, context, new IEnrollmentSaver[] { extraProperties });
                string[] students = new string[] { "example\\user1", "example\\user2" };
                StudentRegistrationStatus status = context.EnrollmentTemplate.EnrollmentType.IsAutomatic() ? StudentRegistrationStatus.Enrolled : StudentRegistrationStatus.WaitForApproval;
                SaveEnrollmentsStrategyParameters parameters = new SaveEnrollmentsStrategyParameters();
                parameters.Status = status;
                parameters.Users = students.Select(userLogin => new UserToEnroll(rem, userLogin));
                saveStrategy.SaveEnrollments(parameters);
            }
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.