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
9d0dd4bb
Commit
9d0dd4bb
authored
Jul 24, 2015
by
Peter Fogg
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9034 from edx/peter-fogg/round-grades
WIP: Display rounded problem results.
parents
a66d4e48
814cc568
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
common/lib/xmodule/xmodule/progress.py
+5
-2
common/lib/xmodule/xmodule/tests/test_progress.py
+3
-0
No files found.
common/lib/xmodule/xmodule/progress.py
View file @
9d0dd4bb
...
@@ -116,12 +116,15 @@ class Progress(object):
...
@@ -116,12 +116,15 @@ class Progress(object):
return
not
self
.
__eq__
(
other
)
return
not
self
.
__eq__
(
other
)
def
__str__
(
self
):
def
__str__
(
self
):
''' Return a string representation of this string.
'''Return a string representation of this string. Rounds results to
two decimal places, stripping out any trailing zeroes.
subclassing note: implemented in terms of frac().
subclassing note: implemented in terms of frac().
'''
'''
(
a
,
b
)
=
self
.
frac
()
(
a
,
b
)
=
self
.
frac
()
return
"{0}/{1}"
.
format
(
a
,
b
)
display
=
lambda
n
:
'{:.2f}'
.
format
(
n
)
.
rstrip
(
'0'
)
.
rstrip
(
'.'
)
return
"{0}/{1}"
.
format
(
display
(
a
),
display
(
b
))
@staticmethod
@staticmethod
def
add_counts
(
a
,
b
):
def
add_counts
(
a
,
b
):
...
...
common/lib/xmodule/xmodule/tests/test_progress.py
View file @
9d0dd4bb
...
@@ -81,6 +81,9 @@ class ProgressTest(unittest.TestCase):
...
@@ -81,6 +81,9 @@ class ProgressTest(unittest.TestCase):
self
.
assertEqual
(
str
(
self
.
not_started
),
"0/17"
)
self
.
assertEqual
(
str
(
self
.
not_started
),
"0/17"
)
self
.
assertEqual
(
str
(
self
.
part_done
),
"2/6"
)
self
.
assertEqual
(
str
(
self
.
part_done
),
"2/6"
)
self
.
assertEqual
(
str
(
self
.
done
),
"7/7"
)
self
.
assertEqual
(
str
(
self
.
done
),
"7/7"
)
self
.
assertEqual
(
str
(
Progress
(
2.1234
,
7
)),
'2.12/7'
)
self
.
assertEqual
(
str
(
Progress
(
2.0034
,
7
)),
'2/7'
)
self
.
assertEqual
(
str
(
Progress
(
0.999
,
7
)),
'1/7'
)
def
test_ternary_str
(
self
):
def
test_ternary_str
(
self
):
self
.
assertEqual
(
self
.
not_started
.
ternary_str
(),
"none"
)
self
.
assertEqual
(
self
.
not_started
.
ternary_str
(),
"none"
)
...
...
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