### Install using Setuptools Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Install the package for the current user or for all users using Setuptools. ```sh python setup.py install --user ``` ```sh sudo python setup.py install ``` -------------------------------- ### Installation Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Instructions on how to install the SCORM Cloud Python SDK v2 using pip. ```APIDOC ## Installation Install the SDK via pip: ```bash pip install rustici_software_cloud_v2 ``` Or from GitHub: ```bash pip install git+https://github.com/RusticiSoftware/scormcloud-api-v2-client-python.git ``` ``` -------------------------------- ### Install SCORM Cloud SDK Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Commands to install the SDK via pip from PyPI or directly from the GitHub repository. ```bash pip install rustici_software_cloud_v2 ``` ```bash pip install git+https://github.com/RusticiSoftware/scormcloud-api-v2-client-python.git ``` -------------------------------- ### Install rustici_software_cloud_v2 from GitHub Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Install the SCORM Cloud API v2 Python client directly from its GitHub repository. ```sh pip install git+https://github.com/RusticiSoftware/scormcloud-api-v2-client-python.git ``` -------------------------------- ### Configuration and Authentication Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Guides on configuring the SDK with API credentials and setting up authentication using basic HTTP authorization or OAuth 2.0 tokens. ```APIDOC ## Configuration and Authentication Configure the SDK with your SCORM Cloud API credentials and set up authentication for making API calls. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta # Configure HTTP basic authorization config = scorm_cloud.Configuration() config.username = "YOUR_APP_ID" config.password = "YOUR_SECRET_KEY" # Set as default configuration for all API instances scorm_cloud.Configuration().set_default(config) # Optional: Configure OAuth token for scoped access app_management_api = scorm_cloud.ApplicationManagementApi() # Create OAuth token with specific permissions expiry = (datetime.utcnow() + timedelta(minutes=30)).isoformat() + 'Z' permissions = scorm_cloud.PermissionsSchema(["write:course", "read:course", "read:registration"]) token_request = scorm_cloud.TokenRequestSchema(permissions, expiry) token_result = app_management_api.create_token(token_request) # Apply OAuth token to configuration config.access_token = token_result.result scorm_cloud.Configuration().set_default(config) ``` ``` -------------------------------- ### Install rustici_software_cloud_v2 via pip Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Use this command to install the SCORM Cloud API v2 Python client from PyPI. ```sh pip install rustici_software_cloud_v2 ``` -------------------------------- ### Get Course Configuration Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve the effective configuration settings for a specific course. Use `include_metadata=True` to also fetch metadata. ```python config = course_api.get_course_configuration( course_id="MY_COURSE_ID", include_metadata=True ) ``` -------------------------------- ### Get All Registrations Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Fetches a list of all learner registrations across all courses in the SCORM Cloud account. ```python registration_list = sc.get_all_registrations() # Show details of the registrations print(OUTPUT_BORDER) print("Registration List: ") for registration in registration_list: print(registration) ``` -------------------------------- ### RegistrationApi - Get Registrations with Pagination Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Demonstrates how to retrieve all registrations, handling pagination by repeatedly calling the API until all records are fetched. ```APIDOC ## RegistrationApi - Get Registrations with Pagination ### Description Retrieves registrations and handles pagination by iterating through subsequent pages using the `more` parameter. ### Method GET ### Endpoint `/registrations` (Implicitly used by `get_registrations`) ### Parameters #### Query Parameters - **more** (string) - Optional - A token to retrieve the next page of results. ### Request Example ```python # Assuming registration_api is an instance of RegistrationApi response = registration_api.get_registrations() all_registrations = response.registrations while response.more is not None: response = registration_api.get_registrations(more=response.more) all_registrations += response.registrations ``` ### Response #### Success Response (200) - **registrations** (list) - A list of registration objects. - **more** (string) - A token for the next page of results, or None if it's the last page. #### Response Example ```json { "registrations": [ { "id": "REG_ID_1", "course": {"title": "Course Title 1"}, "learner": {"id": "LEARNER_ID_1"}, "registration_completion": "complete", "score": {"scaled": 0.95} } ], "more": "NEXT_PAGE_TOKEN" } ``` ``` -------------------------------- ### Get All Courses Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Fetches a list of all courses currently available in the SCORM Cloud account. ```python course_list = sc.get_all_courses() # Show details of the courses print(OUTPUT_BORDER) print("Course List: ") for course in course_list: print(course) ``` -------------------------------- ### Test Registration Postback Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Send a test postback request to a configured URL to verify the webhook setup. ```python postback = scorm_cloud.PostBackSchema( url="https://myserver.com/webhooks/test", auth_type="httpbasic", user_name="test_user", password="test_password" ) registration_api.test_registration_postback(post_back=postback) ``` -------------------------------- ### CourseApi - List and Manage Courses Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Provides examples for retrieving a list of courses with options for filtering, pagination, and including registration counts or course metadata. ```APIDOC ## CourseApi - List and Manage Courses Retrieve courses with filtering, pagination, and course management operations. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta course_api = scorm_cloud.CourseApi() # Get all courses with pagination response = course_api.get_courses( include_registration_count=True, include_course_metadata=True ) all_courses = response.courses while response.more is not None: response = course_api.get_courses(more=response.more) all_courses += response.courses for course in all_courses: print(f"ID: {course.id}, Title: {course.title}, Registrations: {course.registration_count}") ``` ``` -------------------------------- ### Import the SCORM Cloud API client Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Import the SCORM Cloud API v2 Python client package after installation. ```python import rustici_software_cloud_v2 ``` -------------------------------- ### GET /courses Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve a list of courses filtered by tags and date. ```APIDOC ## GET /courses ### Description Retrieve a list of courses filtered by specific tags and a time range. ### Method GET ### Endpoint /courses ### Parameters #### Query Parameters - **tags** (array) - Optional - List of tags to filter courses by. - **since** (datetime) - Optional - Filter courses updated since this timestamp. ``` -------------------------------- ### RegistrationApi - Get Launch History Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieves the complete launch history for a specific registration, including detailed log entries if requested. ```APIDOC ## RegistrationApi - Get Launch History ### Description Retrieve the complete launch history for a registration to analyze learning sessions. ### Method GET ### Endpoint `/registrations/{registrationId}/launchhistory` ### Parameters #### Path Parameters - **registrationId** (string) - Required - The ID of the registration. #### Query Parameters - **includeHistoryLog** (boolean) - Optional - If true, includes detailed log entries for each launch. ### Request Example ```python # Assuming registration_api is an instance of RegistrationApi history = registration_api.get_registration_launch_history( registration_id="REG_001", include_history_log=True # Include detailed log entries ) ``` ### Response #### Success Response (200) - **launchHistory** (list) - A list of launch history objects. #### Response Example ```json { "launchHistory": [ { "id": "LAUNCH_ID_1", "launchTime": "2023-10-27T10:00:00Z", "exitTime": "2023-10-27T11:30:00Z", "completionStatus": "completed", "successStatus": "passed", "score": {"scaled": 0.85} } ] } ``` ``` -------------------------------- ### GET /registrations/{registration_id}/progress Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve detailed progress information for a registration. ```APIDOC ## GET /registrations/{registration_id}/progress ### Description Retrieve detailed progress information for a registration including completion status and scores. ### Method GET ### Endpoint /registrations/{registration_id}/progress ### Parameters #### Path Parameters - **registration_id** (string) - Required - The unique identifier of the registration. #### Query Parameters - **include_child_results** (boolean) - Optional - Include SCO-level results. - **include_interactions_and_objectives** (boolean) - Optional - Include interaction and objective data. - **include_runtime** (boolean) - Optional - Include runtime data. ``` -------------------------------- ### Get Registration Progress Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Retrieves the current progress and status of a learner's registration for a course. For real-time updates, consider implementing SCORM Cloud's postback mechanism. ```python registration_api = scorm_cloud.RegistrationApi() progress = registration_api.get_registration_progress(registration_id) return progress ``` -------------------------------- ### Get Registration Progress Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Retrieves the completion status and score for a specific learner's registration. Requires REGISTRATION_ID. ```python registration_progress = sc.get_result_for_registration(REGISTRATION_ID) ``` -------------------------------- ### Get Detailed Course Information Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Fetch comprehensive details for a specific course, including counts and metadata. Use the `course_id` to identify the course. ```python course = course_api.get_course( course_id="MY_COURSE_ID", include_registration_count=True, include_course_metadata=True ) ``` -------------------------------- ### Get Registration Progress Details Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve detailed progress and status for a specific registration. Options include including child SCO results, interactions, and runtime data. ```python import rustici_software_cloud_v2 as scorm_cloud registration_api = scorm_cloud.RegistrationApi() # Get registration progress with full details progress = registration_api.get_registration_progress( registration_id="REG_001", include_child_results=True, # Include SCO-level results include_interactions_and_objectives=True, include_runtime=True ) print(f"Course: {progress.course.title}") print(f"Learner: {progress.learner.first_name} {progress.learner.last_name}") print(f"Completion: {progress.registration_completion}" ) # COMPLETED, INCOMPLETE, UNKNOWN print(f"Success: {progress.registration_success}") # PASSED, FAILED, UNKNOWN print(f"Score: {progress.score.scaled}") # 0.0 to 1.0 print(f"Total Time: {progress.total_seconds_tracked} seconds") # Access activity-level results if progress.activity_details: for activity in progress.activity_details.children: print(f" Activity: {activity.title}") print(f" Completion: {activity.activity_completion}") ``` -------------------------------- ### Get Course xAPI Statements Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve xAPI statements generated by course launches. Statements can be filtered by `learner_id`, `since`, and `until` dates. The `more` parameter is used for pagination. ```python statements = course_api.get_course_statements( course_id="MY_COURSE_ID", learner_id="LEARNER_001", # Optional filter since=datetime.utcnow() - timedelta(days=7), until=datetime.utcnow() ) for statement in statements.statements: print(f"Actor: {statement.get('actor', {}).get('name')}") print(f"Verb: {statement.get('verb', {}).get('display')}") print(f"Object: {statement.get('object', {}).get('definition', {}).get('name')}") ``` ```python # Paginate through all statements all_statements = statements.statements while statements.more: statements = course_api.get_course_statements( course_id="MY_COURSE_ID", more=statements.more ) all_statements.extend(statements.statements) ``` -------------------------------- ### Filter Courses by Tags Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve courses that have specific tags applied. Filters can also include a 'since' date to get recently modified courses. ```python tagged_courses = course_api.get_courses( tags=["compliance", "onboarding"], since=datetime.utcnow() - timedelta(days=30) ) ``` -------------------------------- ### Build Course Preview Launch Link Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Generate a temporary URL to preview course content without creating a formal registration. Configure redirect URL, expiry, and tracking. ```python import rustici_software_cloud_v2 as scorm_cloud course_api = scorm_cloud.CourseApi() # Create preview launch link request launch_request = scorm_cloud.PreviewLaunchLinkRequestSchema( redirect_on_exit_url="https://mysite.com/preview-complete", expiry=60, # Link expires in 60 seconds tracking=False # Don't track interactions in preview ) # Get preview launch link launch_link = course_api.build_course_preview_launch_link( course_id="MY_COURSE_ID", launch_link_request=launch_request ) print(f"Preview URL: {launch_link.launch_link}") ``` -------------------------------- ### Download Course as ZIP Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Download the entire course content as a ZIP archive. ```python course_zip = course_api.get_course_zip(course_id="MY_COURSE_ID") with open("course_backup.zip", "wb") as f: f.write(course_zip) ``` -------------------------------- ### Upload and Import Local Course Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Upload a local ZIP package and poll the import job status until completion. ```python import rustici_software_cloud_v2 as scorm_cloud import time course_api = scorm_cloud.CourseApi() # Start course import job from local file course_id = "MY_UNIQUE_COURSE_ID" course_path = "/path/to/course_package.zip" job_id = course_api.create_upload_and_import_course_job( course_id, file=course_path, may_create_new_version=True # Allow creating new version if course exists ) # Poll for job completion job_result = course_api.get_import_job_status(job_id.result) while job_result.status == "RUNNING": time.sleep(1) job_result = course_api.get_import_job_status(job_id.result) if job_result.status == "ERROR": raise ValueError(f"Course import failed: {job_result.message}") # Access imported course details course = job_result.import_result.course print(f"Course Title: {course.title}") print(f"Learning Standard: {course.course_learning_standard}") print(f"Version: {course.version}") ``` -------------------------------- ### CourseApi - Upload and Import Course Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Demonstrates how to upload a SCORM package from a local file system and import it as a course in SCORM Cloud, including polling for job completion. ```APIDOC ## CourseApi - Upload and Import Course Upload a SCORM package from your local file system and import it as a course in SCORM Cloud. ```python import rustici_software_cloud_v2 as scorm_cloud import time course_api = scorm_cloud.CourseApi() # Start course import job from local file course_id = "MY_UNIQUE_COURSE_ID" course_path = "/path/to/course_package.zip" job_id = course_api.create_upload_and_import_course_job( course_id, file=course_path, may_create_new_version=True # Allow creating new version if course exists ) # Poll for job completion job_result = course_api.get_import_job_status(job_id.result) while job_result.status == "RUNNING": time.sleep(1) job_result = course_api.get_import_job_status(job_id.result) if job_result.status == "ERROR": raise ValueError(f"Course import failed: {job_result.message}") # Access imported course details course = job_result.import_result.course print(f"Course Title: {course.title}") print(f"Learning Standard: {course.course_learning_standard}") print(f"Version: {course.version}") ``` ``` -------------------------------- ### POST /courses/{course_id}/preview Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Generate a preview launch link for a course. ```APIDOC ## POST /courses/{course_id}/preview ### Description Generate a preview launch link to test course content without creating a registration. ### Method POST ### Endpoint /courses/{course_id}/preview ### Parameters #### Path Parameters - **course_id** (string) - Required - The unique identifier of the course. #### Request Body - **redirect_on_exit_url** (string) - Optional - URL to redirect to upon exit. - **expiry** (integer) - Optional - Link expiration time in seconds. - **tracking** (boolean) - Optional - Whether to track interactions. ``` -------------------------------- ### CourseApi - Import Course from URL Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Shows how to import a course package by fetching it from a remote URL, including optional postback URLs for notifications. ```APIDOC ## CourseApi - Import Course from URL Fetch and import a course package from a remote URL instead of uploading locally. ```python import rustici_software_cloud_v2 as scorm_cloud import time course_api = scorm_cloud.CourseApi() # Create import request with course URL import_request = scorm_cloud.ImportFetchRequestSchema( url="https://example.com/courses/my_course.zip" ) # Start fetch and import job job_id = course_api.create_fetch_and_import_course_job( course_id="REMOTE_COURSE_001", import_request=import_request, may_create_new_version=False, postback_url="https://myserver.com/webhooks/course-import" # Optional callback ) # Poll for completion job_result = course_api.get_import_job_status(job_id.result) while job_result.status == "RUNNING": time.sleep(2) job_result = course_api.get_import_job_status(job_id.result) if job_result.status == "COMPLETE": print(f"Successfully imported: {job_result.import_result.course.title}") ``` ``` -------------------------------- ### Execute Complete SCORM Cloud Workflow Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Demonstrates the end-to-end process of importing a course, registering a learner, generating a launch link, and polling for completion status. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta import time # Configure authentication config = scorm_cloud.Configuration() config.username = "YOUR_APP_ID" config.password = "YOUR_SECRET_KEY" scorm_cloud.Configuration().set_default(config) # Initialize APIs course_api = scorm_cloud.CourseApi() registration_api = scorm_cloud.RegistrationApi() COURSE_ID = "ONBOARDING_2024" LEARNER_ID = "EMP_12345" REGISTRATION_ID = f"{COURSE_ID}_{LEARNER_ID}" try: # 1. Import course print("Importing course...") job_id = course_api.create_upload_and_import_course_job( course_id=COURSE_ID, file="/path/to/onboarding_course.zip", may_create_new_version=True ) job_result = course_api.get_import_job_status(job_id.result) while job_result.status == "RUNNING": time.sleep(1) job_result = course_api.get_import_job_status(job_id.result) if job_result.status == "ERROR": raise Exception(f"Import failed: {job_result.message}") print(f"Course imported: {job_result.import_result.course.title}") # 2. Create registration print("Creating registration...") learner = scorm_cloud.LearnerSchema( id=LEARNER_ID, first_name="Jane", last_name="Smith", email="jane.smith@company.com" ) registration = scorm_cloud.CreateRegistrationSchema( course_id=COURSE_ID, learner=learner, registration_id=REGISTRATION_ID ) registration_api.create_registration(registration) print("Registration created") # 3. Generate launch link launch_settings = scorm_cloud.LaunchLinkRequestSchema( redirect_on_exit_url="https://lms.company.com/complete", expiry=3600 ) launch_link = registration_api.build_registration_launch_link( registration_id=REGISTRATION_ID, launch_link_request=launch_settings ) print(f"Launch URL: {launch_link.launch_link}") print("Send this link to the learner...") # 4. Poll for completion (in real app, use postbacks instead) print("Waiting for learner to complete course...") while True: progress = registration_api.get_registration_progress(REGISTRATION_ID) if progress.registration_completion == "COMPLETED": print(f"Course completed!") print(f"Score: {progress.score.scaled * 100}%") print(f"Passed: {progress.registration_success}") break time.sleep(30) except scorm_cloud.rest.ApiException as e: print(f"API Error: {e.status} - {e.reason}") finally: # Cleanup (optional) # registration_api.delete_registration(REGISTRATION_ID) # course_api.delete_course(COURSE_ID) pass ``` -------------------------------- ### Build Learner Launch Link Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Generates a unique URL for a learner to access and take a registered SCORM course. Requires REGISTRATION_ID. ```python launch_link = sc.build_launch_link(REGISTRATION_ID) ``` -------------------------------- ### Import Course from URL Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Fetch a course package from a remote URL and monitor the import process. ```python import rustici_software_cloud_v2 as scorm_cloud import time course_api = scorm_cloud.CourseApi() # Create import request with course URL import_request = scorm_cloud.ImportFetchRequestSchema( url="https://example.com/courses/my_course.zip" ) # Start fetch and import job job_id = course_api.create_fetch_and_import_course_job( course_id="REMOTE_COURSE_001", import_request=import_request, may_create_new_version=False, postback_url="https://myserver.com/webhooks/course-import" # Optional callback ) # Poll for completion job_result = course_api.get_import_job_status(job_id.result) while job_result.status == "RUNNING": time.sleep(2) job_result = course_api.get_import_job_status(job_id.result) if job_result.status == "COMPLETE": print(f"Successfully imported: {job_result.import_result.course.title}") ``` -------------------------------- ### Build Registration Launch Link Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Generate a launch URL for a learner to access their registered course. Customize redirect, expiry, tracking, and authentication methods. ```python import rustici_software_cloud_v2 as scorm_cloud registration_api = scorm_cloud.RegistrationApi() # Configure launch link settings launch_settings = scorm_cloud.LaunchLinkRequestSchema( redirect_on_exit_url="https://mysite.com/course-complete", expiry=300, # Link valid for 5 minutes tracking=True, start_sco=None, # Start from beginning culture=None, # Use default language css_url=None, # Custom CSS for player launch_auth=scorm_cloud.LaunchAuthSchema( type="cookies" # Options: cookies, vault, any ) ) # Generate launch link launch_link = registration_api.build_registration_launch_link( registration_id="REG_001", launch_link_request=launch_settings ) print(f"Launch URL: {launch_link.launch_link}") # Output: https://cloud.scorm.com/api/cloud/launch/xxxxx?... ``` -------------------------------- ### Create and Import a Course Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Uploads a course from your local machine to SCORM Cloud. This method initiates an import job and polls for its completion, raising an error if the course is improperly formatted. ```python course_api = scorm_cloud.CourseApi() job_id = course_api.create_upload_and_import_course_job(course_id, file=course_path) job_result = course_api.get_import_job_status(job_id.result) while job_result.status == "RUNNING": time.sleep(1) job_result = course_api.get_import_job_status(job_id.result) if job_result.status == "ERROR": raise ValueError("Course is not properly formatted: " + job_result.message) return job_result.import_result.course ``` -------------------------------- ### Create Course and Registration Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Creates a new SCORM course and registers a learner for it. Requires COURSE_ID, COURSE_PATH, and REGISTRATION_ID to be defined. ```python course_details = sc.create_course(COURSE_ID, COURSE_PATH) sc.create_registration(COURSE_ID, LEARNER_ID, REGISTRATION_ID) ``` -------------------------------- ### Build a Course Launch Link Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Generates a URL that learners can use to access and launch a SCORM course. The `redirect_on_exit_url` can be set to control where the learner is redirected upon course completion or exit. ```python registration_api = scorm_cloud.RegistrationApi() settings = scorm_cloud.LaunchLinkRequestSchema(redirect_on_exit_url="Message") launch_link = registration_api.build_registration_launch_link(registration_id, settings) return launch_link.launch_link ``` -------------------------------- ### SCORM Cloud API Initialization Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md This code initializes the SCORM Cloud API client with necessary credentials and defines sample values for course and learner data. Ensure you replace placeholder credentials with your actual APP_ID and SECRET_KEY. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta import urllib.parse as ul import time # ScormCloud API credentials # Note: These are not the same credentials used to log in to ScormCloud APP_ID = "APP_ID" SECRET_KEY = "SECRET_KEY" # Sample values for data COURSE_PATH = "/PATH/TO/COURSE/RunTimeAdvancedCalls_SCORM20043rdEdition.zip" COURSE_ID = "PY_SAMPLE_COURSE" LEARNER_ID = "PY_SAMPLE_COURSE_LEARNER" REGISTRATION_ID = "PY_SAMPLE_COURSE_REGISTRATION" ``` -------------------------------- ### Create SCORM Cloud Registration Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Create a new registration to associate a learner with a course for tracking progress. Handles potential conflicts if the registration already exists. ```python import rustici_software_cloud_v2 as scorm_cloud registration_api = scorm_cloud.RegistrationApi() # Define learner information learner = scorm_cloud.LearnerSchema( id="LEARNER_001", first_name="John", last_name="Doe", email="john.doe@example.com" ) # Create registration registration = scorm_cloud.CreateRegistrationSchema( course_id="MY_COURSE_ID", learner=learner, registration_id="REG_001", initial_registration_state=None # Optional: set initial completion state ) try: registration_api.create_registration(registration) print("Registration created successfully") except scorm_cloud.rest.ApiException as e: if e.status == 409: print("Registration already exists") else: raise ``` -------------------------------- ### Configure Registration Postbacks Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Set up webhooks to receive automatic updates on registration progress. This includes specifying the URL, authentication type, username, and password. ```python settings = scorm_cloud.SettingsPostSchema(settings={ "ApiRollupRegistrationPostBackUrl": "https://myserver.com/webhooks/registration", "ApiRollupRegistrationAuthType": "httpbasic", "ApiRollupRegistrationAuthUser": "webhook_user", "ApiRollupRegistrationAuthPassword": "webhook_secret" }) registration_api.set_registration_configuration( registration_id="REG_001", configuration_settings=settings ) ``` -------------------------------- ### Configure SDK Authentication Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Set up HTTP basic authentication or OAuth 2.0 tokens for API requests. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta # Configure HTTP basic authorization config = scorm_cloud.Configuration() config.username = "YOUR_APP_ID" config.password = "YOUR_SECRET_KEY" # Set as default configuration for all API instances scorm_cloud.Configuration().set_default(config) # Optional: Configure OAuth token for scoped access app_management_api = scorm_cloud.ApplicationManagementApi() # Create OAuth token with specific permissions expiry = (datetime.utcnow() + timedelta(minutes=30)).isoformat() + 'Z' permissions = scorm_cloud.PermissionsSchema(["write:course", "read:course", "read:registration"]) token_request = scorm_cloud.TokenRequestSchema(permissions, expiry) token_result = app_management_api.create_token(token_request) # Apply OAuth token to configuration config.access_token = token_result.result scorm_cloud.Configuration().set_default(config) ``` -------------------------------- ### List Course Files Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve a list of all files within a course. The response includes file paths and sizes. ```python file_list = course_api.get_course_file_list(course_id="MY_COURSE_ID") for file in file_list.files: print(f"File: {file.path}, Size: {file.size}") ``` -------------------------------- ### Create a Learner Registration Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Creates a registration linking a learner to a specific course. This allows the learner to consume the course content. ```python registration_api = scorm_cloud.RegistrationApi() learner = scorm_cloud.LearnerSchema(learner_id) registration = scorm_cloud.CreateRegistrationSchema(course_id, learner, registration_id) registration_api.create_registration(registration) ``` -------------------------------- ### POST /registrations Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Create a new registration for a learner. ```APIDOC ## POST /registrations ### Description Create a registration to link a learner with a course for progress tracking. ### Method POST ### Endpoint /registrations ### Parameters #### Request Body - **course_id** (string) - Required - The course to register the learner for. - **learner** (object) - Required - Learner information (id, first_name, last_name, email). - **registration_id** (string) - Required - Unique identifier for the registration. - **initial_registration_state** (string) - Optional - Initial completion state. ``` -------------------------------- ### CourseApi - Course Configuration Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Manage course-specific configuration settings that can override application-level defaults. ```APIDOC ## CourseApi - Course Configuration ### Description Manage course-level configuration settings that override application defaults. ### Method GET, PUT, DELETE ### Endpoints - `/courses/{courseId}/configuration` - `/courses/{courseId}/configuration` - `/courses/{courseId}/configuration/{settingId}` ### Parameters #### GET /courses/{courseId}/configuration - **courseId** (string) - Required - The ID of the course. - **includeMetadata** (boolean) - Optional - If true, includes metadata for each setting. #### PUT /courses/{courseId}/configuration - **courseId** (string) - Required - The ID of the course. - **configurationSettings** (SettingsPostSchema) - Required - An object containing the course-specific settings to update. - **settings** (object) - Required - A dictionary of setting IDs and their new values. #### DELETE /courses/{courseId}/configuration/{settingId} - **courseId** (string) - Required - The ID of the course. - **settingId** (string) - Required - The ID of the setting to delete. ### Request Example ```python import rustici_software_cloud_v2 as scorm_cloud course_api = scorm_cloud.CourseApi() # Get course configuration course_config = course_api.get_course_configuration(course_id="MY_COURSE_ID", include_metadata=True) # Update course configuration settings_to_update = scorm_cloud.SettingsPostSchema(settings={ "PlayerLaunchType": "new_window", "Scorm12CompletionMode": "legacy" }) course_api.set_course_configuration(course_id="MY_COURSE_ID", configuration_settings=settings_to_update) # Delete a specific course configuration setting course_api.delete_course_configuration_setting(course_id="MY_COURSE_ID", setting_id="PlayerLaunchType") ``` ### Response #### Success Response (200) for GET - **settingItems** (list) - A list of course-specific configuration setting objects. #### Success Response (204) for PUT/DELETE Indicates successful operation. #### Response Example (GET) ```json { "settingItems": [ { "id": "PlayerLaunchType", "value": "new_window", "metadata": {...} } ] } ``` ``` -------------------------------- ### List All Registrations with Filters Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve a list of registrations, with options to filter by course, learner, date range ('since'), and tags. Pagination is supported. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta registration_api = scorm_cloud.RegistrationApi() # Get all registrations with filters response = registration_api.get_registrations( course_id="MY_COURSE_ID", # Filter by course learner_id=None, # Optional: filter by learner since=datetime.utcnow() - timedelta(days=7), tags=["team-a"], include_child_results=False ) ``` -------------------------------- ### Configure Basic Authentication Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Sets up the SCORM Cloud API client to use basic authentication with provided App ID and Secret Key. ```python config = scorm_cloud.Configuration() config.username = APP_ID config.password = SECRET_KEY # Set the default configuration values for new configuration objects scorm_cloud.Configuration().set_default(config) ``` -------------------------------- ### List and Manage Courses Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve a paginated list of courses and iterate through the results. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta course_api = scorm_cloud.CourseApi() # Get all courses with pagination response = course_api.get_courses( include_registration_count=True, include_course_metadata=True ) all_courses = response.courses while response.more is not None: response = course_api.get_courses(more=response.more) all_courses += response.courses for course in all_courses: print(f"ID: {course.id}, Title: {course.title}, Registrations: {course.registration_count}") ``` -------------------------------- ### Retrieve Registration Launch History Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Fetch the complete launch history for a specific registration, including detailed log entries if requested. This helps in analyzing learner session activity. ```python import rustici_software_cloud_v2 as scorm_cloud registration_api = scorm_cloud.RegistrationApi() # Get launch history history = registration_api.get_registration_launch_history( registration_id="REG_001", include_history_log=True # Include detailed log entries ) for launch in history.launch_history: print(f"Launch ID: {launch.id}") print(f" Start: {launch.launch_time}") print(f" Exit: {launch.exit_time}") print(f" Completion: {launch.completion_status}") print(f" Success: {launch.success_status}") print(f" Score: {launch.score.scaled if launch.score else 'N/A'}") ``` -------------------------------- ### Registration Postback Configuration API Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Configure webhooks to receive registration progress updates automatically. ```APIDOC ## RegistrationApi - Postback Configuration Configure webhooks to receive registration progress updates automatically. ### Configure registration to send postbacks #### Method PUT #### Endpoint `/registrations/{registration_id}/configuration` #### Request Body - **settings** (object) - Required - A dictionary of configuration settings. - **ApiRollupRegistrationPostBackUrl** (string) - Required - The URL for registration postbacks. - **ApiRollupRegistrationAuthType** (string) - Optional - The authentication type for postbacks (e.g., `httpbasic`). - **ApiRollupRegistrationAuthUser** (string) - Optional - The username for postback authentication. - **ApiRollupRegistrationAuthPassword** (string) - Optional - The password for postback authentication. ### Test postback configuration #### Method POST #### Endpoint `/registrations/postback/test` #### Request Body - **url** (string) - Required - The test URL for the postback. - **auth_type** (string) - Optional - The authentication type for the test postback. - **user_name** (string) - Optional - The username for the test postback authentication. - **password** (string) - Optional - The password for the test postback authentication. ``` -------------------------------- ### Download Course Asset Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Download a specific asset file from a course using its relative path. ```python asset_file = course_api.get_course_asset( course_id="MY_COURSE_ID", relative_path="shared/images/logo.png" ) ``` -------------------------------- ### Update Course Configuration Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Update the configuration settings for a course. Settings are provided as a dictionary, and common keys include `PlayerCommitFrequency`, `PlayerShowFinishButton`, and `ApiRollupRegistrationPostBackUrl`. ```python settings = scorm_cloud.SettingsPostSchema(settings={ "PlayerCommitFrequency": "always", "PlayerShowFinishButton": "true", "ApiRollupRegistrationPostBackUrl": "https://myserver.com/webhooks/progress" }) course_api.set_course_configuration( course_id="MY_COURSE_ID", configuration_settings=settings ) ``` -------------------------------- ### ApplicationManagementApi - Configuration Settings Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Manage application-level configuration settings that can override system defaults for all courses and registrations. ```APIDOC ## ApplicationManagementApi - Configuration Settings ### Description Manage application-level configuration settings that apply to all courses and registrations. ### Method GET, PUT, DELETE ### Endpoints - `/configuration/settings` - `/configuration/settings` - `/configuration/settings/{settingId}` ### Parameters #### GET /configuration/settings - **includeMetadata** (boolean) - Optional - If true, includes metadata for each setting. #### PUT /configuration/settings - **configurationSettings** (SettingsPostSchema) - Required - An object containing the settings to update. - **settings** (object) - Required - A dictionary of setting IDs and their new values. #### DELETE /configuration/settings/{settingId} - **settingId** (string) - Required - The ID of the setting to delete. ### Request Example ```python import rustici_software_cloud_v2 as scorm_cloud app_management_api = scorm_cloud.ApplicationManagementApi() # Get current application configuration config = app_management_api.get_application_configuration(include_metadata=True) for setting in config.setting_items: print(f"{setting.id}: {setting.value}") # Update application configuration settings = scorm_cloud.SettingsPostSchema(settings={ "PlayerLaunchType": "frameset", "PlayerScoLaunchType": "new_window", "ApiRollupRegistrationSuccessTimestampMode": "last_success" }) app_management_api.set_application_configuration(configuration_settings=settings) # Delete a specific setting (reverts to system default) app_management_api.delete_application_configuration_setting( setting_id="PlayerLaunchType" ) ``` ### Response #### Success Response (200) for GET - **settingItems** (list) - A list of configuration setting objects. #### Success Response (204) for PUT/DELETE Indicates successful update or deletion. #### Response Example (GET) ```json { "settingItems": [ { "id": "PlayerLaunchType", "value": "frameset", "metadata": {...} } ] } ``` ``` -------------------------------- ### Manage Application Configuration Settings Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Retrieve, update, and delete application-level configuration settings. These settings can override default behaviors for all courses and registrations within the application. ```python import rustici_software_cloud_v2 as scorm_cloud app_management_api = scorm_cloud.ApplicationManagementApi() # Get current application configuration config = app_management_api.get_application_configuration(include_metadata=True) for setting in config.setting_items: print(f"{setting.id}: {setting.value}") # Update application configuration settings = scorm_cloud.SettingsPostSchema(settings={ "PlayerLaunchType": "frameset", "PlayerScoLaunchType": "new_window", "ApiRollupRegistrationSuccessTimestampMode": "last_success" }) app_management_api.set_application_configuration(configuration_settings=settings) # Delete a specific setting (reverts to system default) app_management_api.delete_application_configuration_setting( setting_id="PlayerLaunchType" ) ``` -------------------------------- ### Fetch All Registrations with Pagination Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Retrieves all SCORM registrations, handling pagination to ensure all data is fetched. This can be time-consuming for many registrations. Consider using registration postbacks for efficiency. Requires the 'read:registration' scope if using OAuth. ```python def get_all_registrations(self): """ Gets information about the registration progress for all registrations. The result received from the API call is a paginated list, meaning that additional calls are required to retrieve all the information from the API. This has already been accounted for in the sample. This call can be quite time-consuming and tedious with lots of registrations. If you find yourself making lots of calls to this endpoint, it might be worthwhile to look into registration postbacks. More details can be found in the documentation: https://cloud.scorm.com/docs/v2/guides/postback/ :returns: List of detailed information about all of the registrations. :rtype: list[RegistrationSchema] """ # (Optional) Further authenticate via OAuth token access # self.__configure_oauth([ "read:registration" ]) # Additional filters can be provided to this call to get a subset # of all registrations. registration_api = scorm_cloud.RegistrationApi() response = registration_api.get_registrations() # This call is paginated, with a token provided if more results exist registration_list = response.registrations while response.more is not None: response = registration_api.get_registrations(more=response.more) registration_list += response.registrations return registration_list ``` -------------------------------- ### Handle Pagination for Registrations Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Iterate through all registrations by repeatedly fetching pages of results until no more pages are available. This is useful for retrieving large datasets. ```python all_registrations = response.registrations while response.more is not None: response = registration_api.get_registrations(more=response.more) all_registrations += response.registrations for reg in all_registrations: print(f"Registration: {reg.id}") print(f" Course: {reg.course.title}") print(f" Learner: {reg.learner.id}") print(f" Status: {reg.registration_completion}") print(f" Score: {reg.score.scaled if reg.score else 'N/A'}") ``` -------------------------------- ### Fetch All Courses with Pagination Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Retrieves all courses from SCORM Cloud, handling pagination to ensure all results are fetched. Requires the 'read:course' scope if using OAuth. ```python def get_all_courses(self): """ Gets information about the course progress for all courses. The result received from the API call is a paginated list, meaning that additional calls are required to retrieve all the information from the API. This has already been accounted for in the sample. :returns: List of detailed information about all of the courses. :rtype: list[CourseSchema] """ # (Optional) Further authenticate via OAuth token access # self.__configure_oauth([ "read:course" ]) # Additional filters can be provided to this call to get a subset # of all courses. course_api = scorm_cloud.CourseApi() response = course_api.get_courses() # This call is paginated, with a token provided if more results exist course_list = response.courses while response.more is not None: response = course_api.get_courses(more=response.more) course_list += response.courses return course_list ``` -------------------------------- ### Course Configuration API Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Manage configuration settings for individual courses, including retrieving, updating, and deleting specific settings. ```APIDOC ## Course Configuration API ### Get effective configuration for a course #### Method GET #### Endpoint `/courses/{course_id}/configuration` ### Update course configuration #### Method PUT #### Endpoint `/courses/{course_id}/configuration` #### Request Body - **settings** (object) - Required - A dictionary of configuration settings. - **PlayerCommitFrequency** (string) - Optional - How often the player commits progress. - **PlayerShowFinishButton** (string) - Optional - Whether to show the finish button. - **ApiRollupRegistrationPostBackUrl** (string) - Optional - The URL for registration postbacks. ### Delete a specific course setting #### Method DELETE #### Endpoint `/courses/{course_id}/configuration/settings/{setting_id}` ``` -------------------------------- ### Course Asset Management API Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Upload, download, and manage individual asset files within a course. ```APIDOC ## CourseApi - Course Asset Management Upload, download, and manage individual asset files within a course. ### List all files in a course #### Method GET #### Endpoint `/courses/{course_id}/assets` ### Download a specific asset file #### Method GET #### Endpoint `/courses/{course_id}/assets/{relative_path}` ### Upload/replace an asset file #### Method POST #### Endpoint `/courses/{course_id}/assets/{destination}` #### Parameters - **course_id** (string) - Required - The ID of the course. - **destination** (string) - Required - The destination path for the asset file within the course. - **file** (file) - Required - The asset file to upload. - **update_asset_policy** (string) - Optional - Policy for updating assets. Options: `reject`, `strict`, `lax`. ### Download entire course as ZIP #### Method GET #### Endpoint `/courses/{course_id}/zip` ``` -------------------------------- ### Upload Course Asset File Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Upload or replace an asset file within a course. Specify the destination path and optionally an `update_asset_policy` (`reject`, `strict`, or `lax`). ```python with open("/path/to/new_logo.png", "rb") as f: course_api.upload_course_asset_file( course_id="MY_COURSE_ID", destination="/shared/images/logo.png", file=f, update_asset_policy="lax" # Options: reject, strict, lax ) ``` -------------------------------- ### Clean Up Data Source: https://github.com/rusticisoftware/scormcloud-api-v2-client-python/blob/master/README.md Deletes all courses and registrations created by the sample script. Requires COURSE_ID and REGISTRATION_ID. ```python sc.clean_up(COURSE_ID, REGISTRATION_ID) ``` -------------------------------- ### Create and Use OAuth Token for API Access Source: https://context7.com/rusticisoftware/scormcloud-api-v2-client-python/llms.txt Generate an OAuth token with specific permissions and an expiration time. This token can then be used to authenticate subsequent API requests, providing scoped access. ```python import rustici_software_cloud_v2 as scorm_cloud from datetime import datetime, timedelta app_management_api = scorm_cloud.ApplicationManagementApi() # Create token with specific permissions expiry = (datetime.utcnow() + timedelta(hours=1)).isoformat() + 'Z' permissions = scorm_cloud.PermissionsSchema([ "write:course", "read:course", "write:registration", "read:registration" ]) token_request = scorm_cloud.TokenRequestSchema(permissions, expiry) token_result = app_management_api.create_token(token_request) # Use token for subsequent requests config = scorm_cloud.Configuration() config.access_token = token_result.result scorm_cloud.Configuration().set_default(config) # Now all API calls use OAuth token course_api = scorm_cloud.CourseApi() courses = course_api.get_courses() # Uses OAuth token ```