Use Case: A code can be assigned to a test and the learner is required to enter that code in order to take the test.
Initial Setup (one time)
- SETUP: Site-level - Add a custom property of ENABLE_TEST_WATCH=true in the Site Admin --> Customization tab.
- Create a data source in the CMS, give it the name test-watcher.js, and add JavaScript code to check if passcode validation is required and, if required, prompt the user to enter a passcode when the test starts and verify that the passcode is entered correctly (as defined in test's custom property).
Adding a Passcode in the Test
In the test, two custom properties need to be added.
PASS_CODE_VERIFY - true
PASS_CODE - <code value> [multiple comma-seperated valid codes can be assigned.]
Learner's Flow:
When a user clicks the Take Test button, a dialog box appears to prompt them to enter the passcode. The entered passcode is validated and the user can proceed after entering a valid passcode.
JS Code ( Add in data source - test-watcher.js)
<!-- PASS_CODE Verify start --> eb_TestWatcher = { verificationNeedChecked: false, verificationNeeded: false, verified: false, match: false, constructed: null, exp_passcode: null, pass_codes: null, questionShown : function(index, widg){ if(this.verificationNeedChecked && !this.verificationNeeded){return;} if(!this.verificationNeedChecked){ if(widg.viewController.test.customProperties && widg.viewController.test.customProperties.length > 0){ for(var i=0; i<widg.viewController.test.customProperties.length; i++){ if(widg.viewController.test.customProperties[i].name == 'PASS_CODE_VERIFY' && widg.viewController.test.customProperties[i].value == 'true'){ this.verificationNeeded = true; } if(widg.viewController.test.customProperties[i].name == 'PASS_CODE') { exp_passcode = widg.viewController.test.customProperties[i].value; pass_codes = exp_passcode.split(",") } } } this.verificationNeedChecked = true; } if(!this.verificationNeeded){return;} if(this.verified){return;} var num = widg.viewController.test.testQuestions.length; if(!this.constructed){ this.constructed = $(document.createElement('div')); this.constructed.html("<b>Please enter passcode</b><br/>Passcode: <br/> <input type='text' id='vr_passCode'/>"); } var me = this; this.constructed.dialog( { autoOpen: false, modal: true, buttons: { Verify: function() {me.verify();} } } ).dialog("open"); }, verify: function() { var me = this; if($("#vr_passCode").val() == ""){alert("Please enter passcode"); return;} for(var i=0; i<pass_codes.length; i++){ if($("#vr_passCode").val() == pass_codes[i]){ me.match = true; break; } } if(me.match == true){alert("Thanks, Code Verified, Please Proceed!"); me.verified = true; me.constructed.dialog("close"); } else{alert("Sorry, passcode is incorrect"); } } } |
Rating:
Related Pages
Group Management
Javascript
- Customization On Payment Page
- Validate IP Address while accessing the course
- UI Customization JavaScript Functions
- Verify Custom properties during Test Taking
- Verifying User Properties During Test
- JS Example
- example_custom_scripts
- Test Taking - Customization using callback mechanism
- Cms Calendar Example
Reports
Enrollment Management
- API - Update Event Subscription
- API - Create ExamTestInstance
- Update Program Member - via Program Session Id
- Update Program Member
- API - Self Enroll in Course Session
- Update Course Session Member
- API - Self Enroll in Program Session
- API - Self Enroll in Event
- API - Enroll Users in Course Session
- API - Enroll Users in Program Session
- API - Enroll Users in Event
- API - Enroll Users in Program
Other
Introduction
Report
- Get Sites Metadata
- Get Open Learning Items List
- API - Program Enrollment Summary
- API - Course Enrollment Summary
- Get Catalog Items List
- API - Course Session Members list
- API - Program Members List
- Event participants list
- Api - Test Attempts (Test Instances) List
- Test instance details list
- Api - Non Subscribed Event List
- Api - Subscribed Event List
- API - List All Report Schedules
- API - Get Latest Report Content For A Given Schedule ID
- API - Get Report Content For A Given Report ID
- API - List Reports For A Given Schedule
User Management
- API - User list
- API - Get user details
- Api - User Creation
- API - Create User (With Custom Properties)
- API - Update User
- API - Rename User
- API - Add user to group(s)
- API - Remove user from group(s)
- Merge User Accounts
- API - Activate User
- API - Deactivate User
- API - Change User's Origin Site
- Api - User Login (Creating User Session)
eCommerce
Quiz Delivery
- User Test Taking Experience
- Test Collections
- Poll (Short Survey)
- Allow Only Forward Navigation in quiz/survey
- Restrict Quiz Attempts
Test Flow Customization
Group Management
Javascript
- Customization On Payment Page
- Validate IP Address while accessing the course
- UI Customization JavaScript Functions
- Verify Custom properties during Test Taking
- Verifying User Properties During Test
- JS Example
- example_custom_scripts
- Test Taking - Customization using callback mechanism
- Cms Calendar Example
Reports
Enrollment Management
- API - Update Event Subscription
- API - Create ExamTestInstance
- Update Program Member - via Program Session Id
- Update Program Member
- API - Self Enroll in Course Session
- Update Course Session Member
- API - Self Enroll in Program Session
- API - Self Enroll in Event
- API - Enroll Users in Course Session
- API - Enroll Users in Program Session
- API - Enroll Users in Event
- API - Enroll Users in Program
Other
Introduction
Report
- Get Sites Metadata
- Get Open Learning Items List
- API - Program Enrollment Summary
- API - Course Enrollment Summary
- Get Catalog Items List
- API - Course Session Members list
- API - Program Members List
- Event participants list
- Api - Test Attempts (Test Instances) List
- Test instance details list
- Api - Non Subscribed Event List
- Api - Subscribed Event List
- API - List All Report Schedules
- API - Get Latest Report Content For A Given Schedule ID
- API - Get Report Content For A Given Report ID
- API - List Reports For A Given Schedule
User Management
- API - User list
- API - Get user details
- Api - User Creation
- API - Create User (With Custom Properties)
- API - Update User
- API - Rename User
- API - Add user to group(s)
- API - Remove user from group(s)
- Merge User Accounts
- API - Activate User
- API - Deactivate User
- API - Change User's Origin Site
- Api - User Login (Creating User Session)
eCommerce
Quiz Delivery
- User Test Taking Experience
- Test Collections
- Poll (Short Survey)
- Allow Only Forward Navigation in quiz/survey
- Restrict Quiz Attempts