Commit fcb530f1 by Bridger Maxwell

Course settings are now defined in DATA_DIR/course_settings.py. Used by…

Course settings are now defined in DATA_DIR/course_settings.py. Used by importing courseware.course_settings. The grader is defined in these settings files.
parent 7b915cd1
"""
Course settings module. The settings are based of django.conf. All settings in
courseware.global_course_settings are first applied, and then any settings
in the settings.DATA_DIR/course_settings.py are applied. A setting must be
in ALL_CAPS.
Settings are used by calling
from courseware import course_settings
Note that courseware.course_settings is not a module -- it's an object. So
importing individual settings is not possible:
from courseware.course_settings import GRADER # This won't work.
"""
import courseware
import imp
import logging
import sys
import types
from django.conf import settings
from django.utils.functional import SimpleLazyObject
from courseware import global_course_settings
_log = logging.getLogger("mitx.courseware")
class Settings(object):
def __init__(self):
# update this dict from global settings (but only for ALL_CAPS settings)
for setting in dir(global_course_settings):
if setting == setting.upper():
setattr(self, setting, getattr(global_course_settings, setting))
fp = None
try:
fp, pathname, description = imp.find_module("course_settings", [settings.DATA_DIR])
mod = imp.load_module("course_settings", fp, pathname, description)
except Exception as e:
_log.error("Unable to import course settings file from " + settings.DATA_DIR + ". Error: " + str(e))
mod = types.ModuleType('course_settings')
finally:
if fp:
fp.close()
for setting in dir(mod):
if setting == setting.upper():
setting_value = getattr(mod, setting)
setattr(self, setting, setting_value)
course_settings = Settings()
\ No newline at end of file
GRADER = [
{
'course_format' : "Homework",
'min_count' : 12,
'drop_count' : 2,
'short_label' : "HW",
'weight' : 0.15,
},
{
'course_format' : "Lab",
'min_count' : 12,
'drop_count' : 2,
'category' : "Labs",
'weight' : 0.15
},
{
'section_format' : "Examination",
'section_name' : "Midterm Exam",
'short_label' : "Midterm",
'weight' : 0.3,
},
{
'section_format' : "Examination",
'section_name' : "Final Exam",
'short_label' : "Final",
'weight' : 0.4,
}
]
......@@ -5,6 +5,7 @@ import random
import urllib
from collections import namedtuple
from courseware import course_settings
from django.conf import settings
from lxml import etree
from models import StudentModule
......@@ -317,9 +318,7 @@ def grade_sheet(student):
each containing an array of sections, each containing an array of scores. This contains information for graded and ungraded
problems, and is good for displaying a course summary with due dates, etc.
- grade_summary is a summary of how the final grade breaks down. It is an array of "sections". Each section can either be
a conglomerate of scores (like labs or homeworks) which has subscores and a totalscore, or a section can be all from one assignment
(such as a midterm or final) and only has a totalscore. Each section has a weight that shows how it contributes to the total grade.
- grade_summary is the output from the course grader. More information on the format is in the docstring for CourseGrader.
"""
dom=content_parser.course_file(student)
course = dom.xpath('//course/@name')[0]
......@@ -379,15 +378,9 @@ def grade_sheet(student):
'chapter' : c.get("name"),
'sections' : sections,})
#TODO: This grader declaration should live in the data repository. It is only here now to get it working
hwGrader = AssignmentFormatGrader("Homework", 12, 2, short_label = "HW")
labGrader = AssignmentFormatGrader("Lab", 12, 2, category = "Labs")
midtermGrader = SingleSectionGrader("Midterm", "Midterm Exam", short_label = "Midterm")
finalGrader = SingleSectionGrader("Examination", "Final Exam", short_label = "Final")
grader = WeightedSubsectionsGrader( [(hwGrader, hwGrader.category, 0.15), (labGrader, labGrader.category, 0.15),
(midtermGrader, midtermGrader.category, 0.30), (finalGrader, finalGrader.category, 0.40)] )
grader = CourseGrader.graderFromConf(course_settings.GRADER)
#TODO: We should cache this grader object
grade_summary = grader.grade(totaled_scores)
return {'courseware_summary' : chapters,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment