Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
814cc568
Commit
814cc568
authored
9 years ago
by
Peter Fogg
Browse files
Options
Downloads
Patches
Plain Diff
Display rounded problem results.
parent
ac0d7962
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/progress.py
+5
-2
5 additions, 2 deletions
common/lib/xmodule/xmodule/progress.py
common/lib/xmodule/xmodule/tests/test_progress.py
+3
-0
3 additions, 0 deletions
common/lib/xmodule/xmodule/tests/test_progress.py
with
8 additions
and
2 deletions
common/lib/xmodule/xmodule/progress.py
+
5
−
2
View file @
814cc568
...
...
@@ -116,12 +116,15 @@ class Progress(object):
return
not
self
.
__eq__
(
other
)
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().
'''
(
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
def
add_counts
(
a
,
b
):
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/tests/test_progress.py
+
3
−
0
View file @
814cc568
...
...
@@ -81,6 +81,9 @@ class ProgressTest(unittest.TestCase):
self
.
assertEqual
(
str
(
self
.
not_started
),
"
0/17
"
)
self
.
assertEqual
(
str
(
self
.
part_done
),
"
2/6
"
)
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
):
self
.
assertEqual
(
self
.
not_started
.
ternary_str
(),
"
none
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment