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
4b58cb95
Commit
4b58cb95
authored
Nov 28, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix attempt tracking, fix test
- increments attempts on any transition to DONE state
parent
0a1b731d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
common/lib/xmodule/xmodule/self_assessment_module.py
+18
-8
common/lib/xmodule/xmodule/tests/test_self_assessment.py
+1
-1
No files found.
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
4b58cb95
...
...
@@ -160,6 +160,19 @@ class SelfAssessmentModule(XModule):
self
.
history
[
-
1
][
'hint'
]
=
hint
def
change_state
(
self
,
new_state
):
"""
A centralized place for state changes--allows for hooks. If the
current state matches the old state, don't run any hooks.
"""
if
self
.
state
==
new_state
:
return
self
.
state
=
new_state
if
self
.
state
==
self
.
DONE
:
self
.
attempts
+=
1
@staticmethod
def
convert_state_to_current_format
(
old_state
):
"""
...
...
@@ -376,7 +389,7 @@ class SelfAssessmentModule(XModule):
# add new history element with answer and empty score and hint.
self
.
new_history_entry
(
get
[
'student_answer'
])
self
.
state
=
self
.
ASSESSING
self
.
change_state
(
self
.
ASSESSING
)
return
{
'success'
:
True
,
...
...
@@ -411,11 +424,11 @@ class SelfAssessmentModule(XModule):
d
=
{
'success'
:
True
,}
if
score
==
self
.
max_score
():
self
.
state
=
self
.
DONE
self
.
change_state
(
self
.
DONE
)
d
[
'message_html'
]
=
self
.
get_message_html
()
d
[
'allow_reset'
]
=
self
.
_allow_reset
()
else
:
self
.
state
=
self
.
REQUEST_HINT
self
.
change_state
(
self
.
REQUEST_HINT
)
d
[
'hint_html'
]
=
self
.
get_hint_html
()
d
[
'state'
]
=
self
.
state
...
...
@@ -438,10 +451,7 @@ class SelfAssessmentModule(XModule):
return
self
.
out_of_sync_error
(
get
)
self
.
record_latest_hint
(
get
[
'hint'
])
self
.
state
=
self
.
DONE
# increment attempts
self
.
attempts
=
self
.
attempts
+
1
self
.
change_state
(
self
.
DONE
)
# To the tracking logs!
event_info
=
{
...
...
@@ -473,7 +483,7 @@ class SelfAssessmentModule(XModule):
'success'
:
False
,
'error'
:
'Too many attempts.'
}
self
.
state
=
self
.
INITIAL
self
.
change_state
(
self
.
INITIAL
)
return
{
'success'
:
True
}
...
...
common/lib/xmodule/xmodule/tests/test_self_assessment.py
View file @
4b58cb95
...
...
@@ -33,7 +33,7 @@ class SelfAssessmentTest(unittest.TestCase):
self
.
definition
,
self
.
descriptor
,
state
,
{},
metadata
=
self
.
metadata
)
self
.
assertEqual
(
module
.
get_score
(),
0
)
self
.
assertEqual
(
module
.
get_score
()
[
'score'
]
,
0
)
self
.
assertTrue
(
'answer 3'
in
module
.
get_html
())
self
.
assertFalse
(
'answer 2'
in
module
.
get_html
())
...
...
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