Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
60d9e628
Commit
60d9e628
authored
Mar 02, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include course_id in answers, add jump_to_id processing to JSON view
parent
8018f75b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
4 deletions
+58
-4
mentoring/answer.py
+3
-3
mentoring/light_children.py
+14
-0
mentoring/migrations/0003_auto__del_unique_answer_student_id_name__add_unique_answer_course_id_s.py
+40
-0
mentoring/models.py
+1
-1
No files found.
mentoring/answer.py
View file @
60d9e628
...
...
@@ -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
mentoring/light_children.py
View file @
60d9e628
...
...
@@ -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
,
}
...
...
mentoring/migrations/0003_auto__del_unique_answer_student_id_name__add_unique_answer_course_id_s.py
0 → 100644
View file @
60d9e628
# -*- 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
mentoring/models.py
View file @
60d9e628
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment