Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
424abc03
Unverified
Commit
424abc03
authored
3 years ago
by
Dillon Dumesnil
Browse files
Options
Downloads
Patches
Plain Diff
feat: Add User Activity Model for Course Goals AA-903
parent
fa7ed70c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/course_goals/migrations/0005_useractivity.py
+34
-0
34 additions, 0 deletions
lms/djangoapps/course_goals/migrations/0005_useractivity.py
lms/djangoapps/course_goals/models.py
+24
-3
24 additions, 3 deletions
lms/djangoapps/course_goals/models.py
with
58 additions
and
3 deletions
lms/djangoapps/course_goals/migrations/0005_useractivity.py
0 → 100644
+
34
−
0
View file @
424abc03
# Generated by Django 2.2.24 on 2021-08-13 17:02
from
django.conf
import
settings
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
opaque_keys.edx.django.models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'
course_goals
'
,
'
0004_auto_20210806_0137
'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'
UserActivity
'
,
fields
=
[
(
'
id
'
,
models
.
BigAutoField
(
primary_key
=
True
,
serialize
=
False
)),
(
'
course_key
'
,
opaque_keys
.
edx
.
django
.
models
.
CourseKeyField
(
max_length
=
255
)),
(
'
date
'
,
models
.
DateField
()),
(
'
user
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
migrations
.
AddIndex
(
model_name
=
'
useractivity
'
,
index
=
models
.
Index
(
fields
=
[
'
user
'
,
'
course_key
'
],
name
=
'
user_course_index
'
),
),
migrations
.
AddConstraint
(
model_name
=
'
useractivity
'
,
constraint
=
models
.
UniqueConstraint
(
fields
=
(
'
user
'
,
'
course_key
'
,
'
date
'
),
name
=
'
unique_user_course_date
'
),
),
]
This diff is collapsed.
Click to expand it.
lms/djangoapps/course_goals/models.py
+
24
−
3
View file @
424abc03
...
...
@@ -28,10 +28,10 @@ class CourseGoal(models.Model):
.. no_pii:
"""
class
Meta
:
app_label
=
"
course_goals
"
unique_together
=
(
"
user
"
,
"
course_key
"
)
app_label
=
'
course_goals
'
unique_together
=
(
'
user
'
,
'
course_key
'
)
user
=
models
.
ForeignKey
(
User
,
blank
=
False
,
on_delete
=
models
.
CASCADE
)
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
course_key
=
CourseKeyField
(
max_length
=
255
,
db_index
=
True
)
# The goal a user has set for the number of days they want to learn per week
days_per_week
=
models
.
PositiveIntegerField
(
default
=
0
)
...
...
@@ -46,3 +46,24 @@ class CourseGoal(models.Model):
goal
=
self
.
days_per_week
,
course
=
self
.
course_key
,
)
class
UserActivity
(
models
.
Model
):
"""
Tracks 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.
.. no_pii:
"""
class
Meta
:
constraints
=
[
models
.
UniqueConstraint
(
fields
=
[
'
user
'
,
'
course_key
'
,
'
date
'
],
name
=
'
unique_user_course_date
'
)]
indexes
=
[
models
.
Index
(
fields
=
[
'
user
'
,
'
course_key
'
],
name
=
'
user_course_index
'
)]
id
=
models
.
BigAutoField
(
primary_key
=
True
)
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
course_key
=
CourseKeyField
(
max_length
=
255
)
date
=
models
.
DateField
()
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment