Commit 60d9e628 by Xavier Antoviaque

Include course_id in answers, add jump_to_id processing to JSON view

parent 8018f75b
......@@ -131,13 +131,13 @@ class AnswerBlock(LightChild):
if not name:
raise ValueError, 'AnswerBlock.name field need to be set to a non-null/empty value'
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
student_id = self.xmodule_runtime.anonymous_student_id
# TODO: How do we get the course id?
course_id = 'default'
course_id = self.xmodule_runtime.course_id
answer_data, created = Answer.objects.get_or_create(
student_id=student_id,
course_id=course_id,
name=name
name=name,
)
return answer_data
......@@ -28,9 +28,12 @@ import logging
from cStringIO import StringIO
from lxml import etree
from django.core.urlresolvers import reverse
from xblock.core import XBlock
from xblock.fragment import Fragment
from xblock.plugin import Plugin
from xmodule_modifiers import replace_jump_to_id_urls
from .utils import XBlockWithChildrenFragmentsMixin
......@@ -156,7 +159,18 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
"""
Current HTML view of the XBlock, for refresh by client
"""
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
course_id = self.xmodule_runtime.course_id
frag = self.student_view({})
frag = replace_jump_to_id_urls(
course_id,
reverse('jump_to_id', kwargs={'course_id': course_id, 'module_id': ''}),
self,
'student_view',
frag,
{}
)
return {
'html': frag.content,
}
......
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Removing unique constraint on 'Answer', fields ['student_id', 'name']
db.delete_unique('mentoring_answer', ['student_id', 'name'])
# Adding unique constraint on 'Answer', fields ['course_id', 'student_id', 'name']
db.create_unique('mentoring_answer', ['course_id', 'student_id', 'name'])
def backwards(self, orm):
# Removing unique constraint on 'Answer', fields ['course_id', 'student_id', 'name']
db.delete_unique('mentoring_answer', ['course_id', 'student_id', 'name'])
# Adding unique constraint on 'Answer', fields ['student_id', 'name']
db.create_unique('mentoring_answer', ['student_id', 'name'])
models = {
'mentoring.answer': {
'Meta': {'unique_together': "(('student_id', 'course_id', 'name'),)", 'object_name': 'Answer'},
'course_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified_on': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'student_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}),
'student_input': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'})
}
}
complete_apps = ['mentoring']
\ No newline at end of file
......@@ -36,7 +36,7 @@ class Answer(models.Model):
class Meta:
app_label = 'mentoring'
unique_together = (('student_id', 'name'),)
unique_together = (('student_id', 'course_id', 'name'),)
name = models.CharField(max_length=50, db_index=True)
student_id = models.CharField(max_length=32, db_index=True)
......
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