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
dcd52801
Commit
dcd52801
authored
Nov 27, 2012
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
case when user sends less than 3 points, and tests for this case
parent
01b59923
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
+15
-1
common/lib/capa/capa/chem/miller.py
+15
-1
No files found.
common/lib/capa/capa/chem/miller.py
View file @
dcd52801
...
@@ -253,13 +253,15 @@ def grade(user_input, correct_answer):
...
@@ -253,13 +253,15 @@ def grade(user_input, correct_answer):
points
=
[
map
(
float
,
p
)
for
p
in
user_answer
[
'points'
]]
points
=
[
map
(
float
,
p
)
for
p
in
user_answer
[
'points'
]]
if
len
(
points
)
<
3
:
return
False
# round point to closes 0.05 value
# round point to closes 0.05 value
points
=
[
round0_25
(
point
)
for
point
in
points
]
points
=
[
round0_25
(
point
)
for
point
in
points
]
points
=
[
np
.
array
(
point
)
for
point
in
points
]
points
=
[
np
.
array
(
point
)
for
point
in
points
]
# print miller(points), (correct_answer['miller'].replace(' ', ''),
# print miller(points), (correct_answer['miller'].replace(' ', ''),
# negative(correct_answer['miller']).replace(' ', ''))
# negative(correct_answer['miller']).replace(' ', ''))
if
miller
(
points
)
in
(
correct_answer
[
'miller'
]
.
replace
(
' '
,
''
),
negative
(
correct_answer
[
'miller'
])
.
replace
(
' '
,
''
)):
if
miller
(
points
)
in
(
correct_answer
[
'miller'
]
.
replace
(
' '
,
''
),
negative
(
correct_answer
[
'miller'
])
.
replace
(
' '
,
''
)):
return
True
return
True
...
@@ -269,6 +271,18 @@ def grade(user_input, correct_answer):
...
@@ -269,6 +271,18 @@ def grade(user_input, correct_answer):
class
Test_Crystallography_Miller
(
unittest
.
TestCase
):
class
Test_Crystallography_Miller
(
unittest
.
TestCase
):
''' Tests for crystallography grade function.'''
''' Tests for crystallography grade function.'''
def
test_empty_points
(
self
):
user_input
=
'{"lattice": "bcc", "points": []}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_only_one_point
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"]]}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_only_two_points
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.00", "0.50", "0.00"]]}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_1
(
self
):
def
test_1
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.00", "0.50", "0.00"], ["0.00", "0.00", "0.50"]]}'
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.00", "0.50", "0.00"], ["0.00", "0.00", "0.50"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
...
...
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