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
bd6d1531
Commit
bd6d1531
authored
Jan 18, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing self-assessment unit tests
parent
7ac36d2f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
22 deletions
+30
-22
common/lib/xmodule/xmodule/tests/test_import.py
+0
-13
common/lib/xmodule/xmodule/tests/test_self_assessment.py
+30
-9
No files found.
common/lib/xmodule/xmodule/tests/test_import.py
View file @
bd6d1531
...
@@ -339,19 +339,6 @@ class ImportTestCase(unittest.TestCase):
...
@@ -339,19 +339,6 @@ class ImportTestCase(unittest.TestCase):
self
.
assertRaises
(
etree
.
XMLSyntaxError
,
system
.
process_xml
,
bad_xml
)
self
.
assertRaises
(
etree
.
XMLSyntaxError
,
system
.
process_xml
,
bad_xml
)
def
test_selfassessment_import
(
self
):
'''
Check to see if definition_from_xml in self_assessment_module.py
works properly. Pulls data from the self_assessment directory in the test data directory.
'''
modulestore
=
XMLModuleStore
(
DATA_DIR
,
course_dirs
=
[
'self_assessment'
])
sa_id
=
"edX/sa_test/2012_Fall"
location
=
Location
([
"i4x"
,
"edX"
,
"sa_test"
,
"selfassessment"
,
"SampleQuestion"
])
sa_sample
=
modulestore
.
get_instance
(
sa_id
,
location
)
#10 attempts is hard coded into SampleQuestion, which is the url_name of a selfassessment xml tag
self
.
assertEqual
(
sa_sample
.
metadata
[
'attempts'
],
'10'
)
def
test_graphicslidertool_import
(
self
):
def
test_graphicslidertool_import
(
self
):
'''
'''
...
...
common/lib/xmodule/xmodule/tests/test_self_assessment.py
View file @
bd6d1531
...
@@ -4,8 +4,11 @@ import unittest
...
@@ -4,8 +4,11 @@ import unittest
from
xmodule.self_assessment_module
import
SelfAssessmentModule
from
xmodule.self_assessment_module
import
SelfAssessmentModule
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
lxml
import
etree
import
logging
from
.
import
test_system
from
.
import
test_system
log
=
logging
.
getLogger
(
"mitx.courseware"
)
class
SelfAssessmentTest
(
unittest
.
TestCase
):
class
SelfAssessmentTest
(
unittest
.
TestCase
):
...
@@ -26,22 +29,40 @@ class SelfAssessmentTest(unittest.TestCase):
...
@@ -26,22 +29,40 @@ class SelfAssessmentTest(unittest.TestCase):
state
=
json
.
dumps
({
'student_answers'
:
[
"Answer 1"
,
"answer 2"
,
"answer 3"
],
state
=
json
.
dumps
({
'student_answers'
:
[
"Answer 1"
,
"answer 2"
,
"answer 3"
],
'scores'
:
[
0
,
1
],
'scores'
:
[
0
,
1
],
'hints'
:
[
'o hai'
],
'hints'
:
[
'o hai'
],
'state'
:
SelfAssessmentModule
.
ASSESSING
,
'state'
:
SelfAssessmentModule
.
INITIAL
,
'attempts'
:
2
})
'attempts'
:
2
})
rubric
=
'''<rubric><rubric>
<category>
<description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option>
</category>
</rubric></rubric>'''
prompt
=
etree
.
XML
(
"<prompt>Text</prompt>"
)
static_data
=
{
'max_attempts'
:
10
,
'rubric'
:
etree
.
XML
(
rubric
),
'prompt'
:
prompt
,
'max_score'
:
1
}
module
=
SelfAssessmentModule
(
test_system
,
self
.
location
,
module
=
SelfAssessmentModule
(
test_system
,
self
.
location
,
self
.
definition
,
self
.
descriptor
,
self
.
definition
,
self
.
descriptor
,
stat
e
,
{}
,
metadata
=
self
.
metadata
)
stat
ic_data
,
state
,
metadata
=
self
.
metadata
)
self
.
assertEqual
(
module
.
get_score
()[
'score'
],
0
)
self
.
assertEqual
(
module
.
get_score
()[
'score'
],
0
)
self
.
assertTrue
(
'answer 3'
in
module
.
get_html
())
html
=
module
.
get_html
(
test_system
)
self
.
assertFalse
(
'answer 2'
in
module
.
get_html
())
log
.
debug
(
"rendered html: {0}"
.
format
(
html
))
module
.
save_a
ssessment
({
'assessment'
:
'0'
}
)
module
.
save_a
nswer
({
'student_answer'
:
"I am an answer"
},
test_system
)
self
.
assertEqual
(
module
.
state
,
module
.
REQUEST_HINT
)
self
.
assertEqual
(
module
.
state
,
module
.
ASSESSING
)
module
.
save_hint
({
'hint'
:
'hint for ans 3'
})
module
.
save_assessment
({
'assessment'
:
'0'
},
test_system
)
self
.
assertEqual
(
module
.
state
,
module
.
POST_ASSESSMENT
)
module
.
save_hint
({
'hint'
:
'this is a hint'
},
test_system
)
self
.
assertEqual
(
module
.
state
,
module
.
DONE
)
self
.
assertEqual
(
module
.
state
,
module
.
DONE
)
d
=
module
.
reset
({})
d
=
module
.
reset
({})
...
@@ -49,6 +70,6 @@ class SelfAssessmentTest(unittest.TestCase):
...
@@ -49,6 +70,6 @@ class SelfAssessmentTest(unittest.TestCase):
self
.
assertEqual
(
module
.
state
,
module
.
INITIAL
)
self
.
assertEqual
(
module
.
state
,
module
.
INITIAL
)
# if we now assess as right, skip the REQUEST_HINT state
# if we now assess as right, skip the REQUEST_HINT state
module
.
save_answer
({
'student_answer'
:
'answer 4'
})
module
.
save_answer
({
'student_answer'
:
'answer 4'
}
,
test_system
)
module
.
save_assessment
({
'assessment'
:
'1'
})
module
.
save_assessment
({
'assessment'
:
'1'
}
,
test_system
)
self
.
assertEqual
(
module
.
state
,
module
.
DONE
)
self
.
assertEqual
(
module
.
state
,
module
.
DONE
)
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