Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-proctoring
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-proctoring
Commits
0aa31a05
Commit
0aa31a05
authored
Jun 24, 2015
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update models
parent
278cf650
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
12 deletions
+31
-12
edx_proctoring/migrations/0001_initial.py
+7
-1
edx_proctoring/models.py
+19
-7
edx_proctoring/tests/test_models.py
+5
-4
No files found.
edx_proctoring/migrations/0001_initial.py
View file @
0aa31a05
...
@@ -14,6 +14,9 @@ class Migration(SchemaMigration):
...
@@ -14,6 +14,9 @@ class Migration(SchemaMigration):
(
'course_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
255
,
db_index
=
True
)),
(
'course_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
255
,
db_index
=
True
)),
(
'content_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
255
,
db_index
=
True
)),
(
'content_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
255
,
db_index
=
True
)),
(
'external_id'
,
self
.
gf
(
'django.db.models.fields.TextField'
)(
null
=
True
,
db_index
=
True
)),
(
'external_id'
,
self
.
gf
(
'django.db.models.fields.TextField'
)(
null
=
True
,
db_index
=
True
)),
(
'time_limit_mins'
,
self
.
gf
(
'django.db.models.fields.IntegerField'
)()),
(
'is_proctored'
,
self
.
gf
(
'django.db.models.fields.BooleanField'
)(
default
=
False
)),
(
'is_active'
,
self
.
gf
(
'django.db.models.fields.BooleanField'
)(
default
=
False
)),
))
))
db
.
send_create_signal
(
'edx_proctoring'
,
[
'ProctoredExam'
])
db
.
send_create_signal
(
'edx_proctoring'
,
[
'ProctoredExam'
])
...
@@ -73,7 +76,10 @@ class Migration(SchemaMigration):
...
@@ -73,7 +76,10 @@ class Migration(SchemaMigration):
'content_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'content_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'external_id'
:
(
'django.db.models.fields.TextField'
,
[],
{
'null'
:
'True'
,
'db_index'
:
'True'
}),
'external_id'
:
(
'django.db.models.fields.TextField'
,
[],
{
'null'
:
'True'
,
'db_index'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
})
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'is_active'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'is_proctored'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'time_limit_mins'
:
(
'django.db.models.fields.IntegerField'
,
[],
{})
},
},
'edx_proctoring.proctoredexamstudentallowance'
:
{
'edx_proctoring.proctoredexamstudentallowance'
:
{
'Meta'
:
{
'object_name'
:
'ProctoredExamStudentAllowance'
},
'Meta'
:
{
'object_name'
:
'ProctoredExamStudentAllowance'
},
...
...
edx_proctoring/models.py
View file @
0aa31a05
...
@@ -21,6 +21,15 @@ class ProctoredExam(models.Model):
...
@@ -21,6 +21,15 @@ class ProctoredExam(models.Model):
# This will be a integration specific ID - say to SoftwareSecure.
# This will be a integration specific ID - say to SoftwareSecure.
external_id
=
models
.
TextField
(
null
=
True
,
db_index
=
True
)
external_id
=
models
.
TextField
(
null
=
True
,
db_index
=
True
)
# Time limit (in minutes) that a student can finish this exam
time_limit_mins
=
models
.
IntegerField
()
# Whether this exam actually is proctored or not
is_proctored
=
models
.
BooleanField
()
# This will be a integration specific ID - say to SoftwareSecure.
is_active
=
models
.
BooleanField
()
class
ProctoredExamStudentAttempt
(
models
.
Model
):
class
ProctoredExamStudentAttempt
(
models
.
Model
):
"""
"""
...
@@ -92,22 +101,25 @@ class ProctoredExamStudentAllowanceHistory(TimeStampedModel):
...
@@ -92,22 +101,25 @@ class ProctoredExamStudentAllowanceHistory(TimeStampedModel):
# Hook up the custom POST_UPDATE_SIGNAL signal to record updations in the ProctoredExamStudentAllowanceHistory table.
# Hook up the custom POST_UPDATE_SIGNAL signal to record updations in the ProctoredExamStudentAllowanceHistory table.
@receiver
(
post_save
,
sender
=
ProctoredExamStudentAllowance
)
@receiver
(
post_save
,
sender
=
ProctoredExamStudentAllowance
)
def
archive_allowance_updations
(
sender
,
**
kwargs
):
# pylint: disable=unused-argument
def
archive_allowance_updations
(
sender
,
instance
,
created
,
**
kwargs
):
# pylint: disable=unused-argument
"""
"""
Archiving all changes made to the Student Allowance.
Archiving all changes made to the Student Allowance.
Will only archive on update, and not on new entries created.
Will only archive on update, and not on new entries created.
"""
"""
_make_archive_copy
(
kwargs
[
'instance'
])
if
not
created
:
_make_archive_copy
(
instance
)
def
_make_archive_copy
(
updated_obj
):
def
_make_archive_copy
(
item
):
"""
"""
Make a clone and populate in the History table
Make a clone and populate in the History table
"""
"""
archive_object
=
ProctoredExamStudentAllowanceHistory
()
archive_object
=
ProctoredExamStudentAllowanceHistory
(
updated_obj_dict
=
updated_obj
.
__dict__
user_id
=
item
.
user_id
,
updated_obj_dict
.
pop
(
'id'
)
proctored_exam
=
item
.
proctored_exam
,
archive_object
.
__dict__
.
update
(
updated_obj_dict
)
key
=
item
.
key
,
value
=
item
.
value
)
archive_object
.
save
()
archive_object
.
save
()
edx_proctoring/tests/test_models.py
View file @
0aa31a05
...
@@ -28,7 +28,8 @@ class ProctoredExamModelTests(LoggedInTestCase):
...
@@ -28,7 +28,8 @@ class ProctoredExamModelTests(LoggedInTestCase):
proctored_exam
=
ProctoredExam
.
objects
.
create
(
proctored_exam
=
ProctoredExam
.
objects
.
create
(
course_id
=
'test_course'
,
course_id
=
'test_course'
,
content_id
=
'test_content'
,
content_id
=
'test_content'
,
external_id
=
'123aXqe3'
external_id
=
'123aXqe3'
,
time_limit_mins
=
90
)
)
ProctoredExamStudentAllowance
.
objects
.
create
(
ProctoredExamStudentAllowance
.
objects
.
create
(
user_id
=
1
,
user_id
=
1
,
...
@@ -38,7 +39,7 @@ class ProctoredExamModelTests(LoggedInTestCase):
...
@@ -38,7 +39,7 @@ class ProctoredExamModelTests(LoggedInTestCase):
)
)
# No entry in the History table on creation of the Allowance entry.
# No entry in the History table on creation of the Allowance entry.
proctored_exam_student_history
=
ProctoredExamStudentAllowanceHistory
.
objects
.
filter
(
user_id
=
1
)
proctored_exam_student_history
=
ProctoredExamStudentAllowanceHistory
.
objects
.
filter
(
user_id
=
1
)
self
.
assertEqual
(
len
(
proctored_exam_student_history
),
1
)
self
.
assertEqual
(
len
(
proctored_exam_student_history
),
0
)
# Update the allowance object twice
# Update the allowance object twice
ProctoredExamStudentAllowance
.
objects
.
filter
(
ProctoredExamStudentAllowance
.
objects
.
filter
(
...
@@ -63,7 +64,7 @@ class ProctoredExamModelTests(LoggedInTestCase):
...
@@ -63,7 +64,7 @@ class ProctoredExamModelTests(LoggedInTestCase):
# 2 new entries are created in the History table.
# 2 new entries are created in the History table.
proctored_exam_student_history
=
ProctoredExamStudentAllowanceHistory
.
objects
.
filter
(
user_id
=
1
)
proctored_exam_student_history
=
ProctoredExamStudentAllowanceHistory
.
objects
.
filter
(
user_id
=
1
)
self
.
assertEqual
(
len
(
proctored_exam_student_history
),
3
)
self
.
assertEqual
(
len
(
proctored_exam_student_history
),
2
)
# also check with save() method
# also check with save() method
...
@@ -72,4 +73,4 @@ class ProctoredExamModelTests(LoggedInTestCase):
...
@@ -72,4 +73,4 @@ class ProctoredExamModelTests(LoggedInTestCase):
allowance
.
save
()
allowance
.
save
()
proctored_exam_student_history
=
ProctoredExamStudentAllowanceHistory
.
objects
.
filter
(
user_id
=
1
)
proctored_exam_student_history
=
ProctoredExamStudentAllowanceHistory
.
objects
.
filter
(
user_id
=
1
)
self
.
assertEqual
(
len
(
proctored_exam_student_history
),
4
)
self
.
assertEqual
(
len
(
proctored_exam_student_history
),
3
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment