Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
b2993702
Commit
b2993702
authored
Mar 18, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #159 from edx/will/anonymize-student-ids
Use anonymous student ID if available
parents
96d76652
14462cc4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
22 deletions
+18
-22
apps/openassessment/xblock/openassessmentblock.py
+6
-22
apps/openassessment/xblock/test/test_openassessment.py
+12
-0
No files found.
apps/openassessment/xblock/openassessmentblock.py
View file @
b2993702
...
...
@@ -221,23 +221,6 @@ class OpenAssessmentBlock(
help
=
"Saved response submission for the current user."
)
def
get_xblock_trace
(
self
):
"""Uniquely identify this XBlock by context.
Every XBlock has a scope_ids, which is a NamedTuple describing
important contextual information. Per @nedbat, the usage_id attribute
uniquely identifies this block in this course, and the user_id uniquely
identifies this student. With the two of them, we can trace all the
interactions emanating from this interaction.
Useful for logging, debugging, and uniqueification.
"""
return
(
unicode
(
self
.
scope_ids
.
usage_id
),
unicode
(
self
.
scope_ids
.
user_id
)
if
self
.
scope_ids
.
user_id
is
not
None
else
None
,
)
def
get_student_item_dict
(
self
):
"""Create a student_item_dict from our surrounding context.
...
...
@@ -247,14 +230,19 @@ class OpenAssessmentBlock(
(dict): The student item associated with this XBlock instance. This
includes the student id, item id, and course id.
"""
item_id
,
student_id
=
self
.
get_xblock_trace
(
)
item_id
=
unicode
(
self
.
scope_ids
.
usage_id
)
# This is not the real way course_ids should work, but this is a
# temporary expediency for LMS integratino
if
hasattr
(
self
,
"xmodule_runtime"
):
course_id
=
self
.
xmodule_runtime
.
course_id
student_id
=
self
.
xmodule_runtime
.
anonymous_student_id
else
:
course_id
=
"edX/Enchantment_101/April_1"
if
self
.
scope_ids
.
user_id
is
None
:
student_id
=
None
else
:
student_id
=
unicode
(
self
.
scope_ids
.
user_id
)
student_item_dict
=
dict
(
student_id
=
student_id
,
...
...
@@ -278,11 +266,9 @@ class OpenAssessmentBlock(
(Fragment): The HTML Fragment for this XBlock, which determines the
general frame of the Open Ended Assessment Question.
"""
trace
=
self
.
get_xblock_trace
()
ui_models
=
self
.
_create_ui_models
()
# All data we intend to pass to the front end.
context_dict
=
{
"xblock_trace"
:
trace
,
"title"
:
self
.
title
,
"question"
:
self
.
prompt
,
"rubric_criteria"
:
self
.
rubric_criteria
,
...
...
@@ -366,8 +352,6 @@ class OpenAssessmentBlock(
if
not
context_dict
:
context_dict
=
{}
context_dict
[
"xblock_trace"
]
=
self
.
get_xblock_trace
()
if
self
.
start
:
context_dict
[
"formatted_start_date"
]
=
self
.
start
.
strftime
(
"
%
A,
%
B
%
d,
%
Y"
)
context_dict
[
"formatted_start_datetime"
]
=
self
.
start
.
strftime
(
"
%
A,
%
B
%
d,
%
Y
%
X"
)
...
...
apps/openassessment/xblock/test/test_openassessment.py
View file @
b2993702
...
...
@@ -94,6 +94,18 @@ class TestOpenAssessment(XBlockHandlerTestCase):
self
.
assertEqual
(
student_item
[
'student_id'
],
'2'
)
self
.
assertIsInstance
(
student_item
[
'item_id'
],
unicode
)
@scenario
(
'data/basic_scenario.xml'
,
user_id
=
'Bob'
)
def
test_use_xmodule_runtime
(
self
,
xblock
):
# Prefer course ID and student ID provided by the XModule runtime
xblock
.
xmodule_runtime
=
Mock
(
course_id
=
'test_course'
,
anonymous_student_id
=
'test_student'
)
student_item
=
xblock
.
get_student_item_dict
()
self
.
assertEqual
(
student_item
[
'course_id'
],
'test_course'
)
self
.
assertEqual
(
student_item
[
'student_id'
],
'test_student'
)
class
TestDates
(
XBlockHandlerTestCase
):
...
...
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