Commit 0c82e640 by Xavier Antoviaque

Add <quizz> blocks structure, load scenarios 4 & 5

parent 238beb41
from .answer import AnswerBlock
from .quizz import QuizzBlock
from .mentoring import MentoringBlock
......@@ -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')),
]
# -*- 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
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,
}
)
function QuizzBlock(runtime, element) {
return {
submit: function() {
return $(element).find(':input').serializeArray();
},
handleSubmit: function(result) {
$(element).find('.message').text((result || {}).error || '');
}
}
}
......@@ -2,7 +2,7 @@
<mentoring>
<html>
<h3>Deciding on your improvement goal</h3>
<p>Now its 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" />
......
......@@ -2,10 +2,10 @@
<mentoring>
<html>
<h3>Checking your improvement goal</h3>
<p>Now, lets 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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment