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
331806f1
Commit
331806f1
authored
Mar 11, 2013
by
John Hess
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1646 from MITx/feature/jkarni/folditx
Feature/jkarni/folditx
parents
894f9171
ad92eb4d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
common/lib/xmodule/xmodule/foldit_module.py
+4
-1
lms/djangoapps/foldit/models.py
+1
-1
lms/djangoapps/foldit/tests.py
+10
-5
No files found.
common/lib/xmodule/xmodule/foldit_module.py
View file @
331806f1
...
@@ -86,7 +86,10 @@ class FolditModule(XModule):
...
@@ -86,7 +86,10 @@ class FolditModule(XModule):
"""
"""
from
foldit.models
import
Score
from
foldit.models
import
Score
return
[(
e
[
'username'
],
e
[
'score'
])
for
e
in
Score
.
get_tops_n
(
10
)]
leaders
=
[(
e
[
'username'
],
e
[
'score'
])
for
e
in
Score
.
get_tops_n
(
10
)]
leaders
.
sort
(
key
=
lambda
x
:
x
[
1
])
return
leaders
def
get_html
(
self
):
def
get_html
(
self
):
"""
"""
...
...
lms/djangoapps/foldit/models.py
View file @
331806f1
...
@@ -59,7 +59,7 @@ class Score(models.Model):
...
@@ -59,7 +59,7 @@ class Score(models.Model):
scores
=
Score
.
objects
\
scores
=
Score
.
objects
\
.
filter
(
puzzle_id__in
=
puzzles
)
\
.
filter
(
puzzle_id__in
=
puzzles
)
\
.
annotate
(
total_score
=
models
.
Sum
(
'best_score'
))
\
.
annotate
(
total_score
=
models
.
Sum
(
'best_score'
))
\
.
order_by
(
'
-
total_score'
)[:
n
]
.
order_by
(
'total_score'
)[:
n
]
num
=
len
(
puzzles
)
num
=
len
(
puzzles
)
return
[{
'username'
:
s
.
user
.
username
,
return
[{
'username'
:
s
.
user
.
username
,
...
...
lms/djangoapps/foldit/tests.py
View file @
331806f1
...
@@ -143,11 +143,12 @@ class FolditTestCase(TestCase):
...
@@ -143,11 +143,12 @@ class FolditTestCase(TestCase):
def
test_SetPlayerPuzzleScores_manyplayers
(
self
):
def
test_SetPlayerPuzzleScores_manyplayers
(
self
):
"""
"""
Check that when we send scores from multiple users, the correct order
Check that when we send scores from multiple users, the correct order
of scores is displayed.
of scores is displayed. Note that, before being processed by
display_score, lower scores are better.
"""
"""
puzzle_id
=
[
'1'
]
puzzle_id
=
[
'1'
]
player1_score
=
0.0
7
player1_score
=
0.0
8
player2_score
=
0.0
8
player2_score
=
0.0
2
response1
=
self
.
make_puzzle_score_request
(
puzzle_id
,
player1_score
,
response1
=
self
.
make_puzzle_score_request
(
puzzle_id
,
player1_score
,
self
.
user
)
self
.
user
)
...
@@ -164,8 +165,12 @@ class FolditTestCase(TestCase):
...
@@ -164,8 +165,12 @@ class FolditTestCase(TestCase):
self
.
assertEqual
(
len
(
top_10
),
2
)
self
.
assertEqual
(
len
(
top_10
),
2
)
# Top score should be player2_score. Second should be player1_score
# Top score should be player2_score. Second should be player1_score
self
.
assertEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
player2_score
))
self
.
assertAlmostEqual
(
top_10
[
0
][
'score'
],
self
.
assertEqual
(
top_10
[
1
][
'score'
],
Score
.
display_score
(
player1_score
))
Score
.
display_score
(
player2_score
),
delta
=
0.5
)
self
.
assertAlmostEqual
(
top_10
[
1
][
'score'
],
Score
.
display_score
(
player1_score
),
delta
=
0.5
)
# Top score user should be self.user2.username
# Top score user should be self.user2.username
self
.
assertEqual
(
top_10
[
0
][
'username'
],
self
.
user2
.
username
)
self
.
assertEqual
(
top_10
[
0
][
'username'
],
self
.
user2
.
username
)
...
...
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