Basic gradebook
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import logging
|
||||
import urllib
|
||||
from lxml import etree
|
||||
|
||||
import courseware.content_parser as content_parser
|
||||
from models import StudentModule
|
||||
from django.conf import settings
|
||||
import courseware.modules
|
||||
|
||||
from student.models import UserProfile
|
||||
|
||||
@@ -41,7 +43,7 @@ def get_grade(user, problem, cache):
|
||||
|
||||
return (correct, total)
|
||||
|
||||
def gradesheet(student):
|
||||
def grade_sheet(student):
|
||||
dom=content_parser.course_file(student)
|
||||
course = dom.xpath('//course/@name')[0]
|
||||
xmlChapters = dom.xpath('//course[@name=$course]/chapter', course=course)
|
||||
@@ -220,16 +222,7 @@ def gradesheet(student):
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
user_info = UserProfile.objects.get(user=student) # request.user.profile_cache #
|
||||
context={'name':user_info.name,
|
||||
'username':student.username,
|
||||
'location':user_info.location,
|
||||
'language':user_info.language,
|
||||
'email':student.email,
|
||||
'chapters':chapters,
|
||||
'format_url_params' : content_parser.format_url_params,
|
||||
'grade_summary' : grade_summary,
|
||||
}
|
||||
return {'grade_summary' : grade_summary,
|
||||
'chapters':chapters}
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@@ -36,6 +36,20 @@ etree.set_default_parser(etree.XMLParser(dtd_validation=False, load_dtd=False,
|
||||
|
||||
template_imports={'urllib':urllib}
|
||||
|
||||
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
|
||||
def gradebook(request):
|
||||
if 'course_admin' not in content_parser.user_groups(request.user):
|
||||
raise Http404
|
||||
student_objects = User.objects.all()[:100]
|
||||
student_info = [{'username' :s.username,
|
||||
'id' : s.id,
|
||||
'email': s.email,
|
||||
'grade_info' : grades.grade_sheet(s),
|
||||
'realname' : UserProfile.objects.get(user = s).name
|
||||
} for s in student_objects]
|
||||
|
||||
return render_to_response('gradebook.html',{'students':student_info})
|
||||
|
||||
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
|
||||
def profile(request, student_id = None):
|
||||
''' User profile. Show username, location, etc, as well as grades .
|
||||
@@ -51,8 +65,17 @@ def profile(request, student_id = None):
|
||||
raise Http404
|
||||
student = User.objects.get( id = int(student_id))
|
||||
|
||||
context = grades.gradesheet(student)
|
||||
context.update({'csrf':csrf(request)['csrf_token']})
|
||||
user_info = UserProfile.objects.get(user=student) # request.user.profile_cache #
|
||||
|
||||
context={'name':user_info.name,
|
||||
'username':student.username,
|
||||
'location':user_info.location,
|
||||
'language':user_info.language,
|
||||
'email':student.email,
|
||||
'format_url_params' : content_parser.format_url_params,
|
||||
'csrf':csrf(request)['csrf_token']
|
||||
}
|
||||
context.update(grades.grade_sheet(student))
|
||||
|
||||
return render_to_response('profile.html', context)
|
||||
|
||||
|
||||
1
urls.py
1
urls.py
@@ -8,6 +8,7 @@ import django.contrib.auth.views
|
||||
# admin.autodiscover()
|
||||
|
||||
urlpatterns = ('',
|
||||
url(r'^gradebook$', 'courseware.views.gradebook'),
|
||||
url(r'^event$', 'track.views.user_track'),
|
||||
url(r'^t/(?P<template>[^/]*)$', 'static_template_view.views.index'),
|
||||
url(r'^logout$', 'student.views.logout_user'),
|
||||
|
||||
Reference in New Issue
Block a user