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
5a752dff
Commit
5a752dff
authored
Feb 01, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Got a basic, working graph of the scores
--HG-- branch : profiledev
parent
8712197d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
20 deletions
+47
-20
courseware/views.py
+47
-20
No files found.
courseware/views.py
View file @
5a752dff
...
...
@@ -47,7 +47,7 @@ def profile(request):
response_by_id
[
response
.
module_id
]
=
response
total
S
cores
=
{}
total
_s
cores
=
{}
for
c
in
chapters
:
chname
=
c
.
get
(
'name'
)
...
...
@@ -75,12 +75,12 @@ def profile(request):
graded_total
=
(
sum
([
score
[
0
]
for
score
in
scores
if
score
[
2
]]),
sum
([
score
[
1
]
for
score
in
scores
if
score
[
2
]]))
#Add the graded total to total
S
cores
#Add the graded total to total
_s
cores
format
=
s
.
get
(
'format'
)
if
s
.
get
(
'format'
)
else
""
if
format
and
graded_total
[
1
]
>
0
:
format_scores
=
total
Scores
[
format
]
if
format
in
totalS
cores
else
[]
format_scores
=
total
_scores
[
format
]
if
format
in
total_s
cores
else
[]
format_scores
.
append
(
graded_total
)
total
S
cores
[
format
]
=
format_scores
total
_s
cores
[
format
]
=
format_scores
score
=
{
'course'
:
course
,
'section'
:
s
.
get
(
"name"
),
...
...
@@ -92,29 +92,50 @@ def profile(request):
hw
.
append
(
score
)
def
totalWithDrops
(
scores
,
drop_count
):
sorted_scores
=
sorted
(
enumerate
(
scores
),
key
=
lambda
x
:
-
x
[
1
][
'percentage'
]
)
#Note that this key will sort the list descending
dropped_indices
=
[
score
[
0
]
for
score
in
sorted_scores
[
-
drop_count
:]]
# A list of the indices of the dropped scores
aggregate_score
=
0
for
index
,
score
in
enumerate
(
scores
):
if
index
not
in
dropped_indices
:
aggregate_score
+=
score
[
'percentage'
]
aggregate_score
/=
len
(
scores
)
-
drop_count
return
aggregate_score
,
dropped_indices
#Figure the homework scores
print
totalScores
homeworkScores
=
totalScores
[
'Homework'
]
if
'Homework'
in
totalScores
else
[]
homeworkPercentages
=
[]
homework_scores
=
total_scores
[
'Homework'
]
if
'Homework'
in
total_scores
else
[]
homework_percentages
=
[]
for
i
in
range
(
12
):
if
i
<
len
(
homeworkScores
):
percentage
=
homeworkScores
[
i
][
0
]
/
float
(
homeworkScores
[
i
][
1
])
if
i
<
len
(
homework_scores
):
percentage
=
homework_scores
[
i
][
0
]
/
float
(
homework_scores
[
i
][
1
])
summary
=
"{:.0
%
} ({}/{})"
.
format
(
percentage
,
homework_scores
[
i
][
0
],
homework_scores
[
i
][
1
]
)
else
:
percentage
=
0
homeworkPercentages
.
append
(
percentage
)
summary
=
"0
%
(?/?)"
summary
=
"Homework {} - {}"
.
format
(
i
+
1
,
summary
)
homework_percentages
.
append
(
{
'percentage'
:
percentage
,
'summary'
:
summary
}
)
homework_total
,
homework_dropped_indices
=
totalWithDrops
(
homework_percentages
,
2
)
labScores
=
totalScores
[
'Lab'
]
if
'Lab'
in
totalScores
else
[]
labPercentages
=
[]
#Figure the lab scores
lab_scores
=
total_scores
[
'Lab'
]
if
'Lab'
in
total_scores
else
[]
lab_percentages
=
[]
for
i
in
range
(
12
):
if
i
<
len
(
labScores
):
percentage
=
labScores
[
i
][
0
]
/
float
(
labScores
[
i
][
1
])
if
i
<
len
(
lab_scores
):
percentage
=
lab_scores
[
i
][
0
]
/
float
(
lab_scores
[
i
][
1
])
summary
=
"{:.0
%
} ({}/{})"
.
format
(
percentage
,
lab_scores
[
i
][
0
],
lab_scores
[
i
][
1
]
)
else
:
percentage
=
0
labPercentages
.
append
(
percentage
)
summary
=
"0
%
(?/?)"
summary
=
"Lab {} - {}"
.
format
(
i
+
1
,
summary
)
lab_percentages
.
append
(
{
'percentage'
:
percentage
,
'summary'
:
summary
}
)
lab_total
,
lab_dropped_indices
=
totalWithDrops
(
lab_percentages
,
2
)
midterm_score
=
(
130
,
150
)
final_score
=
(
225
,
300
)
user_info
=
UserProfile
.
objects
.
get
(
user
=
request
.
user
)
context
=
{
'name'
:
user_info
.
name
,
...
...
@@ -123,8 +144,14 @@ def profile(request):
'language'
:
user_info
.
language
,
'email'
:
request
.
user
.
email
,
'homeworks'
:
hw
,
'homework_percentages'
:
homeworkPercentages
,
'lab_percentages'
:
labPercentages
,
'homework_percentages'
:
homework_percentages
,
'homework_total'
:
homework_total
,
'homework_dropped_indices'
:
homework_dropped_indices
,
'lab_percentages'
:
lab_percentages
,
'lab_total'
:
lab_total
,
'lab_dropped_indices'
:
lab_dropped_indices
,
'midterm_score'
:
midterm_score
,
'final_score'
:
final_score
,
'csrf'
:
csrf
(
request
)[
'csrf_token'
]
}
return
render_to_response
(
'profile.html'
,
context
)
...
...
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