Commit 59d2b222 by Braden MacDonald

Changes to get mentoring assessments working.

parent 6598d2b0
......@@ -37,7 +37,7 @@ from xblock.fragment import Fragment
from components.title import TitleBlock
from components.header import SharedHeaderBlock
from components.message import MentoringMessageBlock
from components.step import StepParentMixin
from components.step import StepParentMixin, StepMixin
from xblockutils.resources import ResourceLoader
......@@ -375,8 +375,9 @@ class MentoringBlock(XBlock, StepParentMixin):
completed = False
current_child = None
children = [child for child in self.get_children_objects()
if not isinstance(child, self.FLOATING_BLOCKS)]
children = [self.runtime.get_block(child_id) for child_id in self.children]
children = [child for child in children if not isinstance(child, self.FLOATING_BLOCKS)]
steps = [child for child in children if isinstance(child, StepMixin)] # Faster than the self.steps property
for child in children:
if child.name and child.name in submissions:
......@@ -385,7 +386,7 @@ class MentoringBlock(XBlock, StepParentMixin):
# Assessment mode doesn't allow to modify answers
# This will get the student back at the step he should be
current_child = child
step = children.index(child)
step = steps.index(child)
if self.step > step or self.max_attempts_reached:
step = self.step
completed = False
......@@ -397,14 +398,13 @@ class MentoringBlock(XBlock, StepParentMixin):
if 'tips' in child_result:
del child_result['tips']
self.student_results.append([child.name, child_result])
child.save()
completed = child_result['status']
event_data = {}
score = self.score
if current_child == self.steps[-1]:
if current_child == steps[-1]:
log.info(u'Last assessment step submitted: {}'.format(submissions))
if not self.max_attempts_reached:
self.runtime.publish(self, 'grade', {
......@@ -421,7 +421,7 @@ class MentoringBlock(XBlock, StepParentMixin):
event_data['num_attempts'] = self.num_attempts
event_data['submitted_answer'] = submissions
self.publish_event_from_dict('xblock.mentoring.assessment.submitted', event_data)
self.runtime.publish(self, 'xblock.mentoring.assessment.submitted', event_data)
return {
'completed': completed,
......
......@@ -12,6 +12,7 @@ function MentoringBlock(runtime, element) {
children: children,
initChildren: initChildren,
getChildByName: getChildByName,
hideAllChildren: hideAllChildren,
step: step,
publish_event: publish_event
};
......@@ -87,7 +88,13 @@ function MentoringBlock(runtime, element) {
}
}
function getChildByName(element, name) {
function hideAllChildren() {
for (var i=0; i < children.length; i++) {
$(children[i].element).hide();
}
}
function getChildByName(name) {
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child && child.name === name) {
......
......@@ -13,8 +13,8 @@ function MentoringAssessmentView(runtime, element, mentoring) {
checkmark.removeClass('checkmark-partially-correct icon-ok fa-check');
checkmark.removeClass('checkmark-incorrect icon-exclamation fa-exclamation');
/* hide all children */
$(':nth-child(2)', mentoring.children_dom).remove();
// hide all children
mentoring.hideAllChildren();
$('.grade').html('');
$('.attempts').html('');
......@@ -77,7 +77,11 @@ function MentoringAssessmentView(runtime, element, mentoring) {
tryAgainDOM.bind('click', tryAgain);
active_child = mentoring.step-1;
mentoring.readChildren();
var options = {
onChange: onChange
};
mentoring.initChildren(options);
displayNextChild();
mentoring.renderDependency();
......@@ -92,24 +96,16 @@ function MentoringAssessmentView(runtime, element, mentoring) {
}
function displayNextChild() {
var options = {
onChange: onChange
};
cleanAll();
// find the next real child block to display. HTMLBlock are always displayed
++active_child;
while (1) {
var child = mentoring.displayChild(active_child, options);
active_child++;
var child = mentoring.children[active_child];
$(child.element).show();
mentoring.publish_event({
event_type: 'xblock.mentoring.assessment.shown',
exercise_id: $(child).attr('name')
exercise_id: child.name
});
if ((typeof child !== 'undefined') || active_child == mentoring.children.length-1)
break;
++active_child;
}
if (isDone())
renderGrade();
......@@ -151,8 +147,7 @@ function MentoringAssessmentView(runtime, element, mentoring) {
if (result.step != active_child+1) {
active_child = result.step-1;
displayNextChild();
}
else {
} else {
nextDOM.removeAttr("disabled");
reviewDOM.removeAttr("disabled");
}
......
......@@ -10,7 +10,7 @@ function MentoringStandardView(runtime, element, mentoring) {
$.each(results.submitResults || [], function(index, submitResult) {
var input = submitResult[0];
var result = submitResult[1];
var child = mentoring.getChildByName(element, input);
var child = mentoring.getChildByName(input);
var options = {
max_attempts: results.max_attempts,
num_attempts: results.num_attempts
......
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