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
925a31ef
Commit
925a31ef
authored
Nov 23, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds support for QuizzBlock.reject and .display properties
parent
7cf1bb93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
10 deletions
+35
-10
mentoring/quizz.py
+27
-9
static/html/tip.html
+8
-1
No files found.
mentoring/quizz.py
View file @
925a31ef
...
@@ -24,9 +24,9 @@ def commas_to_list(commas_str):
...
@@ -24,9 +24,9 @@ def commas_to_list(commas_str):
Converts a comma-separated string to a list
Converts a comma-separated string to a list
"""
"""
if
commas_str
is
None
:
if
commas_str
is
None
:
return
None
return
None
# Means default value (which can be non-empty)
elif
commas_str
==
''
:
elif
commas_str
==
''
:
return
[]
return
[]
# Means empty list
else
:
else
:
return
commas_str
.
split
(
','
)
return
commas_str
.
split
(
','
)
...
@@ -42,7 +42,7 @@ class QuizzBlock(XBlock):
...
@@ -42,7 +42,7 @@ class QuizzBlock(XBlock):
low
=
String
(
help
=
"Label for low ratings"
,
scope
=
Scope
.
content
,
default
=
"Less"
)
low
=
String
(
help
=
"Label for low ratings"
,
scope
=
Scope
.
content
,
default
=
"Less"
)
high
=
String
(
help
=
"Label for high ratings"
,
scope
=
Scope
.
content
,
default
=
"More"
)
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
=
String
(
help
=
"Mentoring tip to provide if needed"
,
scope
=
Scope
.
content
,
default
=
""
)
tip_
display
=
List
(
help
=
"List of choices to display the tip for"
,
scope
=
Scope
.
content
,
default
=
None
)
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
)
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
)
student_choice
=
String
(
help
=
"Last input submitted by the student"
,
default
=
""
,
scope
=
Scope
.
user_state
)
...
@@ -88,9 +88,9 @@ class QuizzBlock(XBlock):
...
@@ -88,9 +88,9 @@ class QuizzBlock(XBlock):
def
submit
(
self
,
submission
):
def
submit
(
self
,
submission
):
log
.
info
(
u'Received quizz submission:
%
s'
,
submission
)
log
.
info
(
u'Received quizz submission:
%
s'
,
submission
)
# TODO
completed
=
self
.
is_completed
(
submission
)
completed
=
bool
(
submission
)
show_tip
=
self
.
is_tip_shown
(
submission
)
s
how_tip
=
completed
s
elf
.
student_choice
=
submission
if
show_tip
:
if
show_tip
:
formatted_tip
=
render_template
(
'static/html/tip.html'
,
{
formatted_tip
=
render_template
(
'static/html/tip.html'
,
{
...
@@ -105,7 +105,25 @@ class QuizzBlock(XBlock):
...
@@ -105,7 +105,25 @@ class QuizzBlock(XBlock):
'tip'
:
formatted_tip
,
'tip'
:
formatted_tip
,
}
}
#self.student_input = submission[0]['value']
def
is_completed
(
self
,
submission
):
#log.info(u'Answer submitted for`{}`: "{}"'.format(self.name, self.student_input))
return
submission
and
submission
not
in
self
.
reject_with_defaults
#return self.student_choice
def
is_tip_shown
(
self
,
submission
):
return
not
submission
or
submission
in
self
.
display_with_defaults
@property
def
reject_with_defaults
(
self
):
if
self
.
reject
is
None
:
if
self
.
type
==
'yes-no-unsure'
:
return
[
'no'
,
'unsure'
]
elif
self
.
type
==
'rating'
:
return
[
1
,
2
,
3
]
else
:
return
self
.
reject
@property
def
display_with_defaults
(
self
):
if
self
.
display
is
None
:
return
self
.
reject_with_defaults
else
:
return
self
.
display
static/html/tip.html
View file @
925a31ef
<div
class=
"quizz-tip"
>
<div
class=
"quizz-tip"
>
<h3>
{{ self.question }}
</h2>
<strong>
To the question
<em>
"{{ self.question }}"
</em>
,
{% if self.student_choice %}
you answered
<em>
"{{ self.student_choice }}"
</em>
.
{% else %}
you have not provided an answer.
{% endif %}
</strong>
<p>
{{ self.tip }}
</p>
<p>
{{ self.tip }}
</p>
</div>
</div>
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