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
7f0d3def
Commit
7f0d3def
authored
Apr 09, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'get_results' method to all assessment block types
parent
00b3d93f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
19 deletions
+33
-19
problem_builder/answer.py
+9
-6
problem_builder/mcq.py
+11
-5
problem_builder/mrq.py
+13
-8
No files found.
problem_builder/answer.py
View file @
7f0d3def
...
@@ -179,6 +179,14 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
...
@@ -179,6 +179,14 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
""" Normal view of this XBlock, identical to mentoring_view """
""" Normal view of this XBlock, identical to mentoring_view """
return
self
.
mentoring_view
(
context
)
return
self
.
mentoring_view
(
context
)
def
get_results
(
self
):
return
{
'student_input'
:
self
.
student_input
,
'status'
:
self
.
status
,
'weight'
:
self
.
weight
,
'score'
:
1
if
self
.
status
==
'correct'
else
0
,
}
def
submit
(
self
,
submission
):
def
submit
(
self
,
submission
):
"""
"""
The parent block is handling a student submission, including a new answer for this
The parent block is handling a student submission, including a new answer for this
...
@@ -187,12 +195,7 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
...
@@ -187,12 +195,7 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
self
.
student_input
=
submission
[
0
][
'value'
]
.
strip
()
self
.
student_input
=
submission
[
0
][
'value'
]
.
strip
()
self
.
save
()
self
.
save
()
log
.
info
(
u'Answer submitted for`{}`: "{}"'
.
format
(
self
.
name
,
self
.
student_input
))
log
.
info
(
u'Answer submitted for`{}`: "{}"'
.
format
(
self
.
name
,
self
.
student_input
))
return
{
return
self
.
get_results
()
'student_input'
:
self
.
student_input
,
'status'
:
self
.
status
,
'weight'
:
self
.
weight
,
'score'
:
1
if
self
.
status
==
'correct'
else
0
,
}
@property
@property
def
status
(
self
):
def
status
(
self
):
...
...
problem_builder/mcq.py
View file @
7f0d3def
...
@@ -74,9 +74,7 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
...
@@ -74,9 +74,7 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
return
self
.
_
(
u"Wrong"
)
return
self
.
_
(
u"Wrong"
)
return
self
.
_
(
u"Not Acceptable"
)
return
self
.
_
(
u"Not Acceptable"
)
def
submit
(
self
,
submission
):
def
calculate_results
(
self
,
submission
):
log
.
debug
(
u'Received MCQ submission: "
%
s"'
,
submission
)
correct
=
submission
in
self
.
correct_choices
correct
=
submission
in
self
.
correct_choices
tips_html
=
[]
tips_html
=
[]
for
tip
in
self
.
get_tips
():
for
tip
in
self
.
get_tips
():
...
@@ -86,7 +84,7 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
...
@@ -86,7 +84,7 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
if
tips_html
:
if
tips_html
:
formatted_tips
=
loader
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
formatted_tips
=
loader
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
'tips_html'
:
tips_html
,
'tips_html'
:
tips_html
,
})
})
self
.
student_choice
=
submission
self
.
student_choice
=
submission
...
@@ -94,13 +92,21 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
...
@@ -94,13 +92,21 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
# Also send to the submissions API:
# Also send to the submissions API:
sub_api
.
create_submission
(
self
.
student_item_key
,
submission
)
sub_api
.
create_submission
(
self
.
student_item_key
,
submission
)
re
sult
=
{
re
turn
{
'submission'
:
submission
,
'submission'
:
submission
,
'status'
:
'correct'
if
correct
else
'incorrect'
,
'status'
:
'correct'
if
correct
else
'incorrect'
,
'tips'
:
formatted_tips
if
tips_html
else
None
,
'tips'
:
formatted_tips
if
tips_html
else
None
,
'weight'
:
self
.
weight
,
'weight'
:
self
.
weight
,
'score'
:
1
if
correct
else
0
,
'score'
:
1
if
correct
else
0
,
}
}
def
get_results
(
self
):
return
self
.
calculate_results
(
self
.
student_choice
)
def
submit
(
self
,
submission
):
log
.
debug
(
u'Received MCQ submission: "
%
s"'
,
submission
)
result
=
self
.
calculate_results
(
submission
)
self
.
student_choice
=
submission
log
.
debug
(
u'MCQ submission result:
%
s'
,
result
)
log
.
debug
(
u'MCQ submission result:
%
s'
,
result
)
return
result
return
result
...
...
problem_builder/mrq.py
View file @
7f0d3def
...
@@ -81,9 +81,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
...
@@ -81,9 +81,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
return
self
.
_
(
u"Ignored"
)
return
self
.
_
(
u"Ignored"
)
return
self
.
_
(
u"Not Acceptable"
)
return
self
.
_
(
u"Not Acceptable"
)
def
submit
(
self
,
submissions
):
def
calculate_results
(
self
,
submissions
):
log
.
debug
(
u'Received MRQ submissions: "
%
s"'
,
submissions
)
score
=
0
score
=
0
results
=
[]
results
=
[]
...
@@ -106,22 +104,20 @@ class MRQBlock(QuestionnaireAbstractBlock):
...
@@ -106,22 +104,20 @@ class MRQBlock(QuestionnaireAbstractBlock):
choice_result
=
{
choice_result
=
{
'value'
:
choice
.
value
,
'value'
:
choice
.
value
,
'selected'
:
choice_selected
,
'selected'
:
choice_selected
,
}
}
# Only include tips/results in returned response if we want to display them
# Only include tips/results in returned response if we want to display them
if
not
self
.
hide_results
:
if
not
self
.
hide_results
:
loader
=
ResourceLoader
(
__name__
)
loader
=
ResourceLoader
(
__name__
)
choice_result
[
'completed'
]
=
choice_completed
choice_result
[
'completed'
]
=
choice_completed
choice_result
[
'tips'
]
=
loader
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
choice_result
[
'tips'
]
=
loader
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
'tips_html'
:
choice_tips_html
,
'tips_html'
:
choice_tips_html
,
})
})
results
.
append
(
choice_result
)
results
.
append
(
choice_result
)
self
.
student_choices
=
submissions
status
=
'incorrect'
if
score
<=
0
else
'correct'
if
score
>=
len
(
results
)
else
'partial'
status
=
'incorrect'
if
score
<=
0
else
'correct'
if
score
>=
len
(
results
)
else
'partial'
re
sult
=
{
re
turn
{
'submissions'
:
submissions
,
'submissions'
:
submissions
,
'status'
:
status
,
'status'
:
status
,
'choices'
:
results
,
'choices'
:
results
,
...
@@ -130,6 +126,15 @@ class MRQBlock(QuestionnaireAbstractBlock):
...
@@ -130,6 +126,15 @@ class MRQBlock(QuestionnaireAbstractBlock):
'score'
:
(
float
(
score
)
/
len
(
results
))
if
results
else
0
,
'score'
:
(
float
(
score
)
/
len
(
results
))
if
results
else
0
,
}
}
def
get_results
(
self
):
return
self
.
calculate_results
(
self
.
student_choices
)
def
submit
(
self
,
submissions
):
log
.
debug
(
u'Received MRQ submissions: "
%
s"'
,
submissions
)
result
=
self
.
calculate_results
(
submissions
)
self
.
student_choices
=
submissions
log
.
debug
(
u'MRQ submissions result:
%
s'
,
result
)
log
.
debug
(
u'MRQ submissions result:
%
s'
,
result
)
return
result
return
result
...
...
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