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
0319dc94
Commit
0319dc94
authored
Nov 02, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync answer, correctness, hint, so they all save at the same time
parent
1e6ddec4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
11 deletions
+30
-11
common/lib/xmodule/xmodule/self_assessment_module.py
+30
-11
No files found.
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
0319dc94
...
@@ -94,10 +94,11 @@ class SelfAssessmentModule(XModule):
...
@@ -94,10 +94,11 @@ class SelfAssessmentModule(XModule):
self
.
score
=
0
self
.
score
=
0
self
.
top_score
=
1
self
.
top_score
=
1
self
.
attempts
=
0
self
.
attempts
=
0
self
.
correctness
=
"incorrect"
self
.
correctness
=
[]
self
.
done
=
False
self
.
done
=
False
self
.
max_attempts
=
self
.
metadata
.
get
(
'attempts'
,
None
)
self
.
max_attempts
=
self
.
metadata
.
get
(
'attempts'
,
None
)
self
.
hint
=
""
self
.
hint
=
[]
self
.
temp_answer
=
""
#Try setting maxattempts, use default if not available in metadata
#Try setting maxattempts, use default if not available in metadata
if
self
.
max_attempts
is
not
None
:
if
self
.
max_attempts
is
not
None
:
...
@@ -123,13 +124,23 @@ class SelfAssessmentModule(XModule):
...
@@ -123,13 +124,23 @@ class SelfAssessmentModule(XModule):
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'
]
if
instance_state
is
not
None
and
'temp_answer'
in
instance_state
:
self
.
temp_answer
=
instance_state
[
'temp_answer'
]
if
instance_state
is
not
None
and
'hint'
in
instance_state
:
if
instance_state
is
not
None
and
'hint'
in
instance_state
:
self
.
hint
=
instance_state
[
'hint'
]
if
(
type
(
instance_state
[
'hint'
])
in
[
type
(
u''
),
type
(
''
)]):
self
.
hint
.
append
(
instance_state
[
'hint'
])
elif
(
type
(
instance_state
[
'hint'
])
==
type
([])):
self
.
hint
=
instance_state
[
'hint'
]
if
instance_state
is
not
None
and
'correct_map'
in
instance_state
:
if
instance_state
is
not
None
and
'correct_map'
in
instance_state
:
if
'self_assess'
in
instance_state
[
'correct_map'
]:
if
'self_assess'
in
instance_state
[
'correct_map'
]:
self
.
score
=
instance_state
[
'correct_map'
][
'self_assess'
][
'npoints'
]
self
.
score
=
instance_state
[
'correct_map'
][
'self_assess'
][
'npoints'
]
self
.
correctness
=
instance_state
[
'correct_map'
][
'self_assess'
][
'correctness'
]
map_correctness
=
instance_state
[
'correct_map'
][
'self_assess'
][
'correctness'
]
if
(
type
(
map_correctness
)
in
[
type
(
u''
),
type
(
''
)]):
self
.
correctness
.
append
(
map_correctness
)
elif
(
type
(
map_correctness
)
==
type
([])):
self
.
correctness
=
map_correctness
#Parse definition file
#Parse definition file
dom2
=
etree
.
fromstring
(
"<selfassessment>"
+
self
.
definition
[
'data'
]
+
"</selfassessment>"
)
dom2
=
etree
.
fromstring
(
"<selfassessment>"
+
self
.
definition
[
'data'
]
+
"</selfassessment>"
)
...
@@ -237,7 +248,9 @@ class SelfAssessmentModule(XModule):
...
@@ -237,7 +248,9 @@ 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
.
append
(
get
.
keys
()[
0
])
#Dump to temp to keep answer in sync with correctness and hint
self
.
temp_answer
=
get
.
keys
()[
0
]
log
.
debug
(
self
.
temp_answer
)
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
else
:
else
:
return
{
'success'
:
False
,
'message'
:
'Too many attempts.'
}
return
{
'success'
:
False
,
'message'
:
'Too many attempts.'
}
...
@@ -249,12 +262,17 @@ class SelfAssessmentModule(XModule):
...
@@ -249,12 +262,17 @@ class SelfAssessmentModule(XModule):
with the error key only present if success is False.
with the error key only present if success is False.
'''
'''
#Extract correctness from ajax and assign points
#Temp answer check is to keep hints, correctness, and answer in sync
self
.
hint
=
get
[
get
.
keys
()[
1
]]
points
=
0
self
.
correctness
=
get
[
get
.
keys
()[
0
]]
.
lower
()
log
.
debug
(
self
.
temp_answer
)
points
=
0
if
self
.
temp_answer
is
not
""
:
if
self
.
correctness
==
"correct"
:
#Extract correctness and hint from ajax and assign points
points
=
1
self
.
hint
.
append
(
get
[
get
.
keys
()[
1
]])
curr_correctness
=
get
[
get
.
keys
()[
0
]]
.
lower
()
if
curr_correctness
==
"correct"
:
points
=
1
self
.
correctness
.
append
(
curr_correctness
)
self
.
answer
.
append
(
self
.
temp_answer
)
#Student is done, and increment attempts
#Student is done, and increment attempts
self
.
done
=
True
self
.
done
=
True
...
@@ -291,6 +309,7 @@ class SelfAssessmentModule(XModule):
...
@@ -291,6 +309,7 @@ class SelfAssessmentModule(XModule):
state
=
{
'seed'
:
1
,
state
=
{
'seed'
:
1
,
'student_answers'
:
self
.
answer
,
'student_answers'
:
self
.
answer
,
'temp_answer'
:
self
.
temp_answer
,
'hint'
:
self
.
hint
,
'hint'
:
self
.
hint
,
'correct_map'
:
{
'self_assess'
:
{
'correctness'
:
self
.
correctness
,
'correct_map'
:
{
'self_assess'
:
{
'correctness'
:
self
.
correctness
,
'npoints'
:
points
,
'npoints'
:
points
,
...
...
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