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
74fc6b0f
Commit
74fc6b0f
authored
Sep 04, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor optimization/cleanup
parent
7d33b801
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
problem_builder/mentoring.py
+6
-11
problem_builder/step.py
+6
-0
No files found.
problem_builder/mentoring.py
View file @
74fc6b0f
...
@@ -255,7 +255,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -255,7 +255,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
@property
@property
def
score
(
self
):
def
score
(
self
):
"""Compute the student score taking into account the weight of each step."""
"""Compute the student score taking into account the weight of each step."""
steps
=
[
self
.
runtime
.
get_block
(
step_id
)
for
step_id
in
self
.
steps
]
steps
=
self
.
get_steps
()
steps_map
=
{
q
.
name
:
q
for
q
in
steps
}
steps_map
=
{
q
.
name
:
q
for
q
in
steps
}
total_child_weight
=
sum
(
float
(
step
.
weight
)
for
step
in
steps
)
total_child_weight
=
sum
(
float
(
step
.
weight
)
for
step
in
steps
)
if
total_child_weight
==
0
:
if
total_child_weight
==
0
:
...
@@ -283,7 +283,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -283,7 +283,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
self
.
migrate_fields
()
self
.
migrate_fields
()
# Validate self.step:
# Validate self.step:
num_steps
=
len
(
self
.
steps
)
num_steps
=
len
(
self
.
get_steps
()
)
if
self
.
step
>
num_steps
:
if
self
.
step
>
num_steps
:
self
.
step
=
num_steps
self
.
step
=
num_steps
...
@@ -435,9 +435,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -435,9 +435,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
return
[]
# Review tips are only used in assessment mode, and only on the last step.
return
[]
# Review tips are only used in assessment mode, and only on the last step.
review_tips
=
[]
review_tips
=
[]
status_cache
=
dict
(
self
.
student_results
)
status_cache
=
dict
(
self
.
student_results
)
for
child_id
in
self
.
steps
:
for
child
in
self
.
get_steps
():
child
=
self
.
runtime
.
get_block
(
child_id
)
if
child
.
name
:
result
=
status_cache
.
get
(
child
.
name
)
result
=
status_cache
.
get
(
child
.
name
)
if
result
and
result
.
get
(
'status'
)
!=
'correct'
:
if
result
and
result
.
get
(
'status'
)
!=
'correct'
:
# The student got this wrong. Check if there is a review tip to show.
# The student got this wrong. Check if there is a review tip to show.
...
@@ -513,8 +511,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -513,8 +511,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
show_message
=
bool
(
self
.
student_results
)
show_message
=
bool
(
self
.
student_results
)
# In standard mode, all children is visible simultaneously, so need collecting responses from all of them
# In standard mode, all children is visible simultaneously, so need collecting responses from all of them
for
child_id
in
self
.
steps
:
for
child
in
self
.
get_steps
():
child
=
self
.
runtime
.
get_block
(
child_id
)
child_result
=
child
.
get_last_result
()
child_result
=
child
.
get_last_result
()
results
.
append
([
child
.
name
,
child_result
])
results
.
append
([
child
.
name
,
child_result
])
completed
=
completed
and
(
child_result
.
get
(
'status'
,
None
)
==
'correct'
)
completed
=
completed
and
(
child_result
.
get
(
'status'
,
None
)
==
'correct'
)
...
@@ -537,8 +534,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -537,8 +534,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
completed
=
True
completed
=
True
choices
=
dict
(
self
.
student_results
)
choices
=
dict
(
self
.
student_results
)
# Only one child should ever be of concern with this method.
# Only one child should ever be of concern with this method.
for
child_id
in
self
.
steps
:
for
child
in
self
.
get_steps
():
child
=
self
.
runtime
.
get_block
(
child_id
)
if
child
.
name
and
child
.
name
in
queries
:
if
child
.
name
and
child
.
name
in
queries
:
results
=
[
child
.
name
,
child
.
get_results
(
choices
[
child
.
name
])]
results
=
[
child
.
name
,
child
.
get_results
(
choices
[
child
.
name
])]
# Children may have their own definition of 'completed' which can vary from the general case
# Children may have their own definition of 'completed' which can vary from the general case
...
@@ -571,8 +567,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -571,8 +567,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
submit_results
=
[]
submit_results
=
[]
previously_completed
=
self
.
completed
previously_completed
=
self
.
completed
completed
=
True
completed
=
True
for
child_id
in
self
.
steps
:
for
child
in
self
.
get_steps
():
child
=
self
.
runtime
.
get_block
(
child_id
)
if
child
.
name
and
child
.
name
in
submissions
:
if
child
.
name
and
child
.
name
in
submissions
:
submission
=
submissions
[
child
.
name
]
submission
=
submissions
[
child
.
name
]
child_result
=
child
.
submit
(
submission
)
child_result
=
child
.
submit
(
submission
)
...
...
problem_builder/step.py
View file @
74fc6b0f
...
@@ -52,6 +52,12 @@ class StepParentMixin(object):
...
@@ -52,6 +52,12 @@ class StepParentMixin(object):
"""
"""
return
[
_normalize_id
(
child_id
)
for
child_id
in
self
.
children
if
child_isinstance
(
self
,
child_id
,
StepMixin
)]
return
[
_normalize_id
(
child_id
)
for
child_id
in
self
.
children
if
child_isinstance
(
self
,
child_id
,
StepMixin
)]
def
get_steps
(
self
):
""" Get the step children of this block, cached if possible. """
if
getattr
(
self
,
"_steps_cache"
,
None
)
is
None
:
self
.
_steps_cache
=
[
self
.
runtime
.
get_block
(
child_id
)
for
child_id
in
self
.
steps
]
return
self
.
_steps_cache
class
StepMixin
(
object
):
class
StepMixin
(
object
):
"""
"""
...
...
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