Commit 94b1cd57 by Bridger Maxwell

Fixed a few bugs from the complicated rebase.

parent fef004f4
......@@ -88,9 +88,7 @@ def grade_sheet(student):
grade_summary = grader.grade(totaled_scores)
letter_grade = grade_for_percentage(grade_summary['percent'])
_log.debug("Final grade: " + str(letter_grade))
return {'courseware_summary' : chapters,
'grade_summary' : grade_summary,
'grade' : letter_grade}
......
......@@ -20,6 +20,7 @@ from django_future.csrf import ensure_csrf_cookie
from lxml import etree
from courseware import course_settings
from module_render import render_module, modx_dispatch
from certificates.models import GeneratedCertificate
from models import StudentModule
......@@ -218,51 +219,6 @@ def index(request, course="6.002 Spring 2012", chapter="Using the System", secti
result = render_to_response('courseware.html', context)
return result
def modx_dispatch(request, module=None, dispatch=None, id=None):
''' Generic view for extensions. '''
if not request.user.is_authenticated():
return redirect('/')
# Grab the student information for the module from the database
s = StudentModule.objects.filter(student=request.user,
module_id=id)
#s = StudentModule.get_with_caching(request.user, id)
if len(s) == 0 or s is None:
log.debug("Couldnt find module for user and id " + str(module) + " " + str(request.user) + " "+ str(id))
raise Http404
s = s[0]
oldgrade = s.grade
oldstate = s.state
dispatch=dispatch.split('?')[0]
ajax_url = settings.MITX_ROOT_URL + '/modx/'+module+'/'+id+'/'
# Grab the XML corresponding to the request from course.xml
xml = content_parser.module_xml(request.user, module, 'id', id)
# Create the module
system = I4xSystem(track_function = make_track_function(request),
render_function = None,
ajax_url = ajax_url,
filestore = None
)
instance=courseware.modules.get_module_class(module)(system,
xml,
id,
state=oldstate)
# Let the module handle the AJAX
ajax_return=instance.handle_ajax(dispatch, request.POST)
# Save the state back to the database
s.state=instance.get_state()
if instance.get_score():
s.grade=instance.get_score()['score']
if s.grade != oldgrade or s.state != oldstate:
s.save()
# Return whatever the module wanted to return to the client/caller
return HttpResponse(ajax_return)
def certificate_request(request):
''' Attempt to send a certificate. '''
......
......@@ -8,6 +8,7 @@ import uuid
from django.conf import settings
from django.contrib.auth import logout, authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordResetForm
from django.contrib.auth.models import User
from django.core.context_processors import csrf
......
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