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
a60b914b
Commit
a60b914b
authored
Nov 02, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ability to store multiple answers
parent
52c971dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
common/lib/xmodule/xmodule/self_assessment_module.py
+19
-6
No files found.
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
a60b914b
...
@@ -69,7 +69,7 @@ class SelfAssessmentModule(XModule):
...
@@ -69,7 +69,7 @@ class SelfAssessmentModule(XModule):
instance_state
,
shared_state
,
**
kwargs
)
instance_state
,
shared_state
,
**
kwargs
)
"""
"""
Definition file should have
3 blocks -- problem, rubric, and submitmessage
Definition file should have
4 blocks -- problem, rubric, submitmessage, and maxattempts
Sample file:
Sample file:
<selfassessment>
<selfassessment>
...
@@ -82,11 +82,14 @@ class SelfAssessmentModule(XModule):
...
@@ -82,11 +82,14 @@ class SelfAssessmentModule(XModule):
<submitmessage>
<submitmessage>
Thanks for submitting!
Thanks for submitting!
</submitmessage>
</submitmessage>
<maxattempts>
1
</maxattempts>
</selfassessment>
</selfassessment>
"""
"""
#Initialize variables
#Initialize variables
self
.
answer
=
""
self
.
answer
=
[]
self
.
score
=
0
self
.
score
=
0
self
.
top_score
=
1
self
.
top_score
=
1
self
.
attempts
=
0
self
.
attempts
=
0
...
@@ -109,7 +112,10 @@ class SelfAssessmentModule(XModule):
...
@@ -109,7 +112,10 @@ class SelfAssessmentModule(XModule):
self
.
attempts
=
instance_state
[
'attempts'
]
self
.
attempts
=
instance_state
[
'attempts'
]
if
instance_state
is
not
None
and
'student_answers'
in
instance_state
:
if
instance_state
is
not
None
and
'student_answers'
in
instance_state
:
self
.
answer
=
instance_state
[
'student_answers'
]
if
(
type
(
instance_state
[
'student_answers'
])
in
[
type
(
u''
),
type
(
''
)]):
self
.
answer
=
self
.
answer
.
append
(
instance_state
[
'student_answers'
])
elif
(
type
(
instance_state
[
'student_answers'
])
==
type
([])):
self
.
answer
=
instance_state
[
'student_answers'
]
if
instance_state
is
not
None
and
'done'
in
instance_state
:
if
instance_state
is
not
None
and
'done'
in
instance_state
:
self
.
done
=
instance_state
[
'done'
]
self
.
done
=
instance_state
[
'done'
]
...
@@ -125,6 +131,13 @@ class SelfAssessmentModule(XModule):
...
@@ -125,6 +131,13 @@ class SelfAssessmentModule(XModule):
#Parse definition file
#Parse definition file
dom2
=
etree
.
fromstring
(
"<selfassessment>"
+
self
.
definition
[
'data'
]
+
"</selfassessment>"
)
dom2
=
etree
.
fromstring
(
"<selfassessment>"
+
self
.
definition
[
'data'
]
+
"</selfassessment>"
)
max_attempt_parsed
=
dom2
.
xpath
(
'maxattempts'
)[
0
]
.
text
try
:
self
.
max_attempts
=
int
(
max_attempt_parsed
)
except
:
pass
#Extract problem, submission message and rubric from definition file
#Extract problem, submission message and rubric from definition file
self
.
rubric
=
"<br/>"
+
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'rubric'
))])
self
.
rubric
=
"<br/>"
+
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'rubric'
))])
self
.
problem
=
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'problem'
))])
self
.
problem
=
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'problem'
))])
...
@@ -152,8 +165,8 @@ class SelfAssessmentModule(XModule):
...
@@ -152,8 +165,8 @@ class SelfAssessmentModule(XModule):
rubric_header
=
(
'<br/><br/><b>Rubric</b>'
)
rubric_header
=
(
'<br/><br/><b>Rubric</b>'
)
#Combine problem, rubric, and the forms
#Combine problem, rubric, and the forms
if
self
.
answer
is
not
""
:
if
type
(
self
.
answer
)
==
type
([])
and
self
.
answer
is
not
[]
:
answer_html
=
"<br/>Previous answer: {0}<br/>"
.
format
(
self
.
answer
)
answer_html
=
"<br/>Previous answer: {0}<br/>"
.
format
(
self
.
answer
[
len
(
self
.
answer
)
-
1
]
)
self
.
problem
=
''
.
join
([
self
.
problem
,
answer_html
,
problem_form
])
self
.
problem
=
''
.
join
([
self
.
problem
,
answer_html
,
problem_form
])
else
:
else
:
self
.
problem
=
''
.
join
([
self
.
problem
,
problem_form
])
self
.
problem
=
''
.
join
([
self
.
problem
,
problem_form
])
...
@@ -218,7 +231,7 @@ class SelfAssessmentModule(XModule):
...
@@ -218,7 +231,7 @@ class SelfAssessmentModule(XModule):
"""
"""
#Check to see if attempts are less than max
#Check to see if attempts are less than max
if
(
self
.
attempts
<
self
.
max_attempts
):
if
(
self
.
attempts
<
self
.
max_attempts
):
self
.
answer
=
get
.
keys
()[
0
]
self
.
answer
=
self
.
answer
.
append
(
get
.
keys
()[
0
])
log
.
debug
(
self
.
answer
)
log
.
debug
(
self
.
answer
)
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
else
:
else
:
...
...
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