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
8018f75b
Commit
8018f75b
authored
Mar 02, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix anonymous_user_id retreival & model storage, add course_id
parent
e29009fa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
6 deletions
+59
-6
mentoring/answer.py
+4
-2
mentoring/light_children.py
+11
-3
mentoring/migrations/0002_auto__add_field_answer_course_id__chg_field_answer_student_id.py
+42
-0
mentoring/models.py
+2
-1
No files found.
mentoring/answer.py
View file @
8018f75b
...
...
@@ -131,11 +131,13 @@ class AnswerBlock(LightChild):
if
not
name
:
raise
ValueError
,
'AnswerBlock.name field need to be set to a non-null/empty value'
# TODO-WORKBENCH-WORKAROUND: Remove use of getattr(), used to work on both LMS & workbench
student_id
=
getattr
(
self
.
runtime
,
'anonymous_student_id'
,
'student1'
)
student_id
=
self
.
xmodule_runtime
.
anonymous_student_id
# TODO: How do we get the course id?
course_id
=
'default'
answer_data
,
created
=
Answer
.
objects
.
get_or_create
(
student_id
=
student_id
,
course_id
=
course_id
,
name
=
name
)
return
answer_data
mentoring/light_children.py
View file @
8018f75b
...
...
@@ -84,7 +84,7 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
def
add_node_as_child
(
cls
,
block
,
xml_child
,
child_id
):
# Instantiate child
child_class
=
cls
.
get_class_by_element
(
xml_child
.
tag
)
child
=
child_class
(
block
.
runtime
)
child
=
child_class
(
block
)
child
.
name
=
u'{}_{}'
.
format
(
block
.
name
,
child_id
)
# Add any children the child may itself have
...
...
@@ -168,8 +168,16 @@ class LightChild(Plugin, LightChildrenMixin):
"""
entry_point
=
'xblock.light_children'
def
__init__
(
self
,
runtime
):
self
.
runtime
=
runtime
def
__init__
(
self
,
parent
):
self
.
parent
=
parent
@property
def
runtime
(
self
):
return
self
.
parent
.
runtime
@property
def
xmodule_runtime
(
self
):
return
self
.
parent
.
xmodule_runtime
def
save
(
self
):
pass
...
...
mentoring/migrations/0002_auto__add_field_answer_course_id__chg_field_answer_student_id.py
0 → 100644
View file @
8018f75b
# -*- 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
):
# Adding field 'Answer.course_id'
db
.
add_column
(
'mentoring_answer'
,
'course_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
'default'
,
max_length
=
50
,
db_index
=
True
),
keep_default
=
False
)
# Changing field 'Answer.student_id'
db
.
alter_column
(
'mentoring_answer'
,
'student_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
))
def
backwards
(
self
,
orm
):
# Deleting field 'Answer.course_id'
db
.
delete_column
(
'mentoring_answer'
,
'course_id'
)
# Changing field 'Answer.student_id'
db
.
alter_column
(
'mentoring_answer'
,
'student_id'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
20
))
models
=
{
'mentoring.answer'
:
{
'Meta'
:
{
'unique_together'
:
"(('student_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 @
8018f75b
...
...
@@ -39,7 +39,8 @@ class Answer(models.Model):
unique_together
=
((
'student_id'
,
'name'
),)
name
=
models
.
CharField
(
max_length
=
50
,
db_index
=
True
)
student_id
=
models
.
CharField
(
max_length
=
20
,
db_index
=
True
)
student_id
=
models
.
CharField
(
max_length
=
32
,
db_index
=
True
)
course_id
=
models
.
CharField
(
max_length
=
50
,
db_index
=
True
)
student_input
=
models
.
TextField
(
blank
=
True
,
default
=
''
)
created_on
=
models
.
DateTimeField
(
'created on'
,
auto_now_add
=
True
)
modified_on
=
models
.
DateTimeField
(
'modified on'
,
auto_now
=
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