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
22b300a9
Commit
22b300a9
authored
Sep 11, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add step mixins to XBlocks that can be steps
parent
6af86c3d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
39 additions
and
28 deletions
+39
-28
mentoring/answer.py
+2
-1
mentoring/mentoring.py
+2
-21
mentoring/questionnaire.py
+2
-1
mentoring/step.py
+1
-0
mentoring/templates/html/answer_editable.html
+1
-1
mentoring/templates/html/answer_read_only.html
+1
-1
mentoring/templates/html/mcqblock_choices.html
+1
-1
mentoring/templates/html/mcqblock_rating.html
+1
-1
mentoring/templates/html/mrqblock_choices.html
+1
-1
mentoring/templates/xml/mentoring_with_only_one_step.xml
+27
-0
No files found.
mentoring/answer.py
View file @
22b300a9
...
@@ -30,6 +30,7 @@ from lazy import lazy
...
@@ -30,6 +30,7 @@ from lazy import lazy
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
.light_children
import
LightChild
,
Boolean
,
Scope
,
String
,
Integer
,
Float
from
.light_children
import
LightChild
,
Boolean
,
Scope
,
String
,
Integer
,
Float
from
.step
import
StepMixin
from
.models
import
Answer
from
.models
import
Answer
from
.utils
import
render_js_template
,
serialize_opaque_key
from
.utils
import
render_js_template
,
serialize_opaque_key
...
@@ -41,7 +42,7 @@ log = logging.getLogger(__name__)
...
@@ -41,7 +42,7 @@ log = logging.getLogger(__name__)
# Classes ###########################################################
# Classes ###########################################################
class
AnswerBlock
(
LightChild
):
class
AnswerBlock
(
LightChild
,
StepMixin
):
"""
"""
A field where the student enters an answer
A field where the student enters an answer
...
...
mentoring/mentoring.py
View file @
22b300a9
...
@@ -38,6 +38,7 @@ from .title import TitleBlock
...
@@ -38,6 +38,7 @@ from .title import TitleBlock
from
.header
import
SharedHeaderBlock
from
.header
import
SharedHeaderBlock
from
.html
import
HTMLBlock
from
.html
import
HTMLBlock
from
.message
import
MentoringMessageBlock
from
.message
import
MentoringMessageBlock
from
.step
import
StepParentMixin
from
.utils
import
get_scenarios_from_path
,
load_resource
,
render_template
from
.utils
import
get_scenarios_from_path
,
load_resource
,
render_template
...
@@ -48,7 +49,7 @@ log = logging.getLogger(__name__)
...
@@ -48,7 +49,7 @@ log = logging.getLogger(__name__)
# Classes ###########################################################
# Classes ###########################################################
class
MentoringBlock
(
XBlockWithLightChildren
):
class
MentoringBlock
(
XBlockWithLightChildren
,
StepParentMixin
):
"""
"""
An XBlock providing mentoring capabilities
An XBlock providing mentoring capabilities
...
@@ -98,11 +99,6 @@ class MentoringBlock(XBlockWithLightChildren):
...
@@ -98,11 +99,6 @@ class MentoringBlock(XBlockWithLightChildren):
return
self
.
mode
==
'assessment'
return
self
.
mode
==
'assessment'
@property
@property
def
steps
(
self
):
return
[
child
for
child
in
self
.
get_children_objects
()
if
not
isinstance
(
child
,
self
.
FLOATING_BLOCKS
+
(
HTMLBlock
,))]
@property
def
score
(
self
):
def
score
(
self
):
"""Compute the student score taking into account the light child weight."""
"""Compute the student score taking into account the light child weight."""
total_child_weight
=
sum
(
float
(
step
.
weight
)
for
step
in
self
.
steps
)
total_child_weight
=
sum
(
float
(
step
.
weight
)
for
step
in
self
.
steps
)
...
@@ -114,22 +110,7 @@ class MentoringBlock(XBlockWithLightChildren):
...
@@ -114,22 +110,7 @@ class MentoringBlock(XBlockWithLightChildren):
return
(
score
,
int
(
round
(
score
*
100
)),
correct
,
incorrect
)
return
(
score
,
int
(
round
(
score
*
100
)),
correct
,
incorrect
)
def
_index_steps
(
self
):
"""Add an index to each step that can be used in the step's title."""
steps
=
self
.
steps
if
len
(
steps
)
==
1
:
steps
[
0
]
.
index
=
""
return
index
=
1
for
child
in
steps
:
child
.
index
=
index
index
+=
1
def
student_view
(
self
,
context
):
def
student_view
(
self
,
context
):
self
.
_index_steps
()
fragment
,
named_children
=
self
.
get_children_fragment
(
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_view'
,
context
,
view_name
=
'mentoring_view'
,
not_instance_of
=
self
.
FLOATING_BLOCKS
,
not_instance_of
=
self
.
FLOATING_BLOCKS
,
...
...
mentoring/questionnaire.py
View file @
22b300a9
...
@@ -28,6 +28,7 @@ import logging
...
@@ -28,6 +28,7 @@ import logging
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
.choice
import
ChoiceBlock
from
.choice
import
ChoiceBlock
from
.step
import
StepMixin
from
.light_children
import
LightChild
,
Scope
,
String
,
Float
from
.light_children
import
LightChild
,
Scope
,
String
,
Float
from
.tip
import
TipBlock
from
.tip
import
TipBlock
from
.utils
import
render_template
,
render_js_template
from
.utils
import
render_template
,
render_js_template
...
@@ -40,7 +41,7 @@ log = logging.getLogger(__name__)
...
@@ -40,7 +41,7 @@ log = logging.getLogger(__name__)
# Classes ###########################################################
# Classes ###########################################################
class
QuestionnaireAbstractBlock
(
LightChild
):
class
QuestionnaireAbstractBlock
(
LightChild
,
StepMixin
):
"""
"""
An abstract class used for MCQ/MRQ blocks
An abstract class used for MCQ/MRQ blocks
...
...
mentoring/step.py
View file @
22b300a9
...
@@ -4,6 +4,7 @@ class StepParentMixin(object):
...
@@ -4,6 +4,7 @@ class StepParentMixin(object):
The parent must have a get_children_objects() method.
The parent must have a get_children_objects() method.
"""
"""
@property
@property
def
steps
(
self
):
def
steps
(
self
):
return
[
child
for
child
in
self
.
get_children_objects
()
if
isinstance
(
child
,
StepMixin
)]
return
[
child
for
child
in
self
.
get_children_objects
()
if
isinstance
(
child
,
StepMixin
)]
...
...
mentoring/templates/html/answer_editable.html
View file @
22b300a9
<div
class=
"xblock-answer"
data-completed=
"{{ self.completed }}"
>
<div
class=
"xblock-answer"
data-completed=
"{{ self.completed }}"
>
<h3
class=
"question-title"
>
QUESTION {
{ self.index }
}
</h3>
<h3
class=
"question-title"
>
QUESTION {
% if not self.lonely_step %}{{ self.step_number }}{% endif %
}
</h3>
<p>
{{ self.question }}
</p>
<p>
{{ self.question }}
</p>
<textarea
<textarea
class=
"answer editable"
cols=
"50"
rows=
"10"
name=
"input"
class=
"answer editable"
cols=
"50"
rows=
"10"
name=
"input"
...
...
mentoring/templates/html/answer_read_only.html
View file @
22b300a9
<div
class=
"xblock-answer"
data-completed=
"{{ self.completed }}"
>
<div
class=
"xblock-answer"
data-completed=
"{{ self.completed }}"
>
<h3
class=
"question-title"
>
QUESTION {
{ self.index }
}
</h3>
<h3
class=
"question-title"
>
QUESTION {
% if not self.lonely_step %}{{ self.step_number }}{% endif %
}
</h3>
<p>
{{ self.question }}
</p>
<p>
{{ self.question }}
</p>
<blockquote
class=
"answer read_only"
>
<blockquote
class=
"answer read_only"
>
{{ self.student_input|linebreaksbr }}
{{ self.student_input|linebreaksbr }}
...
...
mentoring/templates/html/mcqblock_choices.html
View file @
22b300a9
<fieldset
class=
"choices questionnaire"
>
<fieldset
class=
"choices questionnaire"
>
<legend
class=
"question"
>
<legend
class=
"question"
>
<h3
class=
"question-title"
>
QUESTION {
{ self.index }
}
</h3>
<h3
class=
"question-title"
>
QUESTION {
% if not self.lonely_step %}{{ self.step_number }}{% endif %
}
</h3>
<p>
{{ self.question }}
</p>
<p>
{{ self.question }}
</p>
</legend>
</legend>
<div
class=
"choices-list"
>
<div
class=
"choices-list"
>
...
...
mentoring/templates/html/mcqblock_rating.html
View file @
22b300a9
<fieldset
class=
"rating questionnaire"
>
<fieldset
class=
"rating questionnaire"
>
<legend
class=
"question"
>
<legend
class=
"question"
>
<h3
class=
"question-title"
>
QUESTION {
{ self.index }
}
</h3>
<h3
class=
"question-title"
>
QUESTION {
% if not self.lonely_step %}{{ self.step_number }}{% endif %
}
</h3>
<p>
{{ self.question }}
</p>
<p>
{{ self.question }}
</p>
</legend>
</legend>
<div
class=
"choices-list"
>
<div
class=
"choices-list"
>
...
...
mentoring/templates/html/mrqblock_choices.html
View file @
22b300a9
<fieldset
class=
"choices questionnaire"
data-hide_results=
"{{self.hide_results}}"
>
<fieldset
class=
"choices questionnaire"
data-hide_results=
"{{self.hide_results}}"
>
<legend
class=
"question"
>
<legend
class=
"question"
>
<h3
class=
"question-title"
>
QUESTION {{ self.index }
}
</h3>
<h3
class=
"question-title"
>
QUESTION {% if not self.lonely_step %}{{ self.step_number }}{% endif %
}
</h3>
<p>
{{ self.question }}
</p>
<p>
{{ self.question }}
</p>
</legend>
</legend>
<div
class=
"choices-list"
>
<div
class=
"choices-list"
>
...
...
mentoring/templates/xml/mentoring_with_only_one_step.xml
0 → 100644
View file @
22b300a9
<mentoring
url_name=
"{{ url_name }}"
display_name=
"Nav tooltip title"
weight=
"1"
mode=
"standard"
>
<title>
Default Title
</title>
<html>
<p>
Please answer the questions below.
</p>
</html>
<mrq
name=
"mrq_1_1"
type=
"choices"
>
<question>
What do you like in this MRQ?
</question>
<choice
value=
"elegance"
>
Its elegance
</choice>
<choice
value=
"beauty"
>
Its beauty
</choice>
<choice
value=
"gracefulness"
>
Its gracefulness
</choice>
<choice
value=
"bugs"
>
Its bugs
</choice>
<tip
require=
"gracefulness"
>
This MRQ is indeed very graceful
</tip>
<tip
require=
"elegance,beauty"
>
This is something everyone has to like about this MRQ
</tip>
<tip
reject=
"bugs"
>
Nah, there isn't any!
</tip>
<message
type=
"on-submit"
>
Thank you for answering!
</message>
</mrq>
<message
type=
"completed"
>
<html><p>
Congratulations!
</p></html>
</message>
<message
type=
"incomplete"
>
<html><p>
Still some work to do...
</p></html>
</message>
</mentoring>
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