Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
schoolyourself-xblock
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
schoolyourself-xblock
Commits
4a3b9118
Commit
4a3b9118
authored
Nov 18, 2014
by
John Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished implementing grading in the review XBlock
parent
0f7ea52a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
schoolyourself/schoolyourself_review.py
+27
-4
No files found.
schoolyourself/schoolyourself_review.py
View file @
4a3b9118
"""An XBlock that displays School Yourself reviews and may publish grades."""
"""An XBlock that displays School Yourself reviews and may publish grades."""
import
hmac
import
urllib
import
urllib
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
...
@@ -68,14 +69,36 @@ class SchoolYourselfReviewXBlock(SchoolYourselfXBlock):
...
@@ -68,14 +69,36 @@ class SchoolYourselfReviewXBlock(SchoolYourselfXBlock):
def
handle_grade
(
self
,
data
,
suffix
=
""
):
def
handle_grade
(
self
,
data
,
suffix
=
""
):
"""This is the handler that gets called when we receive grades.
"""This is the handler that gets called when we receive grades.
TODO(jjl): Make sure the message is signed.
We will verify the message to make sure that it is signed and
that the signature is valid. If everything is good, then we'll
publish a "grade" event for this module.
"""
"""
mastery
=
data
.
get
(
"m"
,
None
)
mastery
=
data
.
get
(
"mastery"
,
None
)
if
not
mastery
:
user_id
=
data
.
get
(
"user_id"
,
None
)
signature
=
data
.
get
(
"signature"
,
None
)
if
not
mastery
or
not
user_id
or
not
signature
:
return
return
# Check that the module ID we care about is actually in the data
# that was sent.
mastery_level
=
mastery
.
get
(
self
.
module_id
,
None
)
if
mastery_level
is
None
:
return
# Verify the signature.
verifier
=
hmac
.
new
(
str
(
self
.
shared_key
),
user_id
)
for
key
in
sorted
(
mastery
):
verifier
.
update
(
key
)
verifier
.
update
(
"
%.2
f"
%
mastery
[
key
])
# If the signature is invalid, do nothing.
if
signature
!=
verifier
.
hexdigest
():
return
# If we got here, then everything checks out and we can submit
# a grade for this module.
self
.
runtime
.
publish
(
self
,
"grade"
,
self
.
runtime
.
publish
(
self
,
"grade"
,
{
"value"
:
mastery
,
{
"value"
:
mastery
_level
,
"max_value"
:
0.7
})
"max_value"
:
0.7
})
...
...
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