====== Learning Bundle ====== A Bundle is a collection of courses that are bundled together and priced as a single entity. Bundles can be free or paid. Bundle pricing overrides any individual course pricing. ===== Business Rules ===== * Bundle is a collection of courses * Bundle will have its own pricing, description and properties. * Courses in a bundle can be stand alone(published courses) or only available through a bundle(unpublished courses) * When a buyer buys a Bundle from the catalog, the buyer is enrolled into the Bundle as well as into each of it's constituent courses. * Courses available only through a Bundle, will not have their own pricing(i.e. individual pricing is ignored, and each of these components are treated as free). Only Bundle pricing is applicable. * Courses available only through a Bundle, will not have prerequisites i.e we should either gray it out or ignore prerequisites. Only Bundle rules are applicable. * When items that have their own time component(Live Events, In-person events) are part of a Bundle, Bundle time rules do not apply to them i.e in the Rules pop-up, 'Start Immediately' and 'Begin After.....' radio options are only available to them and the last option is grayed out. If the 'Begin after...' option has been set, and the items own time rule has kicked in and the item has expired, this item is no longer available and will follow the same rule as if it were standalone. * If the same course is available both standalone and within a Bundle, then in the standalone mode, it's pricing is still valid i.e. if someone chooses to buy the standalone course, they will pay the price indicated for the standalone course. When a standalone item is made available within a Bundle, and the buyer has already bought the standalone item, it will be treated exactly like a standalone item. Bundle rules cannot be set for that item, and that item will be grayed out in the Rules pop-up. When the buyer completes this standalone, score, completion status is reflected, and is applicable within the Bundle. * If an item was bought standalone, it will show up in the 'What I'm Working On' section, since Bundle rules do not apply * Canceling a Bundle also involves canceling from each of it's constituent courses. This does not apply to standalone courses that are part of the Bundle. Standalone courses, that are also a part of a Bundle, should be canceled using the standalone cancelation workflow. * Once a course has moved into the 'What I'm working On' section, it will be available in that section from then on, irrespective of if it is a part of another Bundle(i.e. ignore rules once a course moves into the 'What I'm...' section ===== Implementation ===== **Tables** |**bundles**| |id| |title| |description| |user_id| |display_in_catalog| |display_in_catalog_start_date| |display_in_catalog_end_date| |free| |price| |archived_at| |deleted_at| |auto_enroll| |created_at| |updated_at| |**bundle_items**| |id| |bundle_id| |bundleable_id| |bundleable_type| |start_immediatly (Boolean)| |start_after_item_id (Integer)| |start_at (Datetime)| |created_at| |updated_at| Modify enrollments table and add following columns |**enrollments**| |bundle_id| |is_available| **Main UI Components** - Product picker screen - Just like content picker (used to browser contents) we will need a product picker screen where user can browse for products and use it to insert products into the bundle. - Product preview screen - Will need a preview screen where user can preview the product. This will be used in the product picker. - Create/Edit bundle screen ==== Misc ==== Implementation approach 1) Steps to perform when a user enrolls to a Bundle First create an enrollment record for the bundle itself. Note that enrollment of type='Bundle' will never show up in "What i am workin on" section. Create records in the enrollments table for all the items(products) that are part of the bundle. For each enrollment record that will be created do following * Check IF the user has already enrolled to the product. If yes, then skip creating the enrollment record (User might have enrolled to the item via standalone or some other bundle). * ELSE user has not enrolled to the item before then create the enrollment record and set the bundle_id to the ID of the bundle which the user just enrolled into. During creation also check the below conditions. - If the bundle rule for current item is "Start Immediatly" then set the 'is_available' column of the enrollment to 'TRUE'. - If bundle rule is "After" then check if user has a completed enrollment for the product that is specified in "After", if yes then set the 'is_available' column to 'TRUE'. - If bundle rule is "Beginning Date", then check if current time with specificed date. If current time is >= the the "beginning date" then set the 'is_available' column to 'TRUE'. 2) Steps to perform when a user's enrollment reaches completion * Query for all the enrollments for the given user where bundle_id != NULL * For each enrollment get the bundle items where **bundle_items.start_after_item_id == "the item whose enrollment reached completion"** * Update the "is_available" column of the enrollments returned by above step to value "TRUE". (This will activate all the enrollments that are supposed to start after the current enrollment is complete). 3) Run a scheduled job (every few minutes) that queries for all the enrollments where bundle_id != NULL. * For each enrollment get the bundle items whose "start_at" is <= (less then or equal to) current time and update the 'is_available' column to 'TRUE'. ===== Additional Bundle Rules ===== ---Edit (May 16, 2014)--- Below is the current behavior: Use case 1 1) Instructor creates a Bundle (Bundle 1) with following items Course 1 - Starts Immediately Course 2 - Starts After 'Course 1' 2) Instructor creates another bundle (Bundle 2) with following items Course 2 - Starts Immediately Course 3 - Starts After 'Course 2' 3) Learner enrolls to 'Bundle 1'. After enrollment he would see a) 'Course 1' in 'What am i working' section b) 'Course 2' in available Soon section with a message that it will start after 'Course 1' and that 'Course 2' belongs to 'Bundle 1' 4) Now the Learner enrolls to 'Bundle 2'. After enrollment he would see a) 'Course 1' continues to appear in 'What am i working' section' b) 'Course 2' in available Soon section with a message that it will start after 'Course 1' and that 'Course 2' belongs to 'Bundle 1' (No change here) c) 'Course 3' in available soon section with message that it will start after 'Course 2' and that 'Course 3' belongs to 'Bundle 2'. Because of the way the bundle enrollment currently works, the Learner will not able to start the 'Course 2' immediately (which is the rule specified in Bundle 2). Basically if the user is already enrolled to a course as part of bundle then then enrolls to another bundle which has the same course, then the rules of the 1st bundle enrollment applies. Below is how the new behavior is expected to work. Use case 1 1) Instructor creates a Bundle (Bundle 1) with following items Course 1 - Starts Immediately Course 2 - Starts After 'Course 1' 2) Instructor creates another bundle (Bundle 2) with following items Course 2 - Starts Immediately Course 3 - Starts After 'Course 2' 3) Learner enrolls to 'Bundle 1'. After enrollment he would see a) 'Course 1' in 'What am i working' section b) 'Course 2' in available Soon section with a message that it will start after 'Course 1' and that 'Course 2' belongs to 'Bundle 1' 4) Now the Learner enrolls to 'Bundle 2'. After enrollment he would see a) 'Course 1' continues to appear in 'What am i working' section' b) 'Course 2' will appear in 'What am I working section" and it will get attached to 'Bundle 2'. c) 'Course 3' in available soon section with message that it will start after 'Course 2' and that 'Course 3' belongs to 'Bundle 2'. In other words, below is the additional logic that we will apply when user enrolls to a bundle Note: Assume that bundle that user is currently being enrolled into is called "NEW BUNDLE" 1) For each Item in the bundle do the following 2) Check if the item was already enrolled by the current user as part of a different bundle (Assume that this different bundle is called "OLD BUNDLE") 3) IF YES THEN IF the rule for the item in "NEW BUNDLE" is 'Starts immediately' THEN attach the existing enrollment of the item to the 'NEW BUNDLE'. ELSE IF the rule for the item in "NEW BUNDLE" is 'Start after Product' and the rule in 'OLD BUNDLE' is 'Beginning' THEN attach the existing enrollment of the item to 'NEW BUNDLE' ELSE The item remains attached with 'OLD BUNDLE'. 4) IF NO then do what we are currently doing (no change in behavior) In short if an item was already enrolled as part of different bundle and the user tries to enroll to another bundle having same item then we override the rules of existing enrollment by comparing the rule of existing enrollment and the new enrollment. The priority of over riding a rule is 1. Starts Immediately 2) Start After Product 3) Beginning