function create_training_completion
Factory function that instantiates and returns a TrainingCompletion object for managing training completion workflows in a document control system.
/tf/active/vicechatdev/CDocs/ui/training_completion.py
784 - 786
simple
Purpose
This function serves as a factory/constructor wrapper for creating TrainingCompletion instances. It's designed to initialize training completion tracking for controlled documents within a document management system, allowing users to complete required training on specific documents. The function accepts optional parameters for parent application context and document identification.
Source Code
def create_training_completion(parent_app=None, document_uid: str = None):
"""Create a training completion instance."""
return TrainingCompletion(parent_app=parent_app, document_uid=document_uid)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
parent_app |
- | None | positional_or_keyword |
document_uid |
str | None | positional_or_keyword |
Parameter Details
parent_app: Optional reference to the parent application instance. Defaults to None. This parameter allows the TrainingCompletion component to access application-level context, settings, or shared resources. Expected to be an application object or None.
document_uid: Optional string identifier (UID) for the specific document that requires training completion. Defaults to None. This should be a unique identifier string that corresponds to a ControlledDocument in the system. When provided, the TrainingCompletion instance will be associated with that specific document.
Return Value
Returns an instance of the TrainingCompletion class. This object manages the training completion workflow for a document, including tracking user training status, completion records, and related UI components. The returned instance is initialized with the provided parent_app and document_uid parameters.
Dependencies
panelparamloggingtypingdatetime
Required Imports
from CDocs.models.training import TrainingCompletion
Usage Example
# Basic usage without parameters
training_completion = create_training_completion()
# Usage with document UID
training_completion = create_training_completion(document_uid='DOC-12345')
# Usage with parent app and document UID
from my_app import app_instance
training_completion = create_training_completion(
parent_app=app_instance,
document_uid='DOC-12345'
)
# The returned object can then be used to manage training completion
# training_completion.display() # Show UI
# training_completion.mark_complete() # Mark training as complete
Best Practices
- Always provide a valid document_uid when creating a training completion instance for a specific document
- Pass the parent_app parameter when the TrainingCompletion needs access to application-level resources or context
- Ensure the document_uid corresponds to an existing ControlledDocument in the database before creating the instance
- This is a factory function - use it instead of directly instantiating TrainingCompletion to maintain consistency
- Handle cases where the document_uid might not exist in the system by checking document existence before calling this function
- Consider wrapping this call in try-except blocks if the TrainingCompletion constructor might raise exceptions for invalid parameters
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function create_training_management 78.3% similar
-
class TrainingCompletion 62.8% similar
-
function create_training_dashboard 60.1% similar
-
class DocumentTraining 58.2% similar
-
class TrainingManagement 57.7% similar