Commit 985211a3 by Bridger Maxwell

Showing due dates and section types on profile page.

parent 32f69d64
...@@ -185,9 +185,8 @@ def toc_from_xml(dom, active_chapter, active_section): ...@@ -185,9 +185,8 @@ def toc_from_xml(dom, active_chapter, active_section):
sections=list() sections=list()
for s in dom.xpath('//course[@name=$name]/chapter[@name=$chname]/section', name=name, chname=c.get('name')): for s in dom.xpath('//course[@name=$name]/chapter[@name=$chname]/section', name=name, chname=c.get('name')):
sections.append({'name':s.get("name") or "", sections.append({'name':s.get("name") or "",
'time':s.get("time") or "", 'format':s.get("subtitle") if s.get("subtitle") else s.get("format") or "",
'format':s.get("format") or "", 'due':s.get("due") or "",
'due':s.get("display_due_date") or "",
'active':(c.get("name")==active_chapter and \ 'active':(c.get("name")==active_chapter and \
s.get("name")==active_section)}) s.get("name")==active_section)})
ch.append({'name':c.get("name"), ch.append({'name':c.get("name"),
......
...@@ -3,6 +3,7 @@ import datetime ...@@ -3,6 +3,7 @@ import datetime
import dateutil import dateutil
import dateutil.parser import dateutil.parser
import json import json
import logging
import math import math
import numpy import numpy
import os import os
...@@ -23,6 +24,8 @@ from x_module import XModule ...@@ -23,6 +24,8 @@ from x_module import XModule
from courseware.capa.capa_problem import LoncapaProblem from courseware.capa.capa_problem import LoncapaProblem
import courseware.content_parser as content_parser import courseware.content_parser as content_parser
log = logging.getLogger("mitx.courseware")
class LoncapaModule(XModule): class LoncapaModule(XModule):
''' Interface between capa_problem and x_module. Originally a hack ''' Interface between capa_problem and x_module. Originally a hack
meant to be refactored out, but it seems to be serving a useful meant to be refactored out, but it seems to be serving a useful
...@@ -128,6 +131,7 @@ class LoncapaModule(XModule): ...@@ -128,6 +131,7 @@ class LoncapaModule(XModule):
display_due_date_string=content_parser.item(dom2.xpath('/problem/@due')) display_due_date_string=content_parser.item(dom2.xpath('/problem/@due'))
if len(display_due_date_string)>0: if len(display_due_date_string)>0:
self.display_due_date=dateutil.parser.parse(display_due_date_string) self.display_due_date=dateutil.parser.parse(display_due_date_string)
log.debug("Parsed " + display_due_date_string + " to " + str(self.display_due_date))
else: else:
self.display_due_date=None self.display_due_date=None
...@@ -136,6 +140,7 @@ class LoncapaModule(XModule): ...@@ -136,6 +140,7 @@ class LoncapaModule(XModule):
if len(grace_period_string)>0 and self.display_due_date: if len(grace_period_string)>0 and self.display_due_date:
self.grace_period = content_parser.parse_timedelta(grace_period_string) self.grace_period = content_parser.parse_timedelta(grace_period_string)
self.close_date = self.display_due_date + self.grace_period self.close_date = self.display_due_date + self.grace_period
log.debug("Then parsed " + grace_period_string + " to closing date" + str(self.close_date))
else: else:
self.grace_period = None self.grace_period = None
self.close_date = self.display_due_date self.close_date = self.display_due_date
......
...@@ -59,6 +59,8 @@ def profile(request): ...@@ -59,6 +59,8 @@ def profile(request):
course=course, chname=chname): course=course, chname=chname):
problems=dom.xpath('//course[@name=$course]/chapter[@name=$chname]/section[@name=$section]//problem', problems=dom.xpath('//course[@name=$course]/chapter[@name=$chname]/section[@name=$section]//problem',
course=course, chname=chname, section=s.get('name')) course=course, chname=chname, section=s.get('name'))
graded = True if s.get('graded') == "true" else False
scores=[] scores=[]
if len(problems)>0: if len(problems)>0:
for p in problems: for p in problems:
...@@ -70,7 +72,7 @@ def profile(request): ...@@ -70,7 +72,7 @@ def profile(request):
correct=response.grade correct=response.grade
total=courseware.modules.capa_module.LoncapaModule(etree.tostring(p), "id").max_score() # TODO: Add state. Not useful now, but maybe someday problems will have randomized max scores? total=courseware.modules.capa_module.LoncapaModule(etree.tostring(p), "id").max_score() # TODO: Add state. Not useful now, but maybe someday problems will have randomized max scores?
scores.append((int(correct),total, ( True if s.get('graded') == "true" else False ) )) scores.append((int(correct),total, graded ))
section_total = (sum([score[0] for score in scores]), section_total = (sum([score[0] for score in scores]),
...@@ -81,6 +83,7 @@ def profile(request): ...@@ -81,6 +83,7 @@ def profile(request):
#Add the graded total to total_scores #Add the graded total to total_scores
format = s.get('format') if s.get('format') else "" format = s.get('format') if s.get('format') else ""
subtitle = s.get('subtitle') if s.get('subtitle') else format
if format and graded_total[1] > 0: if format and graded_total[1] > 0:
format_scores = total_scores[ format ] if format in total_scores else [] format_scores = total_scores[ format ] if format in total_scores else []
format_scores.append( graded_total ) format_scores.append( graded_total )
...@@ -92,6 +95,9 @@ def profile(request): ...@@ -92,6 +95,9 @@ def profile(request):
'scores':scores, 'scores':scores,
'section_total' : section_total, 'section_total' : section_total,
'format' : format, 'format' : format,
'subtitle' : subtitle,
'due' : s.get("due") or "",
'graded' : graded,
} }
hw.append(score) hw.append(score)
......
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