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
6dccdbe3
Commit
6dccdbe3
authored
Jun 21, 2016
by
Ehtesham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assigning legend for inputtypes
parent
60f13379
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
common/lib/capa/capa/capa_problem.py
+24
-4
common/lib/capa/capa/inputtypes.py
+2
-0
common/lib/capa/capa/templates/choicegroup.html
+4
-1
No files found.
common/lib/capa/capa/capa_problem.py
View file @
6dccdbe3
...
@@ -176,7 +176,7 @@ class LoncapaProblem(object):
...
@@ -176,7 +176,7 @@ class LoncapaProblem(object):
# transformations. This also creates the dict (self.responders) of Response
# transformations. This also creates the dict (self.responders) of Response
# instances for each question in the problem. The dict has keys = xml subtree of
# instances for each question in the problem. The dict has keys = xml subtree of
# Response, values = Response instance
# Response, values = Response instance
self
.
_preprocess_problem
(
self
.
tree
)
self
.
problem_data
=
self
.
_preprocess_problem
(
self
.
tree
)
if
not
self
.
student_answers
:
# True when student_answers is an empty dict
if
not
self
.
student_answers
:
# True when student_answers is an empty dict
self
.
set_initial_display
()
self
.
set_initial_display
()
...
@@ -752,7 +752,10 @@ class LoncapaProblem(object):
...
@@ -752,7 +752,10 @@ class LoncapaProblem(object):
if
problemtree
.
tag
in
inputtypes
.
registry
.
registered_tags
():
if
problemtree
.
tag
in
inputtypes
.
registry
.
registered_tags
():
# If this is an inputtype subtree, let it render itself.
# If this is an inputtype subtree, let it render itself.
status
=
"unsubmitted"
response_id
=
self
.
problem_id
+
'_'
+
problemtree
.
get
(
'response_id'
)
response_data
=
self
.
problem_data
[
response_id
]
status
=
'unsubmitted'
msg
=
''
msg
=
''
hint
=
''
hint
=
''
hintmode
=
None
hintmode
=
None
...
@@ -766,7 +769,7 @@ class LoncapaProblem(object):
...
@@ -766,7 +769,7 @@ class LoncapaProblem(object):
hintmode
=
self
.
correct_map
.
get_hintmode
(
pid
)
hintmode
=
self
.
correct_map
.
get_hintmode
(
pid
)
answervariable
=
self
.
correct_map
.
get_property
(
pid
,
'answervariable'
)
answervariable
=
self
.
correct_map
.
get_property
(
pid
,
'answervariable'
)
value
=
""
value
=
''
if
self
.
student_answers
and
problemid
in
self
.
student_answers
:
if
self
.
student_answers
and
problemid
in
self
.
student_answers
:
value
=
self
.
student_answers
[
problemid
]
value
=
self
.
student_answers
[
problemid
]
...
@@ -780,6 +783,7 @@ class LoncapaProblem(object):
...
@@ -780,6 +783,7 @@ class LoncapaProblem(object):
'id'
:
input_id
,
'id'
:
input_id
,
'input_state'
:
self
.
input_state
[
input_id
],
'input_state'
:
self
.
input_state
[
input_id
],
'answervariable'
:
answervariable
,
'answervariable'
:
answervariable
,
'response_data'
:
response_data
,
'feedback'
:
{
'feedback'
:
{
'message'
:
msg
,
'message'
:
msg
,
'hint'
:
hint
,
'hint'
:
hint
,
...
@@ -836,12 +840,12 @@ class LoncapaProblem(object):
...
@@ -836,12 +840,12 @@ class LoncapaProblem(object):
Obtain all responder answers and save as self.responder_answers dict (key = response)
Obtain all responder answers and save as self.responder_answers dict (key = response)
"""
"""
response_id
=
1
response_id
=
1
problem_data
=
{}
self
.
responders
=
{}
self
.
responders
=
{}
for
response
in
tree
.
xpath
(
'//'
+
"|//"
.
join
(
responsetypes
.
registry
.
registered_tags
())):
for
response
in
tree
.
xpath
(
'//'
+
"|//"
.
join
(
responsetypes
.
registry
.
registered_tags
())):
response_id_str
=
self
.
problem_id
+
"_"
+
str
(
response_id
)
response_id_str
=
self
.
problem_id
+
"_"
+
str
(
response_id
)
# create and save ID for this response
# create and save ID for this response
response
.
set
(
'id'
,
response_id_str
)
response
.
set
(
'id'
,
response_id_str
)
response_id
+=
1
answer_id
=
1
answer_id
=
1
input_tags
=
inputtypes
.
registry
.
registered_tags
()
input_tags
=
inputtypes
.
registry
.
registered_tags
()
...
@@ -857,11 +861,25 @@ class LoncapaProblem(object):
...
@@ -857,11 +861,25 @@ class LoncapaProblem(object):
entry
.
attrib
[
'id'
]
=
"
%
s_
%
i_
%
i"
%
(
self
.
problem_id
,
response_id
,
answer_id
)
entry
.
attrib
[
'id'
]
=
"
%
s_
%
i_
%
i"
%
(
self
.
problem_id
,
response_id
,
answer_id
)
answer_id
=
answer_id
+
1
answer_id
=
answer_id
+
1
p_ids
=
[]
for
p_index
,
p_element
in
enumerate
(
response
.
findall
(
'.//p'
)):
p_tag_id
=
'{}_q{}_desc{}'
.
format
(
self
.
problem_id
,
response_id
,
p_index
)
p_element
.
attrib
[
'id'
]
=
p_tag_id
p_ids
.
append
(
p_tag_id
)
# Find the label and save it for html transformation step
responsetype_label
=
response
.
find
(
'label'
)
problem_data
[
response_id_str
]
=
{
'label'
:
responsetype_label
.
text
if
responsetype_label
is
not
None
else
''
,
'p_ids'
:
p_ids
}
# instantiate capa Response
# instantiate capa Response
responsetype_cls
=
responsetypes
.
registry
.
get_class_for_tag
(
response
.
tag
)
responsetype_cls
=
responsetypes
.
registry
.
get_class_for_tag
(
response
.
tag
)
responder
=
responsetype_cls
(
response
,
inputfields
,
self
.
context
,
self
.
capa_system
,
self
.
capa_module
)
responder
=
responsetype_cls
(
response
,
inputfields
,
self
.
context
,
self
.
capa_system
,
self
.
capa_module
)
# save in list in self
# save in list in self
self
.
responders
[
response
]
=
responder
self
.
responders
[
response
]
=
responder
response_id
+=
1
# get responder answers (do this only once, since there may be a performance cost,
# get responder answers (do this only once, since there may be a performance cost,
# eg with externalresponse)
# eg with externalresponse)
...
@@ -881,3 +899,5 @@ class LoncapaProblem(object):
...
@@ -881,3 +899,5 @@ class LoncapaProblem(object):
for
solution
in
tree
.
findall
(
'.//solution'
):
for
solution
in
tree
.
findall
(
'.//solution'
):
solution
.
attrib
[
'id'
]
=
"
%
s_solution_
%
i"
%
(
self
.
problem_id
,
solution_id
)
solution
.
attrib
[
'id'
]
=
"
%
s_solution_
%
i"
%
(
self
.
problem_id
,
solution_id
)
solution_id
+=
1
solution_id
+=
1
return
problem_data
common/lib/capa/capa/inputtypes.py
View file @
6dccdbe3
...
@@ -225,6 +225,7 @@ class InputTypeBase(object):
...
@@ -225,6 +225,7 @@ class InputTypeBase(object):
self
.
hintmode
=
feedback
.
get
(
'hintmode'
,
None
)
self
.
hintmode
=
feedback
.
get
(
'hintmode'
,
None
)
self
.
input_state
=
state
.
get
(
'input_state'
,
{})
self
.
input_state
=
state
.
get
(
'input_state'
,
{})
self
.
answervariable
=
state
.
get
(
"answervariable"
,
None
)
self
.
answervariable
=
state
.
get
(
"answervariable"
,
None
)
self
.
response_data
=
state
.
get
(
"response_data"
,
None
)
# put hint above msg if it should be displayed
# put hint above msg if it should be displayed
if
self
.
hintmode
==
'always'
:
if
self
.
hintmode
==
'always'
:
...
@@ -317,6 +318,7 @@ class InputTypeBase(object):
...
@@ -317,6 +318,7 @@ class InputTypeBase(object):
'status'
:
Status
(
self
.
status
,
self
.
capa_system
.
i18n
.
ugettext
),
'status'
:
Status
(
self
.
status
,
self
.
capa_system
.
i18n
.
ugettext
),
'msg'
:
self
.
msg
,
'msg'
:
self
.
msg
,
'STATIC_URL'
:
self
.
capa_system
.
STATIC_URL
,
'STATIC_URL'
:
self
.
capa_system
.
STATIC_URL
,
'response_data'
:
self
.
response_data
}
}
context
.
update
(
context
.
update
(
(
a
,
v
)
for
(
a
,
v
)
in
self
.
loaded_attributes
.
iteritems
()
if
a
in
self
.
to_render
(
a
,
v
)
for
(
a
,
v
)
in
self
.
loaded_attributes
.
iteritems
()
if
a
in
self
.
to_render
...
...
common/lib/capa/capa/templates/choicegroup.html
View file @
6dccdbe3
<form
class=
"choicegroup capa_inputtype"
id=
"inputtype_${id}"
>
<form
class=
"choicegroup capa_inputtype"
id=
"inputtype_${id}"
>
<fieldset
role=
"${input_type}group"
aria-label=
"${label}"
>
<fieldset
role=
"${input_type}group"
aria-label=
"${label}"
>
% if response_data['label']:
<legend
id=
"${id}-legend"
class=
"response-fieldset-legend"
>
${response_data['label']}
</legend>
% endif
% for choice_id, choice_description in choices:
% for choice_id, choice_description in choices:
<label
for=
"input_${id}_${choice_id}"
<label
for=
"input_${id}_${choice_id}"
##
If
the
student
has
selected
this
choice
...
##
If
the
student
has
selected
this
choice
...
...
@@ -14,7 +17,7 @@
...
@@ -14,7 +17,7 @@
else:
else:
correctness =
None
correctness =
None
%
>
%
>
% if correctness and not show_correctness
==
'never':
% if correctness and not show_correctness
==
'never':
class="choicegroup_${correctness}"
class="choicegroup_${correctness}"
% endif
% endif
% endif
% endif
...
...
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