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
4c0cc81d
Commit
4c0cc81d
authored
May 07, 2012
by
Lyla Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests
parent
ca89ce73
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
djangoapps/courseware/test_files/multichoice.xml
+21
-0
djangoapps/courseware/test_files/truefalse.xml
+21
-0
djangoapps/courseware/tests.py
+25
-0
No files found.
djangoapps/courseware/test_files/multichoice.xml
0 → 100644
View file @
4c0cc81d
<problem>
<multiplechoiceresponse
max=
"10"
randomize=
"yes"
>
<choicegroup>
<choice
location=
"random"
correct=
"false"
name=
"foil1"
>
<startouttext
/>
This is foil One.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"false"
name=
"foil2"
>
<startouttext
/>
This is foil Two.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"true"
name=
"foil3"
>
<startouttext
/>
This is foil Three.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"false"
name=
"foil4"
>
<startouttext
/>
This is foil Four.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"false"
name=
"foil5"
>
<startouttext
/>
This is foil Five.
<endouttext
/>
</choice>
</choicegroup>
</multiplechoiceresponse>
</problem>
djangoapps/courseware/test_files/truefalse.xml
0 → 100644
View file @
4c0cc81d
<problem>
<truefalseresponse
max=
"10"
randomize=
"yes"
>
<choicegroup>
<choice
location=
"random"
correct=
"true"
name=
"foil1"
>
<startouttext
/>
This is foil One.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"true"
name=
"foil2"
>
<startouttext
/>
This is foil Two.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"false"
name=
"foil3"
>
<startouttext
/>
This is foil Three.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"false"
name=
"foil4"
>
<startouttext
/>
This is foil Four.
<endouttext
/>
</choice>
<choice
location=
"random"
correct=
"false"
name=
"foil5"
>
<startouttext
/>
This is foil Five.
<endouttext
/>
</choice>
</choicegroup>
</truefalseresponse>
</problem>
djangoapps/courseware/tests.py
View file @
4c0cc81d
import
unittest
import
os
import
numpy
import
courseware.modules
import
courseware.capa.calc
as
calc
import
courseware.capa.capa_problem
as
lcp
from
grades
import
Score
,
aggregate_scores
class
ModelsTest
(
unittest
.
TestCase
):
...
...
@@ -59,6 +61,29 @@ class ModelsTest(unittest.TestCase):
exception_happened
=
True
self
.
assertTrue
(
exception_happened
)
class
MultiChoiceTest
(
unittest
.
TestCase
):
def
test_MC_grade
(
self
):
multichoice_file
=
os
.
getcwd
()
+
"/djangoapps/courseware/test_files/multichoice.xml"
test_lcp
=
lcp
.
LoncapaProblem
(
multichoice_file
,
'1'
)
correct_answers
=
{
'1_2_1'
:
'foil3'
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)[
'1_2_1'
],
'correct'
)
false_answers
=
{
'1_2_1'
:
'foil2'
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)[
'1_2_1'
],
'incorrect'
)
def
test_TF_grade
(
self
):
truefalse_file
=
os
.
getcwd
()
+
"/djangoapps/courseware/test_files/truefalse.xml"
test_lcp
=
lcp
.
LoncapaProblem
(
truefalse_file
,
'1'
)
correct_answers
=
{
'1_2_1'
:[
'foil2'
,
'foil1'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)[
'1_2_1'
],
'correct'
)
false_answers
=
{
'1_2_1'
:[
'foil1'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)[
'1_2_1'
],
'incorrect'
)
false_answers
=
{
'1_2_1'
:[
'foil1'
,
'foil3'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)[
'1_2_1'
],
'incorrect'
)
false_answers
=
{
'1_2_1'
:[
'foil3'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)[
'1_2_1'
],
'incorrect'
)
false_answers
=
{
'1_2_1'
:[
'foil1'
,
'foil2'
,
'foil3'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)[
'1_2_1'
],
'incorrect'
)
class
GraderTest
(
unittest
.
TestCase
):
def
test_weighted_grading
(
self
):
...
...
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