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
238beb41
Commit
238beb41
authored
Nov 20, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add <answer default_from="answer_name"> feature & load page 3
parent
6437809f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
mentoring/answer.py
+18
-4
mentoring/mentoring.py
+6
-2
mentoring/models.py
+1
-1
templates/003_reflecting_on_feedback.xml
+1
-1
No files found.
mentoring/answer.py
View file @
238beb41
...
...
@@ -6,7 +6,7 @@
import
logging
from
xblock.core
import
XBlock
from
xblock.fields
import
Any
,
Boolean
,
Scope
from
xblock.fields
import
Any
,
Boolean
,
Scope
,
String
from
xblock.fragment
import
Fragment
from
.models
import
Answer
...
...
@@ -29,12 +29,19 @@ class AnswerBlock(XBlock):
"""
student_input
=
Any
(
help
=
"Last input submitted by the student"
,
default
=
""
,
scope
=
Scope
.
user_state
)
read_only
=
Boolean
(
help
=
"Display as a read-only field"
,
default
=
False
,
scope
=
Scope
.
content
)
default_from
=
String
(
help
=
"If specified, the name of the answer to get the default value from"
,
default
=
None
,
scope
=
Scope
.
content
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
AnswerBlock
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
# Only attempt to locate a model object for this block when the answer has a name
if
self
.
name
:
self
.
student_input
=
self
.
get_model_object
()
.
student_input
# Default value can be set from another answer's current value
if
not
self
.
student_input
and
self
.
default_from
:
self
.
student_input
=
self
.
get_model_object
(
name
=
self
.
default_from
)
.
student_input
def
student_view
(
self
,
context
=
None
):
# pylint: disable=W0613
"""Returns default student view."""
return
Fragment
(
u"<p>I can only appear inside problems.</p>"
)
...
...
@@ -69,8 +76,15 @@ class AnswerBlock(XBlock):
answer_data
.
student_input
=
self
.
student_input
answer_data
.
save
()
def
get_model_object
(
self
):
if
not
self
.
name
:
def
get_model_object
(
self
,
name
=
None
):
"""
Fetches the Answer model object for the answer named `name`
"""
# By default, get the model object for the current answer's name
if
not
name
:
name
=
self
.
name
# Consistency check - we should have a name by now
if
not
name
:
raise
ValueError
,
'AnswerBlock.name field need to be set to a non-null/empty value'
# TODO Use a random user id
...
...
@@ -78,6 +92,6 @@ class AnswerBlock(XBlock):
answer_data
,
created
=
Answer
.
objects
.
get_or_create
(
student_id
=
student_id
,
name
=
self
.
name
name
=
name
)
return
answer_data
mentoring/mentoring.py
View file @
238beb41
...
...
@@ -106,6 +106,10 @@ class MentoringBlock(XBlock):
Sample scenarios which will be displayed in the workbench
"""
return
[
(
"Mentoring: Pre-Goal Brainstom"
,
load_resource
(
'templates/001_pre_goal_brainstorm.xml'
)),
(
"Mentoring: Getting Feedback"
,
load_resource
(
'templates/002_getting_feedback.xml'
)),
(
"Mentoring - Page 1, Pre-goal brainstom"
,
load_resource
(
'templates/001_pre_goal_brainstorm.xml'
)),
(
"Mentoring - Page 2, Getting feedback"
,
load_resource
(
'templates/002_getting_feedback.xml'
)),
(
"Mentoring - Page 3, Reflecting on your feedback"
,
load_resource
(
'templates/003_reflecting_on_feedback.xml'
)),
]
mentoring/models.py
View file @
238beb41
...
...
@@ -7,6 +7,6 @@ class Answer(models.Model):
name
=
models
.
CharField
(
max_length
=
20
,
db_index
=
True
)
student_id
=
models
.
CharField
(
max_length
=
20
,
db_index
=
True
)
student_input
=
models
.
CharField
(
max_length
=
10000
)
student_input
=
models
.
CharField
(
max_length
=
10000
,
blank
=
True
,
default
=
''
)
created_on
=
models
.
DateTimeField
(
'created on'
,
auto_now_add
=
True
)
modified_on
=
models
.
DateTimeField
(
'modified on'
,
auto_now
=
True
)
templates/003_reflecting_on_feedback.xml
View file @
238beb41
...
...
@@ -5,6 +5,6 @@
<p>
Now that you have received feedback from others, would you like to revise your brainstorm list? Which goals are the most interesting to you now? Which goals are you most considering pursuing?
</p>
</html>
<answer
name=
"brainstorm_goals2"
default
-
from=
"brainstorm_goals"
/>
<answer
name=
"brainstorm_goals2"
default
_
from=
"brainstorm_goals"
/>
</mentoring>
</vertical>
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