Commit 0d915cc4 by dragonfi

pep8

parent bcf736a6
...@@ -29,6 +29,7 @@ from .light_children import LightChild, Scope, String ...@@ -29,6 +29,7 @@ from .light_children import LightChild, Scope, String
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SharedHeaderBlock(LightChild): class SharedHeaderBlock(LightChild):
""" """
A shared header block shown under the title. A shared header block shown under the title.
......
...@@ -108,12 +108,11 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -108,12 +108,11 @@ class MentoringBlock(XBlockWithLightChildren):
total_child_weight = sum(float(step.weight) for step in self.steps) total_child_weight = sum(float(step.weight) for step in self.steps)
if total_child_weight == 0: if total_child_weight == 0:
return (0, 0, 0, 0) return (0, 0, 0, 0)
score = sum(r[1]['score']*r[1]['weight'] \ score = sum(r[1]['score'] * r[1]['weight'] for r in self.student_results) / total_child_weight
for r in self.student_results) / total_child_weight correct = sum(1 for r in self.student_results if r[1]['completed'] is True)
correct = sum(1 for r in self.student_results if r[1]['completed'] == True) incorrect = sum(1 for r in self.student_results if r[1]['completed'] is False)
incorrect = sum(1 for r in self.student_results if r[1]['completed'] == False)
return (score, int(round(score*100)), correct, incorrect) return (score, int(round(score * 100)), correct, incorrect)
def _index_steps(self): def _index_steps(self):
steps = self.steps steps = self.steps
...@@ -127,7 +126,6 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -127,7 +126,6 @@ class MentoringBlock(XBlockWithLightChildren):
child.index = index child.index = index
index += 1 index += 1
def student_view(self, context): def student_view(self, context):
self._index_steps() self._index_steps()
...@@ -136,7 +134,6 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -136,7 +134,6 @@ class MentoringBlock(XBlockWithLightChildren):
not_instance_of=self.FLOATING_BLOCKS, not_instance_of=self.FLOATING_BLOCKS,
) )
fragment.add_content(render_template('templates/html/mentoring.html', { fragment.add_content(render_template('templates/html/mentoring.html', {
'self': self, 'self': self,
'named_children': named_children, 'named_children': named_children,
...@@ -144,7 +141,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -144,7 +141,7 @@ class MentoringBlock(XBlockWithLightChildren):
})) }))
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/mentoring.css')) fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/mentoring.css'))
fragment.add_javascript_url( fragment.add_javascript_url(
self.runtime.local_resource_url(self, 'public/js/vendor/underscore-min.js')) self.runtime.local_resource_url(self, 'public/js/vendor/underscore-min.js'))
if self.is_assessment: if self.is_assessment:
fragment.add_javascript_url( fragment.add_javascript_url(
self.runtime.local_resource_url(self, 'public/js/mentoring_assessment_view.js') self.runtime.local_resource_url(self, 'public/js/mentoring_assessment_view.js')
...@@ -176,7 +173,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -176,7 +173,7 @@ class MentoringBlock(XBlockWithLightChildren):
data['component_id'] = self.url_name data['component_id'] = self.url_name
self.runtime.publish(self, event_type, data) self.runtime.publish(self, event_type, data)
return {'result':'success'} return {'result': 'success'}
@property @property
def title(self): def title(self):
...@@ -248,8 +245,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -248,8 +245,7 @@ class MentoringBlock(XBlockWithLightChildren):
if self.has_missing_dependency: if self.has_missing_dependency:
completed = False completed = False
message = 'You need to complete all previous steps before being able to complete '+\ message = 'You need to complete all previous steps before being able to complete the current one.'
'the current one.'
elif completed and self.next_step == self.url_name: elif completed and self.next_step == self.url_name:
self.next_step = self.followed_by self.next_step = self.followed_by
...@@ -293,7 +289,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -293,7 +289,7 @@ class MentoringBlock(XBlockWithLightChildren):
completed = False completed = False
current_child = None current_child = None
children = [child for child in self.get_children_objects() \ children = [child for child in self.get_children_objects()
if not isinstance(child, self.FLOATING_BLOCKS)] if not isinstance(child, self.FLOATING_BLOCKS)]
for child in children: for child in children:
...@@ -309,7 +305,7 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -309,7 +305,7 @@ class MentoringBlock(XBlockWithLightChildren):
completed = False completed = False
break break
self.step = step+1 self.step = step + 1
child_result = child.submit(submission) child_result = child.submit(submission)
if 'tips' in child_result: if 'tips' in child_result:
......
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