From e5a6509bb043381d39058cba77ab514e2c5d67bb Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 8 Jan 2013 11:51:20 -0500 Subject: [PATCH] Add a first_time_user attribute to CourseModule so that we can check for that explicitly, rather than looking for an implicitly created StudentModule --- common/lib/xmodule/xmodule/course_module.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 3b73b6a4d1..2bab5580f6 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -89,8 +89,18 @@ class TextbookList(ModelType): return json_data +class CourseModule(SequenceModule): + first_time_user = Boolean(help="Whether this is the first time the user has visited this course", scope=Scope.student_state, default=True) + + def __init__(self, *args, **kwargs): + super(CourseModule, self).__init__(*args, **kwargs) + + if self.first_time_user: + self.first_time_user = False + + class CourseDescriptor(SequenceDescriptor): - module_class = SequenceModule + module_class = CourseModule textbooks = TextbookList(help="List of pairs of (title, url) for textbooks used in this course", default=[], scope=Scope.content) wiki_slug = String(help="Slug that points to the wiki for this course", scope=Scope.content)