Commit 01e7afca by Braden MacDonald

Prefix all block type names and prepare for eventual rename to "problem builder"

parent 50b3c567
...@@ -395,7 +395,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -395,7 +395,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
raw_score = self.score.raw raw_score = self.score.raw
self.runtime.publish(self, 'xblock.mentoring.submitted', { self.runtime.publish(self, 'xblock.problem_builder.submitted', {
'num_attempts': self.num_attempts, 'num_attempts': self.num_attempts,
'submitted_answer': submissions, 'submitted_answer': submissions,
'grade': raw_score, 'grade': raw_score,
...@@ -460,7 +460,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -460,7 +460,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
event_data['num_attempts'] = self.num_attempts event_data['num_attempts'] = self.num_attempts
event_data['submitted_answer'] = submissions event_data['submitted_answer'] = submissions
self.runtime.publish(self, 'xblock.mentoring.assessment.submitted', event_data) self.runtime.publish(self, 'xblock.problem_builder.assessment.submitted', event_data)
return { return {
'completed': completed, 'completed': completed,
......
...@@ -46,7 +46,7 @@ function MentoringBlock(runtime, element) { ...@@ -46,7 +46,7 @@ function MentoringBlock(runtime, element) {
if (!clickedInside(question_feedback_selector, question_feedback_selector)) { if (!clickedInside(question_feedback_selector, question_feedback_selector)) {
$(question_feedback_selector).not(':hidden').each(function (i, el) { $(question_feedback_selector).not(':hidden').each(function (i, el) {
$(el).hide(); $(el).hide();
publish_event({event_type: 'xblock.mentoring.feedback.closed', content: $(el).text()}); publish_event({event_type: 'xblock.problem_builder.feedback.closed', content: $(el).text()});
}); });
} }
...@@ -118,5 +118,5 @@ function MentoringBlock(runtime, element) { ...@@ -118,5 +118,5 @@ function MentoringBlock(runtime, element) {
MentoringAssessmentView(runtime, element, mentoring); MentoringAssessmentView(runtime, element, mentoring);
} }
publish_event({event_type:"xblock.mentoring.loaded"}); publish_event({event_type:"xblock.problem_builder.loaded"});
} }
...@@ -112,7 +112,7 @@ function MentoringAssessmentView(runtime, element, mentoring) { ...@@ -112,7 +112,7 @@ function MentoringAssessmentView(runtime, element, mentoring) {
$(child.element).show(); $(child.element).show();
$(child.element).find("input, textarea").first().focus(); $(child.element).find("input, textarea").first().focus();
mentoring.publish_event({ mentoring.publish_event({
event_type: 'xblock.mentoring.assessment.shown', event_type: 'xblock.problem_builder.assessment.shown',
exercise_id: child.name exercise_id: child.name
}); });
......
function MentoringEditComponents(runtime, element) { function MentoringEditComponents(runtime, element) {
"use strict"; "use strict";
// Disable "add" buttons when a message of that type already exists: // Disable "add" buttons when a message of that type already exists:
var $buttons = $('.add-xblock-component-button[data-category=mentoring-message]', element); var $buttons = $('.add-xblock-component-button[data-category=pb-message]', element);
var updateButtons = function() { var updateButtons = function() {
$buttons.each(function() { $buttons.each(function() {
var msg_type = $(this).data('boilerplate'); var msg_type = $(this).data('boilerplate');
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="new-component"> <div class="new-component">
<ul class="new-component-type"> <ul class="new-component-type">
<li><a href="#" class="single-template add-xblock-component-button" data-category="html">{% trans "Add HTML" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="html">{% trans "Add HTML" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-answer-recap">{% trans "Add Answer Recap" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-answer-recap">{% trans "Add Answer Recap" %}</a></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="add-xblock-component new-component-item adding"> <div class="add-xblock-component new-component-item adding">
<div class="new-component"> <div class="new-component">
<ul class="new-component-type"> <ul class="new-component-type">
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-column">{% trans "Add Answer Recap Column" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-column">{% trans "Add Answer Recap Column" %}</a></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
<div class="new-component"> <div class="new-component">
<h5>{% trans "Add New Component" %}</h5> <h5>{% trans "Add New Component" %}</h5>
<ul class="new-component-type"> <ul class="new-component-type">
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-answer" data-boilerplate="studio_default">{% trans "Long Answer" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-answer" data-boilerplate="studio_default">{% trans "Long Answer" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-mcq">{% trans "Multiple Choice Question" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-mcq">{% trans "Multiple Choice Question" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-rating">{% trans "Rating Question" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-rating">{% trans "Rating Question" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-mrq">{% trans "Multiple Response Question" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-mrq">{% trans "Multiple Response Question" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="html">{% trans "HTML" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="html">{% trans "HTML" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-answer-recap">{% trans "Long Answer Recap" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-answer-recap">{% trans "Long Answer Recap" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-table">{% trans "Answer Recap Table" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-table">{% trans "Answer Recap Table" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-message" data-boilerplate="completed">{% trans "Message (Complete)" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="completed">{% trans "Message (Complete)" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-message" data-boilerplate="incomplete">{% trans "Message (Incomplete)" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="incomplete">{% trans "Message (Incomplete)" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-message" data-boilerplate="max_attempts_reached">{% trans "Message (Max # Attempts)" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="max_attempts_reached">{% trans "Message (Max # Attempts)" %}</a></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<div class="add-xblock-component new-component-item adding"> <div class="add-xblock-component new-component-item adding">
<div class="new-component"> <div class="new-component">
<ul class="new-component-type"> <ul class="new-component-type">
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-choice" data-boilerplate="studio_default">{% trans "Add Custom Choice" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-choice" data-boilerplate="studio_default">{% trans "Add Custom Choice" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="mentoring-tip">{% trans "Add Tip" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-tip">{% trans "Add Tip" %}</a></li>
</ul> </ul>
</div> </div>
</div> </div>
<mentoring display_name="Mentoring Assessment Example" weight="1" mode="assessment" max_attempts="10"> <problem-builder display_name="Mentoring Assessment Example" weight="1" mode="assessment" max_attempts="10">
<html_demo> <html_demo>
<p>This paragraph is shared between <strong>all</strong> questions.</p> <p>This paragraph is shared between <strong>all</strong> questions.</p>
<p>Please answer the questions below.</p> <p>Please answer the questions below.</p>
</html_demo> </html_demo>
<answer name="goal" question="What is your goal?"> <pb-answer name="goal" question="What is your goal?">
</answer> </pb-answer>
<mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes"> <pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great!</tip> <pb-tip values="yes">Great!</pb-tip>
<tip values="maybenot">Ah, damn.</tip> <pb-tip values="maybenot">Ah, damn.</pb-tip>
<tip values="understand"><div id="test-custom-html">Really?</div></tip> <pb-tip values="understand"><div id="test-custom-html">Really?</div></pb-tip>
</mcq> </pb-mcq>
<rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5"> <pb-rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5">
<choice value="notwant">I don't want to rate it</choice> <pb-choice value="notwant">I don't want to rate it</pb-choice>
<tip values="4,5">I love good grades.</tip> <pb-tip values="4,5">I love good grades.</pb-tip>
<tip values="1,2,3">Will do better next time...</tip> <pb-tip values="1,2,3">Will do better next time...</pb-tip>
<tip values="notwant">Your loss!</tip> <pb-tip values="notwant">Your loss!</pb-tip>
</rating> </pb-rating>
<mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices="gracefulness,elegance,beauty"> <pb-mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices="gracefulness,elegance,beauty">
<choice value="elegance">Its elegance</choice> <pb-choice value="elegance">Its elegance</pb-choice>
<choice value="beauty">Its beauty</choice> <pb-choice value="beauty">Its beauty</pb-choice>
<choice value="gracefulness">Its gracefulness</choice> <pb-choice value="gracefulness">Its gracefulness</pb-choice>
<choice value="bugs">Its bugs</choice> <pb-choice value="bugs">Its bugs</pb-choice>
<tip values="gracefulness">This MRQ is indeed very graceful</tip> <pb-tip values="gracefulness">This MRQ is indeed very graceful</pb-tip>
<tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip> <pb-tip values="elegance,beauty">This is something everyone has to like about this MRQ</pb-tip>
<tip values="bugs">Nah, there isn't any!</tip> <pb-tip values="bugs">Nah, there isn't any!</pb-tip>
</mrq> </pb-mrq>
</mentoring> </problem-builder>
<mentoring display_name="Default Title" weight="1" mode="standard"> <problem-builder display_name="Default Title" weight="1" mode="standard">
<html_demo> <html_demo>
<p>Please answer the questions below.</p> <p>Please answer the questions below.</p>
</html_demo> </html_demo>
<answer name="goal" question="What is your goal?"> <pb-answer name="goal" question="What is your goal?">
</answer> </pb-answer>
<mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes"> <pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great!</tip> <pb-tip values="yes">Great!</pb-tip>
<tip values="maybenot">Ah, damn.</tip> <pb-tip values="maybenot">Ah, damn.</pb-tip>
<tip values="understand"><div id="test-custom-html">Really?</div></tip> <pb-tip values="understand"><div id="test-custom-html">Really?</div></pb-tip>
</mcq> </pb-mcq>
<rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5"> <pb-rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5">
<choice value="notwant">I don't want to rate it</choice> <pb-choice value="notwant">I don't want to rate it</pb-choice>
<tip values="4,5">I love good grades.</tip> <pb-tip values="4,5">I love good grades.</pb-tip>
<tip values="1,2,3">Will do better next time...</tip> <pb-tip values="1,2,3">Will do better next time...</pb-tip>
<tip values="notwant">Your loss!</tip> <pb-tip values="notwant">Your loss!</pb-tip>
</rating> </pb-rating>
<mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices="gracefulness,elegance,beauty" message="Thank you for answering!"> <pb-mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices="gracefulness,elegance,beauty" message="Thank you for answering!">
<choice value="elegance">Its elegance</choice> <pb-choice value="elegance">Its elegance</pb-choice>
<choice value="beauty">Its beauty</choice> <pb-choice value="beauty">Its beauty</pb-choice>
<choice value="gracefulness">Its gracefulness</choice> <pb-choice value="gracefulness">Its gracefulness</pb-choice>
<choice value="bugs">Its bugs</choice> <pb-choice value="bugs">Its bugs</pb-choice>
<tip values="gracefulness">This MRQ is indeed very graceful</tip> <pb-tip values="gracefulness">This MRQ is indeed very graceful</pb-tip>
<tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip> <pb-tip values="elegance,beauty">This is something everyone has to like about this MRQ</pb-tip>
<tip values="bugs">Nah, there aren't any!</tip> <pb-tip values="bugs">Nah, there aren't any!</pb-tip>
</mrq> </pb-mrq>
<mentoring-message type="completed"> <pb-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</mentoring-message> </pb-message>
<mentoring-message type="incomplete"> <pb-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
<mentoring display_name="Default Title" weight="1" mode="standard"> <problem-builder display_name="Default Title" weight="1" mode="standard">
<html_demo> <html_demo>
<p>Please answer the questions below.</p> <p>Please answer the questions below.</p>
</html_demo> </html_demo>
<mrq name="mrq_1_1" question="What do you like in this MRQ?" message="Thank you for answering!" required_choices="gracefulness,elegance,beauty"> <pb-mrq name="mrq_1_1" question="What do you like in this MRQ?" message="Thank you for answering!" required_choices="gracefulness,elegance,beauty">
<choice value="elegance">Its elegance</choice> <pb-choice value="elegance">Its elegance</pb-choice>
<choice value="beauty">Its beauty</choice> <pb-choice value="beauty">Its beauty</pb-choice>
<choice value="gracefulness">Its gracefulness</choice> <pb-choice value="gracefulness">Its gracefulness</pb-choice>
<choice value="bugs">Its bugs</choice> <pb-choice value="bugs">Its bugs</pb-choice>
<tip values="gracefulness">This MRQ is indeed very graceful</tip> <pb-tip values="gracefulness">This MRQ is indeed very graceful</pb-tip>
<tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip> <pb-tip values="elegance,beauty">This is something everyone has to like about this MRQ</pb-tip>
<tip values="bugs">Nah, there aren't any!</tip> <pb-tip values="bugs">Nah, there aren't any!</pb-tip>
</mrq> </pb-mrq>
<mentoring-message type="completed"> <pb-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</mentoring-message> </pb-message>
<mentoring-message type="incomplete"> <pb-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
<vertical_demo> <vertical_demo>
<mentoring url_name="answer_blank_read_only" enforce_dependency="false"> <problem-builder url_name="answer_blank_read_only" enforce_dependency="false">
<answer-recap name="answer_blank" /> <pb-answer-recap name="answer_blank" />
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="answer_edit_1" enforce_dependency="false"> <problem-builder url_name="answer_edit_1" enforce_dependency="false">
<html_demo> <html_demo>
<p>This should be displayed in the answer_edit scenario</p> <p>This should be displayed in the answer_edit scenario</p>
</html_demo> </html_demo>
<answer name="answer_1" /> <pb-answer name="answer_1" />
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="answer_edit_2" enforce_dependency="false"> <problem-builder url_name="answer_edit_2" enforce_dependency="false">
<answer-recap name="answer_1" /> <pb-answer-recap name="answer_1" />
<answer name="answer_1" /> <pb-answer name="answer_1" />
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<mentoring url_name="mentoring-assessment-1" display_name="A Simple Assessment" weight="1" mode="assessment" max_attempts="2"> <problem-builder url_name="mentoring-assessment-1" display_name="A Simple Assessment" weight="1" mode="assessment" max_attempts="2">
<html_demo> <html_demo>
<p>This paragraph is shared between <strong>all</strong> questions.</p> <p>This paragraph is shared between <strong>all</strong> questions.</p>
...@@ -12,34 +12,34 @@ ...@@ -12,34 +12,34 @@
</html_demo> </html_demo>
<acid/> <acid/>
<answer name="goal" question="What is your goal?" /> <pb-answer name="goal" question="What is your goal?" />
<mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes"> <pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great!</tip> <pb-tip values="yes">Great!</pb-tip>
<tip values="maybenot">Ah, damn.</tip> <pb-tip values="maybenot">Ah, damn.</pb-tip>
<tip values="understand"><div id="test-custom-html">Really?</div></tip> <pb-tip values="understand"><div id="test-custom-html">Really?</div></pb-tip>
</mcq> </pb-mcq>
<rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5"> <pb-rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5">
<choice value="notwant">I don't want to rate it</choice> <pb-choice value="notwant">I don't want to rate it</pb-choice>
<tip values="4,5">I love good grades.</tip> <pb-tip values="4,5">I love good grades.</pb-tip>
<tip values="1,2,3">Will do better next time...</tip> <pb-tip values="1,2,3">Will do better next time...</pb-tip>
<tip values="notwant">Your loss!</tip> <pb-tip values="notwant">Your loss!</pb-tip>
</rating> </pb-rating>
<mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices="gracefulness,elegance,beauty"> <pb-mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices="gracefulness,elegance,beauty">
<choice value="elegance">Its elegance</choice> <pb-choice value="elegance">Its elegance</pb-choice>
<choice value="beauty">Its beauty</choice> <pb-choice value="beauty">Its beauty</pb-choice>
<choice value="gracefulness">Its gracefulness</choice> <pb-choice value="gracefulness">Its gracefulness</pb-choice>
<choice value="bugs">Its bugs</choice> <pb-choice value="bugs">Its bugs</pb-choice>
<tip values="gracefulness">This MRQ is indeed very graceful</tip> <pb-tip values="gracefulness">This MRQ is indeed very graceful</pb-tip>
<tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip> <pb-tip values="elegance,beauty">This is something everyone has to like about this MRQ</pb-tip>
<tip values="bugs">Nah, there isn't any!</tip> <pb-tip values="bugs">Nah, there isn't any!</pb-tip>
</mrq> </pb-mrq>
</mentoring> </problem-builder>
<mentoring url_name="mentoring-assessment-2" display_name="A Simple Assessment" weight="1" mode="assessment" max_attempts="2"> <problem-builder url_name="mentoring-assessment-2" display_name="A Simple Assessment" weight="1" mode="assessment" max_attempts="2">
<html_demo> <html_demo>
<p>This paragraph is shared between <strong>all</strong> questions.</p> <p>This paragraph is shared between <strong>all</strong> questions.</p>
<p>Please answer the questions below.</p> <p>Please answer the questions below.</p>
</html_demo> </html_demo>
<mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes"> <pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great!</tip> <pb-tip values="yes">Great!</pb-tip>
<tip values="maybenot">Ah, damn.</tip> <pb-tip values="maybenot">Ah, damn.</pb-tip>
<tip values="understand"><div id="test-custom-html">Really?</div></tip> <pb-tip values="understand"><div id="test-custom-html">Really?</div></pb-tip>
</mcq> </pb-mcq>
</mentoring> </problem-builder>
<vertical_demo> <vertical_demo>
<mentoring url_name="mcq_1" enforce_dependency="false"> <problem-builder url_name="mcq_1" enforce_dependency="false">
<mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes"> <pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great!</tip> <pb-tip values="yes">Great!</pb-tip>
<tip values="maybenot">Ah, damn.</tip> <pb-tip values="maybenot">Ah, damn.</pb-tip>
<tip values="understand"><div id="test-custom-html">Really?</div></tip> <pb-tip values="understand"><div id="test-custom-html">Really?</div></pb-tip>
</mcq> </pb-mcq>
<rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How do you rate this MCQ?" correct_choices="4,5"> <pb-rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How do you rate this MCQ?" correct_choices="4,5">
<choice value="notwant">I don't want to rate it</choice> <pb-choice value="notwant">I don't want to rate it</pb-choice>
<tip values="4,5">I love good grades.</tip> <pb-tip values="4,5">I love good grades.</pb-tip>
<tip values="1,2,3">Will do better next time...</tip> <pb-tip values="1,2,3">Will do better next time...</pb-tip>
<tip values="notwant">Your loss!</tip> <pb-tip values="notwant">Your loss!</pb-tip>
</rating> </pb-rating>
<mentoring-message type="completed"> <pb-message type="completed">
All is good now... All is good now...
<p>Congratulations!</p> <p>Congratulations!</p>
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="mcq_with_comments" display_name="MRQ With Resizable popups" weight="1" enforce_dependency="false"> <problem-builder url_name="mcq_with_comments" display_name="MRQ With Resizable popups" weight="1" enforce_dependency="false">
<mrq name="mrq_1_1_7" question="What do you like in this MRQ?" required_choices="elegance,gracefulness,beauty"> <pb-mrq name="mrq_1_1_7" question="What do you like in this MRQ?" required_choices="elegance,gracefulness,beauty">
<choice value="elegance">Its elegance</choice> <pb-choice value="elegance">Its elegance</pb-choice>
<choice value="beauty">Its beauty</choice> <pb-choice value="beauty">Its beauty</pb-choice>
<choice value="gracefulness">Its gracefulness</choice> <pb-choice value="gracefulness">Its gracefulness</pb-choice>
<choice value="bugs">Its bugs</choice> <pb-choice value="bugs">Its bugs</pb-choice>
<tip values="gracefulness" width ="200" height = "200">This MRQ is indeed very graceful</tip> <pb-tip values="gracefulness" width ="200" height = "200">This MRQ is indeed very graceful</pb-tip>
<tip values="elegance" width ="600" height = "800">This is something everyone has to like about this MRQ</tip> <pb-tip values="elegance" width ="600" height = "800">This is something everyone has to like about this MRQ</pb-tip>
<tip values="beauty" width ="400" height = "600">This is something everyone has to like about beauty</tip> <pb-tip values="beauty" width ="400" height = "600">This is something everyone has to like about beauty</pb-tip>
<tip values="bugs" width = "100" height = "200">Nah, there isn\'t any!</tip> <pb-tip values="bugs" width = "100" height = "200">Nah, there isn\'t any!</pb-tip>
<!--<message type="on-submit">This is deliberately commented out to test parsing of XML comments</message> --> <!--<pb-message type="on-submit">This is deliberately commented out to test parsing of XML comments</pb-message> -->
</mrq> </pb-mrq>
<mentoring-message type="completed"> <pb-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</mentoring-message> </pb-message>
<mentoring-message type="incomplete"> <pb-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="mcq_with_comments" display_name="MCQ With Resizable popups" weight="1" enforce_dependency="false"> <problem-builder url_name="mcq_with_comments" display_name="MCQ With Resizable popups" weight="1" enforce_dependency="false">
<mcq name="mrq_1_1_7" question="What do you like in this MCQ?" correct_choices="gracefulness,elegance,beauty"> <pb-mcq name="mrq_1_1_7" question="What do you like in this MCQ?" correct_choices="gracefulness,elegance,beauty">
<choice value="elegance"><strong>Its elegance</strong></choice> <pb-choice value="elegance"><strong>Its elegance</strong></pb-choice>
<choice value="beauty"><em>Its beauty</em></choice> <pb-choice value="beauty"><em>Its beauty</em></pb-choice>
<choice value="gracefulness"><strong>Its gracefulness</strong></choice> <pb-choice value="gracefulness"><strong>Its gracefulness</strong></pb-choice>
<choice value="bugs"><span style="font-color:red">Its bugs</span></choice> <pb-choice value="bugs"><span style="font-color:red">Its bugs</span></pb-choice>
<tip values="gracefulness" width ="200" height = "200">This MCQ is indeed very graceful</tip> <pb-tip values="gracefulness" width ="200" height = "200">This MCQ is indeed very graceful</pb-tip>
<tip values="elegance" width ="600" height = "800">This is something everyone has to like about this MCQ</tip> <pb-tip values="elegance" width ="600" height = "800">This is something everyone has to like about this MCQ</pb-tip>
<tip values="beauty" width ="400" height = "600">This is something everyone has to like about beauty</tip> <pb-tip values="beauty" width ="400" height = "600">This is something everyone has to like about beauty</pb-tip>
<tip values="bugs" width = "100" height = "200">Nah, there isn\'t any!</tip> <pb-tip values="bugs" width = "100" height = "200">Nah, there isn\'t any!</pb-tip>
</mcq> </pb-mcq>
<mentoring-message type="completed"> <pb-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</mentoring-message> </pb-message>
<mentoring-message type="incomplete"> <pb-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="mcq_with_comments" display_name="MRQ With Resizable popups" weight="1" enforce_dependency="false"> <problem-builder url_name="mcq_with_comments" display_name="MRQ With Resizable popups" weight="1" enforce_dependency="false">
<mrq name="mrq_1_1_7" question="What do you like in this MRQ?" required_choices="elegance,beauty,gracefulness"> <pb-mrq name="mrq_1_1_7" question="What do you like in this MRQ?" required_choices="elegance,beauty,gracefulness">
<choice value="elegance"><strong>Its elegance</strong></choice> <pb-choice value="elegance"><strong>Its elegance</strong></pb-choice>
<choice value="beauty"><em>Its beauty</em></choice> <pb-choice value="beauty"><em>Its beauty</em></pb-choice>
<choice value="gracefulness"><strong>Its gracefulness</strong></choice> <pb-choice value="gracefulness"><strong>Its gracefulness</strong></pb-choice>
<choice value="bugs"><span style="font-color:red">Its bugs</span></choice> <pb-choice value="bugs"><span style="font-color:red">Its bugs</span></pb-choice>
<tip values="gracefulness" width ="200" height = "200">This MRQ is indeed very graceful</tip> <pb-tip values="gracefulness" width ="200" height = "200">This MRQ is indeed very graceful</pb-tip>
<tip values="elegance" width ="600" height = "800">This is something everyone has to like about this MRQ</tip> <pb-tip values="elegance" width ="600" height = "800">This is something everyone has to like about this MRQ</pb-tip>
<tip values="beauty" width ="400" height = "600">This is something everyone has to like about beauty</tip> <pb-tip values="beauty" width ="400" height = "600">This is something everyone has to like about beauty</pb-tip>
<tip values="bugs" width = "100" height = "200">Nah, there aren\'t any!</tip> <pb-tip values="bugs" width = "100" height = "200">Nah, there aren\'t any!</pb-tip>
</mrq> </pb-mrq>
<mentoring-message type="completed"> <pb-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</mentoring-message> </pb-message>
<mentoring-message type="incomplete"> <pb-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="answer_no_display_submit" enforce_dependency="false" display_submit="false"> <problem-builder url_name="answer_no_display_submit" enforce_dependency="false" display_submit="false">
<answer name="answer_blank"/> <pb-answer name="answer_blank"/>
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="mentoring_first" followed_by="progression_2" enforce_dependency="true"> <problem-builder url_name="mentoring_first" followed_by="progression_2" enforce_dependency="true">
<answer name="progression_1_answer" /> <pb-answer name="progression_1_answer" />
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="progression_2" followed_by="progression_3" enforce_dependency="true"> <problem-builder url_name="progression_2" followed_by="progression_3" enforce_dependency="true">
<answer name="progression_2_answer" /> <pb-answer name="progression_2_answer" />
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="progression_3" enforce_dependency="true"> <problem-builder url_name="progression_3" enforce_dependency="true">
<answer name="progression_3_answer" /> <pb-answer name="progression_3_answer" />
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring enforce_dependency="false"> <problem-builder enforce_dependency="false">
<answer name="table_1_answer_1" /> <pb-answer name="table_1_answer_1" />
<answer name="table_1_answer_2" /> <pb-answer name="table_1_answer_2" />
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring display_submit="false" enforce_dependency="false"> <problem-builder display_submit="false" enforce_dependency="false">
<mentoring-table> <pb-table>
<mentoring-column header="Header Test 1"> <pb-column header="Header Test 1">
<answer-recap name="table_1_answer_1"/> <pb-answer-recap name="table_1_answer_1"/>
</mentoring-column> </pb-column>
<mentoring-column header="Header Test 2"> <pb-column header="Header Test 2">
<answer-recap name="table_1_answer_2"/> <pb-answer-recap name="table_1_answer_2"/>
</mentoring-column> </pb-column>
</mentoring-table> </pb-table>
</mentoring> </problem-builder>
</vertical_demo> </vertical_demo>
<mentoring url_name="mentoring-assessment-2" display_name="A Simple Assessment" weight="1" mode="assessment" max_attempts="2"> <problem-builder url_name="mentoring-assessment-2" display_name="A Simple Assessment" weight="1" mode="assessment" max_attempts="2">
<html_demo> <html_demo>
<p>This paragraph is shared between <strong>all</strong> questions.</p> <p>This paragraph is shared between <strong>all</strong> questions.</p>
<p>Please answer the questions below.</p> <p>Please answer the questions below.</p>
</html_demo> </html_demo>
<mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes"> <pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great!</tip> <pb-tip values="yes">Great!</pb-tip>
<tip values="maybenot">Ah, damn.</tip> <pb-tip values="maybenot">Ah, damn.</pb-tip>
<tip values="understand"><div id="test-custom-html">Really?</div></tip> <pb-tip values="understand"><div id="test-custom-html">Really?</div></pb-tip>
</mcq> </pb-mcq>
</mentoring> </problem-builder>
<mentoring url_name="some_url_name" weight="1" mode="standard" display_name="Default Title"> <problem-builder url_name="some_url_name" weight="1" mode="standard" display_name="Default Title">
<html> <html>
<p>This paragraph is shared between <strong>all</strong> questions.</p> <p>This paragraph is shared between <strong>all</strong> questions.</p>
</html> </html>
<html> <html>
<p>Please answer the questions below.</p> <p>Please answer the questions below.</p>
</html> </html>
<answer name="goal" question="What is your goal?"/> <pb-answer name="goal" question="What is your goal?"/>
<mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes"> <pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices="yes">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great!</tip> <pb-tip values="yes">Great!</pb-tip>
<tip values="maybenot">Ah, damn.</tip> <pb-tip values="maybenot">Ah, damn.</pb-tip>
<tip values="understand"> <pb-tip values="understand">
<div id="test-custom-html">Really?</div> <div id="test-custom-html">Really?</div>
</tip> </pb-tip>
</mcq> </pb-mcq>
<rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5"> <pb-rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices="4,5">
<choice value="notwant">I don't want to rate it</choice> <pb-choice value="notwant">I don't want to rate it</pb-choice>
<tip values="4,5">I love good grades.</tip> <pb-tip values="4,5">I love good grades.</pb-tip>
<tip values="1,2,3">Will do better next time...</tip> <pb-tip values="1,2,3">Will do better next time...</pb-tip>
<tip values="notwant">Your loss!</tip> <pb-tip values="notwant">Your loss!</pb-tip>
</rating> </pb-rating>
<mrq name="mrq_1_1" question="What do you like in this MRQ?" message="Thank you for answering!" required_choices="gracefulness,elegance,beauty"> <pb-mrq name="mrq_1_1" question="What do you like in this MRQ?" message="Thank you for answering!" required_choices="gracefulness,elegance,beauty">
<choice value="elegance">Its elegance</choice> <pb-choice value="elegance">Its elegance</pb-choice>
<choice value="beauty">Its beauty</choice> <pb-choice value="beauty">Its beauty</pb-choice>
<choice value="gracefulness">Its gracefulness</choice> <pb-choice value="gracefulness">Its gracefulness</pb-choice>
<choice value="bugs">Its bugs</choice> <pb-choice value="bugs">Its bugs</pb-choice>
<tip values="gracefulness">This MRQ is indeed very graceful</tip> <pb-tip values="gracefulness">This MRQ is indeed very graceful</pb-tip>
<tip values="elegance,beauty">This is something everyone has to like about this MRQ</tip> <pb-tip values="elegance,beauty">This is something everyone has to like about this MRQ</pb-tip>
<tip values="bugs">Nah, there isn't any!</tip> <pb-tip values="bugs">Nah, there isn't any!</pb-tip>
</mrq> </pb-mrq>
<mentoring-message type="completed"> <pb-message type="completed">
<p>Congratulations!</p> <p>Congratulations!</p>
</mentoring-message> </pb-message>
<mentoring-message type="incomplete"> <pb-message type="incomplete">
<p>Still some work to do...</p> <p>Still some work to do...</p>
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
<mentoring enforce_dependency="false" followed_by="past_attempts"> <problem-builder enforce_dependency="false" followed_by="past_attempts">
<html> <html>
<h3>Checking your improvement frog</h3> <h3>Checking your improvement frog</h3>
<p>Now, let's make sure your frog meets the criteria for a strong column 1. Here is your frog:</p> <p>Now, let's make sure your frog meets the criteria for a strong column 1. Here is your frog:</p>
</html> </html>
<answer-recap name="improvement-frog"/> <pb-answer-recap name="improvement-frog"/>
<mcq name="frog-happy" question="Is this frog happy for you?" correct_choices="yes,maybenot,understand"> <pb-mcq name="frog-happy" question="Is this frog happy for you?" correct_choices="yes,maybenot,understand">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great. Your frog should be happy for you.</tip> <pb-tip values="yes">Great. Your frog should be happy for you.</pb-tip>
<tip values="maybenot">In the end, all the feedback you have gotten from others should not lead you to choose a frog that does not also feel happy and important to you.</tip> <pb-tip values="maybenot">In the end, all the feedback you have gotten from others should not lead you to choose a frog that does not also feel happy and important to you.</pb-tip>
<tip values="understand"> <pb-tip values="understand">
<p>If a frog is <span class="italic">happy for you</span>, that means it is a frog that you genuinely feel in your own heart to be something that you want to improve. What is in your heart?</p> <p>If a frog is <span class="italic">happy for you</span>, that means it is a frog that you genuinely feel in your own heart to be something that you want to improve. What is in your heart?</p>
</tip> </pb-tip>
</mcq> </pb-mcq>
<mcq name="frog-implicate" question="Does this frog implicate you?" correct_choices="yes,maybenot,understand"> <pb-mcq name="frog-implicate" question="Does this frog implicate you?" correct_choices="yes,maybenot,understand">
<choice value="yes">Yes</choice> <pb-choice value="yes">Yes</pb-choice>
<choice value="maybenot">Maybe not</choice> <pb-choice value="maybenot">Maybe not</pb-choice>
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="yes">Great. Your frog should implicate you.</tip> <pb-tip values="yes">Great. Your frog should implicate you.</pb-tip>
<tip values="maybenot"> <pb-tip values="maybenot">
<p>Since the Trial of Uruk-Shan focuses on your own growth and change, it is important to be clear about the ways <span class="bold">you</span> are hoping to change and improve.</p> <p>Since the Trial of Uruk-Shan focuses on your own growth and change, it is important to be clear about the ways <span class="bold">you</span> are hoping to change and improve.</p>
</tip> </pb-tip>
<tip values="understand">Your frog implicates you if it is clear that you must get better at something. Your frog should focus on something you can control.</tip> <pb-tip values="understand">Your frog implicates you if it is clear that you must get better at something. Your frog should focus on something you can control.</pb-tip>
</mcq> </pb-mcq>
<rating name="frog-important" low="Not at all important to me" high="Very important to me" question="How important is it to you?" correct_choices="4,5,1,2,3,understand"> <pb-rating name="frog-important" low="Not at all important to me" high="Very important to me" question="How important is it to you?" correct_choices="4,5,1,2,3,understand">
<choice value="understand">I don't understand</choice> <pb-choice value="understand">I don't understand</pb-choice>
<tip values="4,5">Great!</tip> <pb-tip values="4,5">Great!</pb-tip>
<tip values="1,2,3">The Trial of Uruk-Shan helps you uncover some of the core beliefs and assumptions you have held that are preventing you from making change.</tip> <pb-tip values="1,2,3">The Trial of Uruk-Shan helps you uncover some of the core beliefs and assumptions you have held that are preventing you from making change.</pb-tip>
<tip values="understand">A frog is important if it is one that could make a big difference in helping you reach your frogs in your work life or your personal life (or both).</tip> <pb-tip values="understand">A frog is important if it is one that could make a big difference in helping you reach your frogs in your work life or your personal life (or both).</pb-tip>
</rating> </pb-rating>
<mentoring-message type="completed"> <pb-message type="completed">
Great! You have indicated that you have chosen a frog that is happy for you, implicates you, has room for improvement, and is important to you. You are now ready to move onto the next step. Great! You have indicated that you have chosen a frog that is happy for you, implicates you, has room for improvement, and is important to you. You are now ready to move onto the next step.
</mentoring-message> </pb-message>
</mentoring> </problem-builder>
<mentoring display_submit="false" enforce_dependency="false"> <problem-builder display_submit="false" enforce_dependency="false">
<mentoring-table type="table_test" url_name="table_2"> <pb-table type="table_test" url_name="table_2">
<mentoring-column header="Header Test 1"> <pb-column header="Header Test 1">
<answer-recap name="table_1_answer_1" /> <pb-answer-recap name="table_1_answer_1" />
</mentoring-column> </pb-column>
<mentoring-column header="Header &lt;strong&gt;Test 2&lt;/strong&gt;"> <pb-column header="Header &lt;strong&gt;Test 2&lt;/strong&gt;">
<answer-recap name="table_1_answer_2" /> <pb-answer-recap name="table_1_answer_2" />
<html><p>Inline HTML</p></html> <html><p>Inline HTML</p></html>
<answer-recap name="table_1_answer_2" /> <pb-answer-recap name="table_1_answer_2" />
</mentoring-column> </pb-column>
</mentoring-table> </pb-table>
</mentoring> </problem-builder>
...@@ -43,11 +43,33 @@ class Change(object): ...@@ -43,11 +43,33 @@ class Change(object):
raise NotImplementedError raise NotImplementedError
class RenameMentoringTag(Change):
"""
Replace <mentoring> with <problem-builder>
"""
@staticmethod
def applies_to(node):
return node.tag == "mentoring"
def apply(self):
self.node.tag = "problem-builder"
class PrefixTags(Change):
""" Most old elements now get a pb- prefix """
@staticmethod
def applies_to(node):
return node.tag in ("tip", "choice", "answer", "mcq", "mrq", "rating", "column", "message")
def apply(self):
self.node.tag = "pb-" + self.node.tag
class RemoveTitle(Change): class RemoveTitle(Change):
""" The old <title> element is now an attribute of <mentoring> """ """ The old <title> element is now an attribute of <mentoring> """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "title" and node.getparent().tag == "mentoring" return node.tag == "title" and node.getparent().tag == "problem-builder"
def apply(self): def apply(self):
title = self.node.text.strip() title = self.node.text.strip()
...@@ -60,10 +82,10 @@ class RemoveTitle(Change): ...@@ -60,10 +82,10 @@ class RemoveTitle(Change):
class UnwrapHTML(Change): class UnwrapHTML(Change):
""" <choice>,<tip>, <header>, and <message> now contain HTML without an explicit <html> wrapper. """ """ <pb-choice>,<pb-tip>, <header>, and <pb-message> now contain HTML without an explicit <html> wrapper. """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "html" and node.getparent().tag in ("choice", "tip", "message", "header") return node.tag == "html" and node.getparent().tag in ("pb-choice", "pb-tip", "pb-message", "header")
def apply(self): def apply(self):
p = self.node.getparent() p = self.node.getparent()
...@@ -76,28 +98,39 @@ class UnwrapHTML(Change): ...@@ -76,28 +98,39 @@ class UnwrapHTML(Change):
p.remove(self.node) p.remove(self.node)
class RenameTableTag(Change):
"""
Replace <mentoring-table> with <pb-table>
"""
@staticmethod
def applies_to(node):
return node.tag == "mentoring-table"
def apply(self):
self.node.tag = "pb-table"
class TableColumnHeader(Change): class TableColumnHeader(Change):
""" """
Replace: Replace:
<mentoring-table> <pb-table>
<column> <pb-column>
<header>Answer 1</header> <header>Answer 1</header>
<answer name="answer_1" /> <answer name="answer_1" />
</column> </pb-column>
</mentoring-table> </pb-table>
with with
<mentoring-table> <pb-table>
<mentoring-column header="Answer 1"> <pb-column header="Answer 1">
<answer-recap name="answer_1" /> <answer-recap name="answer_1" />
</mentoring-column> </pb-column>
</mentoring-table> </pb-table>
""" """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "column" and node.getparent().tag == "mentoring-table" return node.tag == "pb-column" and node.getparent().tag == "pb-table"
def apply(self): def apply(self):
self.node.tag = "mentoring-column"
header_html = u"" header_html = u""
to_remove = [] to_remove = []
for child in list(self.node): for child in list(self.node):
...@@ -107,12 +140,12 @@ class TableColumnHeader(Change): ...@@ -107,12 +140,12 @@ class TableColumnHeader(Change):
for grandchild in list(child): for grandchild in list(child):
header_html += etree.tostring(grandchild) header_html += etree.tostring(grandchild)
to_remove.append(child) to_remove.append(child)
elif child.tag == "answer": elif child.tag == "pb-answer":
child.tag = "answer-recap" child.tag = "pb-answer-recap"
if "read_only" in child.attrib: if "read_only" in child.attrib:
del child.attrib["read_only"] del child.attrib["read_only"]
elif child.tag != "html": elif child.tag != "html":
warnings.warn("Invalid <column> element: Unexpected <{}>".format(child.tag)) warnings.warn("Invalid <pb-column> element: Unexpected <{}>".format(child.tag))
return return
for child in to_remove: for child in to_remove:
self.node.remove(child) self.node.remove(child)
...@@ -121,49 +154,36 @@ class TableColumnHeader(Change): ...@@ -121,49 +154,36 @@ class TableColumnHeader(Change):
self.node.attrib["header"] = header_html self.node.attrib["header"] = header_html
class PrefixMessageElements(Change):
"""
<message> is renamed to <mentoring-message> since it only works as a direct child of
<mentoring> and <message> could collide with other future XBlocks.
"""
@staticmethod
def applies_to(node):
return node.tag == "message" and node.getparent().tag == "mentoring"
def apply(self):
self.node.tag = "mentoring-message"
class QuizzToMCQ(Change): class QuizzToMCQ(Change):
""" <quizz> element was an alias for <mcq>. In v2 we only have <mcq> """ """ <quizz> element was an alias for <mcq>. In v2 we only have <pb-mcq> """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "quizz" return node.tag == "quizz"
def apply(self): def apply(self):
self.node.tag = "mcq" self.node.tag = "pb-mcq"
class MCQToRating(Change): class MCQToRating(Change):
""" <mcq type="rating"> is now just <rating>, and we never use type="choices" on MCQ/MRQ """ """ <mcq type="rating"> is now just <rating>, and we never use type="choices" on MCQ/MRQ """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag in ("mcq", "mrq") and "type" in node.attrib return node.tag in ("pb-mcq", "pb-mrq") and "type" in node.attrib
def apply(self): def apply(self):
if self.node.tag == "mcq" and self.node.get("type") == "rating": if self.node.tag == "pb-mcq" and self.node.get("type") == "rating":
self.node.tag = "rating" self.node.tag = "pb-rating"
self.node.attrib.pop("type") # Type attribute is no longer used. self.node.attrib.pop("type") # Type attribute is no longer used.
class ReadOnlyAnswerToRecap(Change): class ReadOnlyAnswerToRecap(Change):
""" <answer read_only="true"> is now <answer-recap/> """ """ <answer read_only="true"> is now <pb-answer-recap/> """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "answer" and node.get("read_only") == "true" return node.tag == "pb-answer" and node.get("read_only") == "true"
def apply(self): def apply(self):
self.node.tag = "answer-recap" self.node.tag = "pb-answer-recap"
self.node.attrib self.node.attrib
self.node.attrib.pop("read_only") self.node.attrib.pop("read_only")
for name in self.node.attrib: for name in self.node.attrib:
...@@ -183,7 +203,7 @@ class QuestionToField(Change): ...@@ -183,7 +203,7 @@ class QuestionToField(Change):
""" """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
parent_tags = ("answer", "mcq", "mrq", "rating") parent_tags = ("pb-answer", "pb-mcq", "pb-mrq", "pb-rating")
return node.tag == "question" and node.getparent().tag in parent_tags return node.tag == "question" and node.getparent().tag in parent_tags
def apply(self): def apply(self):
...@@ -206,7 +226,11 @@ class QuestionSubmitMessageToField(Change): ...@@ -206,7 +226,11 @@ class QuestionSubmitMessageToField(Change):
""" """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "message" and node.get("type") == "on-submit" and node.getparent().tag in ("mcq", "mrq") return (
node.tag == "pb-message" and
node.get("type") == "on-submit" and
node.getparent().tag in ("pb-mcq", "pb-mrq")
)
def apply(self): def apply(self):
if list(self.node): if list(self.node):
...@@ -223,7 +247,7 @@ class TipChanges(Change): ...@@ -223,7 +247,7 @@ class TipChanges(Change):
""" """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "tip" and node.getparent().tag in ("mcq", "mrq", "rating") return node.tag == "pb-tip" and node.getparent().tag in ("pb-mcq", "pb-mrq", "pb-rating")
def apply(self): def apply(self):
p = self.node.getparent() p = self.node.getparent()
...@@ -239,7 +263,7 @@ class TipChanges(Change): ...@@ -239,7 +263,7 @@ class TipChanges(Change):
return return
mode = self.node.attrib.keys()[0] mode = self.node.attrib.keys()[0]
value = self.node.attrib[mode] value = self.node.attrib[mode]
if p.tag == "mrq": if p.tag == "pb-mrq":
if mode == "display": if mode == "display":
add_to_list("ignored_choices", value) add_to_list("ignored_choices", value)
elif mode == "require": elif mode == "require":
...@@ -262,7 +286,7 @@ class SharedHeaderToHTML(Change): ...@@ -262,7 +286,7 @@ class SharedHeaderToHTML(Change):
""" <shared-header> element no longer exists. Just use <html> """ """ <shared-header> element no longer exists. Just use <html> """
@staticmethod @staticmethod
def applies_to(node): def applies_to(node):
return node.tag == "shared-header" and node.getparent().tag == "mentoring" return node.tag == "shared-header" and node.getparent().tag == "problem-builder"
def apply(self): def apply(self):
self.node.tag = "html" self.node.tag = "html"
...@@ -270,10 +294,12 @@ class SharedHeaderToHTML(Change): ...@@ -270,10 +294,12 @@ class SharedHeaderToHTML(Change):
# An *ordered* list of all XML schema changes: # An *ordered* list of all XML schema changes:
xml_changes = ( xml_changes = (
RenameMentoringTag,
PrefixTags,
RemoveTitle, RemoveTitle,
UnwrapHTML, UnwrapHTML,
RenameTableTag,
TableColumnHeader, TableColumnHeader,
PrefixMessageElements,
QuizzToMCQ, QuizzToMCQ,
MCQToRating, MCQToRating,
ReadOnlyAnswerToRecap, ReadOnlyAnswerToRecap,
......
...@@ -40,26 +40,35 @@ def package_data(pkg, root_list): ...@@ -40,26 +40,35 @@ def package_data(pkg, root_list):
# Main ############################################################## # Main ##############################################################
BLOCKS = [ BLOCKS = [
'mentoring = mentoring:MentoringBlock', 'problem-builder = mentoring:MentoringBlock',
'mentoring = mentoring:MentoringBlock', # Deprecated alias for problem-builder. Required to import older blocks.
'mentoring-table = mentoring:MentoringTableBlock', 'pb-table = mentoring:MentoringTableBlock',
'mentoring-column = mentoring:MentoringTableColumn', 'pb-column = mentoring:MentoringTableColumn',
'answer = mentoring:AnswerBlock', 'pb-answer = mentoring:AnswerBlock',
'answer-recap = mentoring:AnswerRecapBlock', 'pb-answer-recap = mentoring:AnswerRecapBlock',
'mcq = mentoring:MCQBlock', 'pb-mcq = mentoring:MCQBlock',
'rating = mentoring:RatingBlock', 'pb-rating = mentoring:RatingBlock',
'mrq = mentoring:MRQBlock', 'pb-mrq = mentoring:MRQBlock',
'mentoring-message = mentoring:MentoringMessageBlock', 'pb-message = mentoring:MentoringMessageBlock',
'tip = mentoring:TipBlock', 'pb-tip = mentoring:TipBlock',
'choice = mentoring:ChoiceBlock', 'pb-choice = mentoring:ChoiceBlock',
# Deprecated: # Deprecated. You can temporarily uncomment and run 'python setup.py develop' if you have these blocks
'mentoring-answer = mentoring:AnswerBlock', # installed from testing mentoring v2 and need to get past an error message.
'mentoring-answer-recap = mentoring:AnswerRecapBlock', #'answer = mentoring:AnswerBlock',
'mentoring-mcq = mentoring:MCQBlock', #'mentoring-answer = mentoring:AnswerBlock',
'mentoring-rating = mentoring:RatingBlock', #'answer-recap = mentoring:AnswerRecapBlock',
'mentoring-mrq = mentoring:MRQBlock', #'mentoring-answer-recap = mentoring:AnswerRecapBlock',
'mentoring-tip = mentoring:TipBlock', #'mcq = mentoring:MCQBlock',
'mentoring-choice = mentoring:ChoiceBlock', #'mentoring-mcq = mentoring:MCQBlock',
#'rating = mentoring:RatingBlock',
#'mentoring-rating = mentoring:RatingBlock',
#'mrq = mentoring:MRQBlock',
#'mentoring-mrq = mentoring:MRQBlock',
#'tip = mentoring:TipBlock',
#'mentoring-tip = mentoring:TipBlock',
#'choice = mentoring:ChoiceBlock',
#'mentoring-choice = mentoring:ChoiceBlock',
] ]
setup( setup(
......
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