Added links from profile to courseware. Updated names in urls to accomodate.
This commit is contained in:
@@ -95,8 +95,10 @@ def profile(request):
|
||||
|
||||
|
||||
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
|
||||
#Note that this key will sort the list descending
|
||||
sorted_scores = sorted( enumerate(scores), key=lambda x: -x[1]['percentage'] )
|
||||
# A list of the indices of the dropped scores
|
||||
dropped_indices = [score[0] for score in sorted_scores[-drop_count:]]
|
||||
aggregate_score = 0
|
||||
for index, score in enumerate(scores):
|
||||
if index not in dropped_indices:
|
||||
@@ -176,16 +178,18 @@ def profile(request):
|
||||
'language':user_info.language,
|
||||
'email':request.user.email,
|
||||
'homeworks':hw,
|
||||
'format_url_params' : format_url_params,
|
||||
'grade_summary' : grade_summary,
|
||||
'csrf':csrf(request)['csrf_token']
|
||||
}
|
||||
return render_to_response('profile.html', context)
|
||||
|
||||
def format_url_params(params):
|
||||
return [ urllib.quote(string.replace(' ','_')) for string in params ]
|
||||
|
||||
def render_accordion(request,course,chapter,section):
|
||||
''' Draws navigation bar. Takes current position in accordion as
|
||||
parameter. Returns (initialization_javascript, content)'''
|
||||
def format_string(string):
|
||||
return urllib.quote(string.replace(' ','_'))
|
||||
|
||||
toc=content_parser.toc_from_xml(content_parser.course_file(request.user), chapter, section)
|
||||
active_chapter=1
|
||||
@@ -195,7 +199,7 @@ def render_accordion(request,course,chapter,section):
|
||||
context=dict([['active_chapter',active_chapter],
|
||||
['toc',toc],
|
||||
['course_name',course],
|
||||
['format_string',format_string],
|
||||
['format_url_params',format_url_params],
|
||||
['csrf',csrf(request)['csrf_token']]] + \
|
||||
template_imports.items())
|
||||
return {'init_js':render_to_string('accordion_init.js',context),
|
||||
|
||||
14
urls.py
14
urls.py
@@ -35,11 +35,11 @@ if settings.PERFSTATS:
|
||||
urlpatterns=urlpatterns + (url(r'^reprofile$','perfstats.views.end_profile'),)
|
||||
|
||||
if settings.COURSEWARE_ENABLED:
|
||||
urlpatterns=urlpatterns + ( url(r'^courseware/$', 'courseware.views.index'),
|
||||
url(r'^wiki/', include('simplewiki.urls')),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^courseware/(?P<course>[^/]*)/$', 'courseware.views.index'),
|
||||
urlpatterns=urlpatterns + (url(r'^courseware/$', 'courseware.views.index', name="courseware"),
|
||||
url(r'^wiki/', include('simplewiki.urls')),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$', 'courseware.views.index', name="courseware_section"),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/$', 'courseware.views.index', name="courseware_chapter"),
|
||||
url(r'^courseware/(?P<course>[^/]*)/$', 'courseware.views.index', name="courseware_course"),
|
||||
url(r'^modx/(?P<module>[^/]*)/(?P<id>[^/]*)/(?P<dispatch>[^/]*)$', 'courseware.views.modx_dispatch'), #reset_problem'),
|
||||
url(r'^profile$', 'courseware.views.profile'),
|
||||
url(r'^change_setting$', 'student.views.change_setting'),
|
||||
@@ -47,8 +47,8 @@ url(r'^wiki/', include('simplewiki.urls')),
|
||||
url(r'^book/(?P<page>[^/]*)$', 'staticbook.views.index'),
|
||||
url(r'^book-shifted/(?P<page>[^/]*)$', 'staticbook.views.index_shifted'),
|
||||
url(r'^book*$', 'staticbook.views.index'),
|
||||
# url(r'^course_info/$', 'student.views.courseinfo'),
|
||||
# url(r'^show_circuit/(?P<circuit>[^/]*)$', 'circuit.views.show_circuit'),
|
||||
# url(r'^course_info/$', 'student.views.courseinfo'),
|
||||
# url(r'^show_circuit/(?P<circuit>[^/]*)$', 'circuit.views.show_circuit'),
|
||||
url(r'^edit_circuit/(?P<circuit>[^/]*)$', 'circuit.views.edit_circuit'),
|
||||
url(r'^save_circuit/(?P<circuit>[^/]*)$', 'circuit.views.save_circuit'),
|
||||
url(r'^calculate$', 'util.views.calculate'),
|
||||
|
||||
Reference in New Issue
Block a user