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
00fb2cc2
Commit
00fb2cc2
authored
Nov 20, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display quizzes questions & radio selections (both types)
parent
bf9c05ec
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
17 deletions
+62
-17
mentoring/answer.py
+1
-1
mentoring/quizz.py
+21
-12
static/html/quizz_rating.html
+22
-0
static/html/quizz_yes-no-unsure.html
+14
-0
templates/005_checking_your_improvement_goal.xml
+4
-4
No files found.
mentoring/answer.py
View file @
00fb2cc2
...
...
@@ -54,7 +54,7 @@ class AnswerBlock(XBlock):
Answer
.
_meta
.
get_field
(
'student_input'
)
.
max_length
,
self
.
student_input
)
else
:
html
=
u'<blockquote class="answer read_only">{}</
div
>'
.
format
(
self
.
student_input
)
html
=
u'<blockquote class="answer read_only">{}</
blockquote
>'
.
format
(
self
.
student_input
)
fragment
=
Fragment
(
html
)
fragment
.
add_css
(
load_resource
(
'static/css/answer.css'
))
...
...
mentoring/quizz.py
View file @
00fb2cc2
...
...
@@ -6,10 +6,10 @@
import
logging
from
xblock.core
import
XBlock
from
xblock.fields
import
Any
,
List
,
Scope
,
String
from
xblock.fields
import
List
,
Scope
,
String
from
xblock.fragment
import
Fragment
from
.utils
import
load_resource
from
.utils
import
load_resource
,
render_template
# Globals ###########################################################
...
...
@@ -37,17 +37,14 @@ class QuizzBlock(XBlock):
"""
TODO: Description
"""
type
=
String
(
help
=
"Type of quizz"
,
scope
=
Scope
.
content
,
default
=
"yes-no-unsure"
)
question
=
String
(
help
=
"Question to ask the student"
,
scope
=
Scope
.
content
,
default
=
""
)
type
=
String
(
help
=
"Type of quizz"
,
scope
=
Scope
.
content
,
default
=
"yes-no-unsure"
)
low
=
String
(
help
=
"Label for low ratings"
,
scope
=
Scope
.
content
,
default
=
"Less"
)
high
=
String
(
help
=
"Label for high ratings"
,
scope
=
Scope
.
content
,
default
=
"More"
)
tip
=
String
(
help
=
"Mentoring tip to provide if needed"
,
scope
=
Scope
.
content
,
default
=
""
)
tip_display
=
List
(
help
=
"List of answers to display the tip for"
,
scope
=
Scope
.
content
,
default
=
None
)
reject
=
List
(
help
=
"List of answers to reject"
,
scope
=
Scope
.
content
,
default
=
None
)
student_input
=
Any
(
help
=
"Last input submitted by the student"
,
default
=
""
,
scope
=
Scope
.
user_state
)
has_children
=
True
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
QuizzBlock
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
# TODO
tip_display
=
List
(
help
=
"List of choices to display the tip for"
,
scope
=
Scope
.
content
,
default
=
None
)
reject
=
List
(
help
=
"List of choices to reject"
,
scope
=
Scope
.
content
,
default
=
None
)
student_choice
=
String
(
help
=
"Last input submitted by the student"
,
default
=
""
,
scope
=
Scope
.
user_state
)
@classmethod
def
parse_xml
(
cls
,
node
,
runtime
,
keys
):
...
...
@@ -63,6 +60,10 @@ class QuizzBlock(XBlock):
else
:
block
.
runtime
.
add_node_as_child
(
block
,
child
)
for
name
,
value
in
node
.
items
():
if
name
in
block
.
fields
:
setattr
(
block
,
name
,
value
)
return
block
def
student_view
(
self
,
context
=
None
):
# pylint: disable=W0613
...
...
@@ -70,7 +71,15 @@ class QuizzBlock(XBlock):
return
Fragment
(
u"<p>I can only appear inside mentoring blocks.</p>"
)
def
mentoring_view
(
self
,
context
=
None
):
fragment
=
Fragment
(
u'<h2>Quizz</h2>'
)
# TODO
if
self
.
type
not
in
(
'yes-no-unsure'
,
'rating'
):
raise
ValueError
,
u'Invalid value for QuizzBlock.type: `{}`'
.
format
(
self
.
type
)
template_path
=
'static/html/quizz_{}.html'
.
format
(
self
.
type
)
html
=
render_template
(
template_path
,
{
'self'
:
self
,
})
fragment
=
Fragment
(
html
)
fragment
.
add_css
(
load_resource
(
'static/css/quizz.css'
))
fragment
.
add_javascript
(
load_resource
(
'static/js/quizz.js'
))
fragment
.
initialize_js
(
'QuizzBlock'
)
...
...
static/html/quizz_rating.html
0 → 100644
View file @
00fb2cc2
<fieldset
class=
"rating"
>
<legend>
{{ self.question }}
</legend>
<div
class=
"choices"
>
<span
class=
"low"
>
{{ self.low }}
</span>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"1"
{%
if
self
.
student_choice =
=
'
1
'
%}
checked
{%
endif
%}
></label>
</span>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"2"
{%
if
self
.
student_choice =
=
'
2
'
%}
checked
{%
endif
%}
></label>
</span>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"3"
{%
if
self
.
student_choice =
=
'
3
'
%}
checked
{%
endif
%}
></label>
</span>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"4"
{%
if
self
.
student_choice =
=
'
4
'
%}
checked
{%
endif
%}
></label>
</span>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"5"
{%
if
self
.
student_choice =
=
'
5
'
%}
checked
{%
endif
%}
></label>
</span>
<span
class=
"low"
>
{{ self.high }}
</span>
</div>
</fieldset>
static/html/quizz_yes-no-unsure.html
0 → 100644
View file @
00fb2cc2
<fieldset
class=
"yes-no-unsure"
>
<legend>
{{ self.question }}
</legend>
<div
class=
"choices"
>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"yes"
{%
if
self
.
student_choice =
=
'
yes
'
%}
checked
{%
endif
%}
>
Yes
</label>
</span>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"no"
{%
if
self
.
student_choice =
=
'
yes
'
%}
checked
{%
endif
%}
>
No
</label>
</span>
<span
class=
"choice"
>
<label><input
type=
"radio"
name=
"{{ self.name }}"
value=
"unsure"
{%
if
self
.
student_choice =
=
'
yes
'
%}
checked
{%
endif
%}
>
Unsure
</label>
</span>
</div>
</fieldset>
templates/005_checking_your_improvement_goal.xml
View file @
00fb2cc2
...
...
@@ -7,22 +7,22 @@
<answer
name=
"improvement_goal"
read_only=
"true"
/>
<quizz
type=
"yes-no-unsure"
>
<quizz
name=
"goal_true"
type=
"yes-no-unsure"
>
<question>
Is this goal true for you?
</question>
<tip>
A goal that is true to you ___. Please enter a new goal that does meet these criteria.
</tip>
</quizz>
<quizz
type=
"yes-no-unsure"
>
<quizz
name=
"goal_implicate"
type=
"yes-no-unsure"
>
<question>
Does this goal implicate you?
</question>
<tip>
A goal that implicates you ____. Please enter a new goal that does meet these criteria.
</tip>
</quizz>
<quizz
type=
"rating"
low=
"Far"
high=
"Nearly there"
>
<quizz
name=
"goal_close"
type=
"rating"
low=
"Far"
high=
"Nearly there"
>
<question>
How close are you to reaching this goal?
</question>
<tip
reject=
"5"
display=
"4"
>
Please enter a goal which you are less close to reach
</tip>
</quizz>
<quizz
type=
"rating"
low=
"Least"
high=
"Most"
>
<quizz
name=
"goal_important"
type=
"rating"
low=
"Least"
high=
"Most"
>
<question>
How important is it to you?
</question>
<tip>
Please enter a goal which is important for you.
</tip>
</quizz>
...
...
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