Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
917ca595
Commit
917ca595
authored
Apr 02, 2015
by
aamir-khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ECOM-1289: added the re-verification service to implement the re-verification xblock
parent
3b854b21
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
1 deletions
+71
-1
lms/djangoapps/courseware/module_render.py
+2
-0
lms/djangoapps/verify_student/models.py
+19
-1
lms/djangoapps/verify_student/services.py
+50
-0
No files found.
lms/djangoapps/courseware/module_render.py
View file @
917ca595
...
...
@@ -70,6 +70,7 @@ from util.json_request import JsonResponse
from
util.sandboxing
import
can_execute_unsafe_code
,
get_python_lib_zip
from
util
import
milestones_helpers
from
util.module_utils
import
yield_dynamic_descriptor_descendents
from
verify_student.services
import
ReverificationService
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -618,6 +619,7 @@ def get_module_system_for_user(user, field_data_cache,
'fs'
:
xblock
.
reference
.
plugins
.
FSService
(),
'field-data'
:
field_data
,
'user'
:
DjangoXBlockUserService
(
user
,
user_is_staff
=
user_is_staff
),
"reverification"
:
ReverificationService
()
},
get_user_role
=
lambda
:
get_user_role
(
user
,
course_id
),
descriptor_runtime
=
descriptor
.
_runtime
,
# pylint: disable=protected-access
...
...
lms/djangoapps/verify_student/models.py
View file @
917ca595
...
...
@@ -17,6 +17,7 @@ import uuid
from
boto.s3.connection
import
S3Connection
from
boto.s3.key
import
Key
from
django.core.exceptions
import
ObjectDoesNotExist
import
pytz
import
requests
...
...
@@ -945,6 +946,20 @@ class VerificationCheckpoint(models.Model):
"""
self
.
photo_verification
.
add
(
verification_attempt
)
# pylint: disable=no-member
def
get_user_latest_status
(
self
,
user_id
):
""" Return the latest status of the given checkpoint attempt by user
Args:
user_id(str): Id of user
Returns:
VerificationStatus object if found any else None
"""
try
:
return
self
.
checkpoint_status
.
filter
(
user_id
=
user_id
)
.
latest
()
# pylint: disable=E1101
except
ObjectDoesNotExist
:
return
None
@classmethod
def
get_verification_checkpoint
(
cls
,
course_id
,
checkpoint_name
):
"""Get the verification checkpoint for given course_id and checkpoint name
...
...
@@ -976,13 +991,16 @@ class VerificationStatus(models.Model):
(
"error"
,
"error"
)
)
checkpoint
=
models
.
ForeignKey
(
VerificationCheckpoint
)
checkpoint
=
models
.
ForeignKey
(
VerificationCheckpoint
,
related_name
=
"checkpoint_status"
)
user
=
models
.
ForeignKey
(
User
)
status
=
models
.
CharField
(
choices
=
VERIFICATION_STATUS_CHOICES
,
db_index
=
True
,
max_length
=
32
)
timestamp
=
models
.
DateTimeField
(
auto_now_add
=
True
)
response
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
error
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
class
Meta
(
object
):
# pylint: disable=missing-docstring
get_latest_by
=
"timestamp"
@classmethod
def
add_verification_status
(
cls
,
checkpoint
,
user
,
status
):
""" Create new verification status object
...
...
lms/djangoapps/verify_student/services.py
0 → 100644
View file @
917ca595
"""
Implement the Reverification XBlock "reverification" server
"""
from
opaque_keys.edx.keys
import
CourseKey
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.urlresolvers
import
reverse
from
verify_student.models
import
VerificationCheckpoint
,
VerificationStatus
class
ReverificationService
(
object
):
""" Service to implement the Reverification XBlock "reverification" service
"""
def
get_status
(
self
,
user_id
,
course_id
,
checkpoint_name
):
""" Check if the user has any verification attempt for this checkpoint and course_id
Args:
user_id(str): User Id string
course_id(str): A string of course_id
checkpoint_name(str): Verification checkpoint name
Returns:
Verification Status string if any attempt submitted by user else None
"""
course_key
=
CourseKey
.
from_string
(
course_id
)
try
:
checkpoint_status
=
VerificationStatus
.
objects
.
filter
(
user_id
=
user_id
,
checkpoint__course_id
=
course_key
,
checkpoint__checkpoint_name
=
checkpoint_name
)
.
latest
()
return
checkpoint_status
.
status
except
ObjectDoesNotExist
:
return
None
def
start_verification
(
self
,
course_id
,
checkpoint_name
,
item_id
):
# pylint: disable=W0613
""" Get or create the verification checkpoint and return the re-verification link
Args:
course_id(str): A string of course_id
checkpoint_name(str): Verification checkpoint name
Returns:
Re-verification link
"""
course_key
=
CourseKey
.
from_string
(
course_id
)
VerificationCheckpoint
.
objects
.
get_or_create
(
course_id
=
course_key
,
checkpoint_name
=
checkpoint_name
)
re_verification_link
=
reverse
(
"verify_student_incourse_reverify"
,
args
=
(
course_id
,
checkpoint_name
))
return
re_verification_link
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