Commit 88a30cb7 by David Ormsbee

Fixes in response to Victor's comments.

parent 87784d1c
...@@ -67,6 +67,8 @@ class StudentModuleHistory(models.Model): ...@@ -67,6 +67,8 @@ class StudentModuleHistory(models.Model):
Student. Right now, we restrict this to problems so that the table doesn't Student. Right now, we restrict this to problems so that the table doesn't
explode in size.""" explode in size."""
HISTORY_SAVING_TYPES = {'problem'}
class Meta: class Meta:
get_latest_by = "created" get_latest_by = "created"
...@@ -81,7 +83,7 @@ class StudentModuleHistory(models.Model): ...@@ -81,7 +83,7 @@ class StudentModuleHistory(models.Model):
@receiver(post_save, sender=StudentModule) @receiver(post_save, sender=StudentModule)
def save_history(sender, instance, **kwargs): def save_history(sender, instance, **kwargs):
if instance.module_type == 'problem': if instance.module_type in StudentModuleHistory.HISTORY_SAVING_TYPES:
history_entry = StudentModuleHistory(student_module=instance, history_entry = StudentModuleHistory(student_module=instance,
version=None, version=None,
created=instance.modified, created=instance.modified,
......
...@@ -616,10 +616,11 @@ def submission_history(request, course_id, student_username, location): ...@@ -616,10 +616,11 @@ def submission_history(request, course_id, student_username, location):
Right now this only works for problems because that's all Right now this only works for problems because that's all
StudentModuleHistory records. StudentModuleHistory records.
""" """
# Make sure our has_access check uses the course_id, eh? or is ourself
course = get_course_with_access(request.user, course_id, 'load') course = get_course_with_access(request.user, course_id, 'load')
staff_access = has_access(request.user, course, 'staff') staff_access = has_access(request.user, course, 'staff')
# Permission Denied if they don't have staff access and are trying to see
# somebody else's submission history.
if (student_username != request.user.username) and (not staff_access): if (student_username != request.user.username) and (not staff_access):
raise PermissionDenied raise PermissionDenied
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
% for i, entry in enumerate(history_entries): % for i, entry in enumerate(history_entries):
<hr/> <hr/>
<div> <div>
<b>#${len(history_entries) - i}</b>: ${entry.created} EST</br> <b>#${len(history_entries) - i}</b>: ${entry.created} UTC</br>
Score: ${entry.grade} / ${entry.max_grade} Score: ${entry.grade} / ${entry.max_grade}
<pre> <pre>
${json.dumps(json.loads(entry.state), indent=2, sort_keys=True) | h} ${json.dumps(json.loads(entry.state), indent=2, sort_keys=True) | h}
......
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