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
fc73916e
Commit
fc73916e
authored
Sep 28, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed django.conf.settings dependency from graders.
parent
a99d7f7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
11 deletions
+8
-11
common/lib/xmodule/xmodule/graders.py
+7
-10
lms/djangoapps/courseware/grades.py
+1
-1
No files found.
common/lib/xmodule/xmodule/graders.py
View file @
fc73916e
...
@@ -6,8 +6,6 @@ import sys
...
@@ -6,8 +6,6 @@ import sys
from
collections
import
namedtuple
from
collections
import
namedtuple
from
django.conf
import
settings
log
=
logging
.
getLogger
(
"mitx.courseware"
)
log
=
logging
.
getLogger
(
"mitx.courseware"
)
# This is a tuple for holding scores, either from problems or sections.
# This is a tuple for holding scores, either from problems or sections.
...
@@ -187,7 +185,7 @@ class CourseGrader(object):
...
@@ -187,7 +185,7 @@ class CourseGrader(object):
__metaclass__
=
abc
.
ABCMeta
__metaclass__
=
abc
.
ABCMeta
@abc.abstractmethod
@abc.abstractmethod
def
grade
(
self
,
grade_sheet
):
def
grade
(
self
,
grade_sheet
,
generate_random_scores
=
False
):
raise
NotImplementedError
raise
NotImplementedError
...
@@ -207,13 +205,13 @@ class WeightedSubsectionsGrader(CourseGrader):
...
@@ -207,13 +205,13 @@ class WeightedSubsectionsGrader(CourseGrader):
def
__init__
(
self
,
sections
):
def
__init__
(
self
,
sections
):
self
.
sections
=
sections
self
.
sections
=
sections
def
grade
(
self
,
grade_sheet
):
def
grade
(
self
,
grade_sheet
,
generate_random_scores
=
False
):
total_percent
=
0.0
total_percent
=
0.0
section_breakdown
=
[]
section_breakdown
=
[]
grade_breakdown
=
[]
grade_breakdown
=
[]
for
subgrader
,
category
,
weight
in
self
.
sections
:
for
subgrader
,
category
,
weight
in
self
.
sections
:
subgrade_result
=
subgrader
.
grade
(
grade_sheet
)
subgrade_result
=
subgrader
.
grade
(
grade_sheet
,
generate_random_scores
)
weightedPercent
=
subgrade_result
[
'percent'
]
*
weight
weightedPercent
=
subgrade_result
[
'percent'
]
*
weight
section_detail
=
"{0} = {1:.1
%
} of a possible {2:.0
%
}"
.
format
(
category
,
weightedPercent
,
weight
)
section_detail
=
"{0} = {1:.1
%
} of a possible {2:.0
%
}"
.
format
(
category
,
weightedPercent
,
weight
)
...
@@ -240,7 +238,7 @@ class SingleSectionGrader(CourseGrader):
...
@@ -240,7 +238,7 @@ class SingleSectionGrader(CourseGrader):
self
.
short_label
=
short_label
or
name
self
.
short_label
=
short_label
or
name
self
.
category
=
category
or
name
self
.
category
=
category
or
name
def
grade
(
self
,
grade_sheet
):
def
grade
(
self
,
grade_sheet
,
generate_random_scores
=
False
):
foundScore
=
None
foundScore
=
None
if
self
.
type
in
grade_sheet
:
if
self
.
type
in
grade_sheet
:
for
score
in
grade_sheet
[
self
.
type
]:
for
score
in
grade_sheet
[
self
.
type
]:
...
@@ -248,7 +246,7 @@ class SingleSectionGrader(CourseGrader):
...
@@ -248,7 +246,7 @@ class SingleSectionGrader(CourseGrader):
foundScore
=
score
foundScore
=
score
break
break
if
settings
.
GENERATE_PROFILE_SCORES
:
# for debugging!
if
generate_random_scores
:
# for debugging!
earned
=
random
.
randint
(
2
,
15
)
earned
=
random
.
randint
(
2
,
15
)
possible
=
random
.
randint
(
earned
,
15
)
possible
=
random
.
randint
(
earned
,
15
)
percent
=
float
(
earned
)
/
possible
percent
=
float
(
earned
)
/
possible
...
@@ -306,7 +304,7 @@ class AssignmentFormatGrader(CourseGrader):
...
@@ -306,7 +304,7 @@ class AssignmentFormatGrader(CourseGrader):
self
.
short_label
=
short_label
or
self
.
type
self
.
short_label
=
short_label
or
self
.
type
self
.
show_only_average
=
show_only_average
self
.
show_only_average
=
show_only_average
def
grade
(
self
,
grade_sheet
):
def
grade
(
self
,
grade_sheet
,
generate_random_scores
=
False
):
def
totalWithDrops
(
breakdown
,
drop_count
):
def
totalWithDrops
(
breakdown
,
drop_count
):
#create an array of tuples with (index, mark), sorted by mark['percent'] descending
#create an array of tuples with (index, mark), sorted by mark['percent'] descending
sorted_breakdown
=
sorted
(
enumerate
(
breakdown
),
key
=
lambda
x
:
-
x
[
1
][
'percent'
])
sorted_breakdown
=
sorted
(
enumerate
(
breakdown
),
key
=
lambda
x
:
-
x
[
1
][
'percent'
])
...
@@ -328,8 +326,7 @@ class AssignmentFormatGrader(CourseGrader):
...
@@ -328,8 +326,7 @@ class AssignmentFormatGrader(CourseGrader):
scores
=
grade_sheet
.
get
(
self
.
type
,
[])
scores
=
grade_sheet
.
get
(
self
.
type
,
[])
breakdown
=
[]
breakdown
=
[]
for
i
in
range
(
max
(
self
.
min_count
,
len
(
scores
))):
for
i
in
range
(
max
(
self
.
min_count
,
len
(
scores
))):
print
"scores"
,
scores
if
generate_random_scores
:
# for debugging!
if
settings
.
GENERATE_PROFILE_SCORES
:
# for debugging!
earned
=
random
.
randint
(
2
,
15
)
earned
=
random
.
randint
(
2
,
15
)
possible
=
random
.
randint
(
earned
,
15
)
possible
=
random
.
randint
(
earned
,
15
)
percentage
=
float
(
earned
)
/
possible
percentage
=
float
(
earned
)
/
possible
...
...
lms/djangoapps/courseware/grades.py
View file @
fc73916e
...
@@ -201,7 +201,7 @@ def grade(student, request, course, student_module_cache=None, keep_raw_scores=F
...
@@ -201,7 +201,7 @@ def grade(student, request, course, student_module_cache=None, keep_raw_scores=F
totaled_scores
[
section_format
]
=
format_scores
totaled_scores
[
section_format
]
=
format_scores
grade_summary
=
course
.
grader
.
grade
(
totaled_scores
)
grade_summary
=
course
.
grader
.
grade
(
totaled_scores
,
generate_random_scores
=
settings
.
GENERATE_PROFILE_SCORES
)
# We round the grade here, to make sure that the grade is an whole percentage and
# We round the grade here, to make sure that the grade is an whole percentage and
# doesn't get displayed differently than it gets grades
# doesn't get displayed differently than it gets grades
...
...
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