lms.djangoapps.course_goals package#
Subpackages#
Submodules#
lms.djangoapps.course_goals.api module#
Course Goals Python API
- lms.djangoapps.course_goals.api.add_course_goal(user, course_id, subscribed_to_reminders, days_per_week=None)#
Add a new course goal for the provided user and course. If the goal already exists, simply update and save the goal.
- Parameters:
user – The user that is setting the goal
course_id (string) – The id for the course the goal refers to
subscribed_to_reminders (bool) – whether the learner wants to receive email reminders about their goal
days_per_week (int) – (optional) number of days learner wants to learn per week
- lms.djangoapps.course_goals.api.get_course_goal(user, course_key)#
Given a user and a course_key, return their course goal.
If the user is anonymous or a course goal does not exist, returns None.
lms.djangoapps.course_goals.apps module#
Course Goals Application Configuration
Signal handlers are connected here.
lms.djangoapps.course_goals.handlers module#
Signal handlers for course goals.
- lms.djangoapps.course_goals.handlers.emit_course_goal_event(sender, instance, **kwargs)#
Emit events for both tracking logs and for Segment.
lms.djangoapps.course_goals.models module#
Course Goals Models
- class lms.djangoapps.course_goals.models.CourseGoal(*args, **kwargs)#
Bases:
ModelRepresents a course goal set by a user on the course home page.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- course_key#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- days_per_week#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_goal_key_display(*, field=<django.db.models.fields.CharField: goal_key>)#
- goal_key#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- reminder_status#
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- save(**kwargs)#
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- save_without_historical_record(*args, **kwargs)#
Save the model instance without creating a historical record.
Make sure you know what you’re doing before using this method.
- subscribed_to_reminders#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- unsubscribe_token#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id#
- class lms.djangoapps.course_goals.models.CourseGoalReminderStatus(*args, **kwargs)#
Bases:
TimeStampedModelTracks whether we’ve sent a reminder about a particular goal this week.
See the management command goal_reminder_email for more detail about how this is used.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- email_reminder_sent#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- goal#
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.placeis aForwardOneToOneDescriptorinstance.
- goal_id#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- class lms.djangoapps.course_goals.models.UserActivity(*args, **kwargs)#
Bases:
ModelTracks the date a user performs an activity in a course for goal purposes. To be used in conjunction with the CourseGoal model to establish if a learner is hitting their desired days_per_week.
To start, this model will only be tracking page views that count towards a learner’s goal, but could grow to tracking other types of goal achieving activities in the future.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- course_key#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_date(*, field=<django.db.models.fields.DateField: date>, is_next=True, **kwargs)#
- get_previous_by_date(*, field=<django.db.models.fields.DateField: date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- classmethod record_user_activity(user, course_key, request=None, only_if_mobile_app=False)#
Update the user activity table with a record for this activity.
Since we store one activity per date, we don’t need to query the database for every activity on a given date. To avoid unnecessary queries, we store a record in a cache once we have an activity for the date, which times out at the end of that date (in the user’s timezone).
The request argument is only used to check if the request is coming from a mobile app. Once the only_if_mobile_app argument is removed the request argument can be removed as well.
The return value is the id of the object that was created, or retrieved. A return value of None signifies that a user activity record was not stored or retrieved
- user#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id#