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
859aaff4
Commit
859aaff4
authored
Oct 13, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use str instead of mixed types for completion status
parent
beb43c10
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
17 deletions
+17
-17
mentoring/answer.py
+4
-4
mentoring/mcq.py
+6
-6
mentoring/mentoring.py
+5
-5
mentoring/mrq.py
+2
-2
No files found.
mentoring/answer.py
View file @
859aaff4
...
...
@@ -121,18 +121,18 @@ class AnswerBlock(LightChild, StepMixin):
log
.
info
(
u'Answer submitted for`{}`: "{}"'
.
format
(
self
.
name
,
self
.
student_input
))
return
{
'student_input'
:
self
.
student_input
,
'
completed'
:
self
.
completed
,
'
status'
:
self
.
status
,
'weight'
:
self
.
weight
,
'score'
:
1
if
self
.
completed
else
0
,
'score'
:
1
if
self
.
status
==
'correct'
else
0
,
}
@property
def
completed
(
self
):
def
status
(
self
):
answer_length_ok
=
self
.
student_input
if
self
.
min_characters
>
0
:
answer_length_ok
=
len
(
self
.
student_input
.
strip
())
>=
self
.
min_characters
return
bool
(
self
.
read_only
or
answer_length_ok
)
return
'correct'
if
(
self
.
read_only
or
answer_length_ok
)
else
'incorrect'
def
save
(
self
):
"""
...
...
mentoring/mcq.py
View file @
859aaff4
...
...
@@ -52,31 +52,31 @@ class MCQBlock(QuestionnaireAbstractBlock):
def
submit
(
self
,
submission
):
log
.
debug
(
u'Received MCQ submission: "
%
s"'
,
submission
)
co
mpleted
=
True
co
rrect
=
True
tips_fragments
=
[]
for
tip
in
self
.
get_tips
():
co
mpleted
=
completed
and
self
.
is_tip_completed
(
tip
,
submission
)
co
rrect
=
correct
and
self
.
is_tip_correct
(
tip
,
submission
)
if
submission
in
tip
.
display_with_defaults
:
tips_fragments
.
append
(
tip
.
render
())
formatted_tips
=
render_template
(
'templates/html/tip_choice_group.html'
,
{
'self'
:
self
,
'tips_fragments'
:
tips_fragments
,
'completed'
:
co
mpleted
,
'completed'
:
co
rrect
,
})
self
.
student_choice
=
submission
result
=
{
'submission'
:
submission
,
'
completed'
:
completed
,
'
status'
:
'correct'
if
correct
else
'incorrect'
,
'tips'
:
formatted_tips
,
'weight'
:
self
.
weight
,
'score'
:
1
if
co
mpleted
else
0
,
'score'
:
1
if
co
rrect
else
0
,
}
log
.
debug
(
u'MCQ submission result:
%
s'
,
result
)
return
result
def
is_tip_co
mpleted
(
self
,
tip
,
submission
):
def
is_tip_co
rrect
(
self
,
tip
,
submission
):
if
not
submission
:
return
False
...
...
mentoring/mentoring.py
View file @
859aaff4
...
...
@@ -113,9 +113,9 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
if
total_child_weight
==
0
:
return
(
0
,
0
,
0
,
0
)
score
=
sum
(
r
[
1
][
'score'
]
*
r
[
1
][
'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
)
incorrect
=
sum
(
1
for
r
in
self
.
student_results
if
r
[
1
][
'
completed'
]
is
False
)
partially_correct
=
sum
(
1
for
r
in
self
.
student_results
if
r
[
1
][
'
completed'
]
is
'partial'
)
correct
=
sum
(
1
for
r
in
self
.
student_results
if
r
[
1
][
'
status'
]
==
'correct'
)
incorrect
=
sum
(
1
for
r
in
self
.
student_results
if
r
[
1
][
'
status'
]
==
'incorrect'
)
partially_correct
=
sum
(
1
for
r
in
self
.
student_results
if
r
[
1
][
'
status'
]
==
'partial'
)
return
(
score
,
int
(
round
(
score
*
100
)),
correct
,
incorrect
,
partially_correct
)
...
...
@@ -217,7 +217,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
child_result
=
child
.
submit
(
submission
)
submit_results
.
append
([
child
.
name
,
child_result
])
child
.
save
()
completed
=
completed
and
(
child_result
[
'
completed'
]
is
True
)
completed
=
completed
and
(
child_result
[
'
status'
]
==
'correct'
)
if
self
.
max_attempts_reached
:
message
=
self
.
get_message_html
(
'max_attempts_reached'
)
...
...
@@ -303,7 +303,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
del
child_result
[
'tips'
]
self
.
student_results
.
append
([
child
.
name
,
child_result
])
child
.
save
()
completed
=
child_result
[
'
completed'
]
completed
=
child_result
[
'
status'
]
==
'correct'
event_data
=
{}
...
...
mentoring/mrq.py
View file @
859aaff4
...
...
@@ -83,11 +83,11 @@ class MRQBlock(QuestionnaireAbstractBlock):
self
.
student_choices
=
submissions
completed
=
False
if
score
<=
0
else
True
if
score
>=
len
(
results
)
else
'partial'
status
=
'incorrect'
if
score
<=
0
else
'correct'
if
score
>=
len
(
results
)
else
'partial'
result
=
{
'submissions'
:
submissions
,
'
completed'
:
completed
,
'
status'
:
status
,
'choices'
:
results
,
'message'
:
self
.
message
,
'weight'
:
self
.
weight
,
...
...
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