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
0c82e640
Commit
0c82e640
authored
Nov 20, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add <quizz> blocks structure, load scenarios 4 & 5
parent
238beb41
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
110 additions
and
11 deletions
+110
-11
mentoring/__init__.py
+1
-0
mentoring/mentoring.py
+4
-0
mentoring/quizz.py
+84
-0
setup.py
+8
-8
static/css/quizz.css
+0
-0
static/js/quizz.js
+10
-0
templates/004_deciding_on_your_improvement_goal.xml
+1
-1
templates/005_checking_your_improvement_goal.xml
+2
-2
No files found.
mentoring/__init__.py
View file @
0c82e640
from
.answer
import
AnswerBlock
from
.quizz
import
QuizzBlock
from
.mentoring
import
MentoringBlock
mentoring/mentoring.py
View file @
0c82e640
...
...
@@ -112,4 +112,8 @@ class MentoringBlock(XBlock):
load_resource
(
'templates/002_getting_feedback.xml'
)),
(
"Mentoring - Page 3, Reflecting on your feedback"
,
load_resource
(
'templates/003_reflecting_on_feedback.xml'
)),
(
"Mentoring - Page 4, Deciding on your improvement goal"
,
load_resource
(
'templates/004_deciding_on_your_improvement_goal.xml'
)),
(
"Mentoring - Page 5, Checking your improvement goal"
,
load_resource
(
'templates/005_checking_your_improvement_goal.xml'
)),
]
mentoring/quizz.py
0 → 100644
View file @
0c82e640
# -*- coding: utf-8 -*-
# Imports ###########################################################
import
logging
from
xblock.core
import
XBlock
from
xblock.fields
import
Any
,
List
,
Scope
,
String
from
xblock.fragment
import
Fragment
from
.utils
import
load_resource
# Globals ###########################################################
log
=
logging
.
getLogger
(
__name__
)
# Functions #########################################################
def
commas_to_list
(
commas_str
):
"""
Converts a comma-separated string to a list
"""
if
commas_str
is
None
:
return
None
elif
commas_str
==
''
:
return
[]
else
:
return
commas_str
.
split
(
','
)
# Classes ###########################################################
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
=
""
)
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
@classmethod
def
parse_xml
(
cls
,
node
,
runtime
,
keys
):
block
=
runtime
.
construct_xblock_from_class
(
cls
,
keys
)
for
child
in
node
:
if
child
.
tag
==
"question"
:
block
.
question
=
child
.
text
elif
child
.
tag
==
"tip"
:
block
.
tip
=
child
.
text
block
.
reject
=
commas_to_list
(
child
.
get
(
'reject'
))
block
.
display
=
commas_to_list
(
child
.
get
(
'display'
))
else
:
block
.
runtime
.
add_node_as_child
(
block
,
child
)
return
block
def
student_view
(
self
,
context
=
None
):
# pylint: disable=W0613
"""Returns default student view."""
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
fragment
.
add_css
(
load_resource
(
'static/css/quizz.css'
))
fragment
.
add_javascript
(
load_resource
(
'static/js/quizz.js'
))
fragment
.
initialize_js
(
'QuizzBlock'
)
return
fragment
def
submit
(
self
,
submission
):
# TODO
#self.student_input = submission[0]['value']
#log.info(u'Answer submitted for`{}`: "{}"'.format(self.name, self.student_input))
return
self
.
student_input
setup.py
View file @
0c82e640
from
setuptools
import
setup
BLOCKS
=
[
'mentoring = mentoring:MentoringBlock'
,
'answer = mentoring:AnswerBlock'
,
'quizz = mentoring:QuizzBlock'
,
]
setup
(
name
=
'xblock-mentoring'
,
version
=
'0.1'
,
description
=
'XBlock - Mentoring'
,
packages
=
[
'mentoring'
],
entry_points
=
{
'xblock.v1'
:
[
'mentoring = mentoring:MentoringBlock'
,
'answer = mentoring:AnswerBlock'
,
],
'xmodule.v1'
:
[
'mentoring = mentoring:MentoringBlock'
,
'answer = mentoring:AnswerBlock'
,
]
'xblock.v1'
:
BLOCKS
,
'xmodule.v1'
:
BLOCKS
,
}
)
static/css/quizz.css
0 → 100644
View file @
0c82e640
static/js/quizz.js
0 → 100644
View file @
0c82e640
function
QuizzBlock
(
runtime
,
element
)
{
return
{
submit
:
function
()
{
return
$
(
element
).
find
(
':input'
).
serializeArray
();
},
handleSubmit
:
function
(
result
)
{
$
(
element
).
find
(
'.message'
).
text
((
result
||
{}).
error
||
''
);
}
}
}
templates/004_deciding_on_your_improvement_goal.xml
View file @
0c82e640
...
...
@@ -2,7 +2,7 @@
<mentoring>
<html>
<h3>
Deciding on your improvement goal
</h3>
<p>
Now it
’
s time to make your decision on which improvement goal you will pursue.
</p>
<p>
Now it
'
s time to make your decision on which improvement goal you will pursue.
</p>
<h4>
(1) Write your goal in a sentence or phrase.
</h4>
</html>
<answer
name=
"improvement_goal"
/>
...
...
templates/005_checking_your_improvement_goal.xml
View file @
0c82e640
...
...
@@ -2,10 +2,10 @@
<mentoring>
<html>
<h3>
Checking your improvement goal
</h3>
<p>
Now, let
’
s make sure your goal meets the criteria for a strong column 1. Here is your goal:
</p>
<p>
Now, let
'
s make sure your goal meets the criteria for a strong column 1. Here is your goal:
</p>
</html>
<answer
name=
"improvement_goal"
read_only=
"
yes
"
/>
<answer
name=
"improvement_goal"
read_only=
"
true
"
/>
<quizz
type=
"yes-no-unsure"
>
<question>
Is this goal true for you?
</question>
...
...
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