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
79bdff76
Commit
79bdff76
authored
Feb 24, 2016
by
Tim Krones
Committed by
Tim Krones
Feb 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce instance-wide setting that specifies if previous answers to
MCQs are shown when users revisit them.
parent
5e5d897c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
7 deletions
+45
-7
problem_builder/mentoring.py
+42
-7
problem_builder/public/js/questionnaire.js
+3
-0
No files found.
problem_builder/mentoring.py
View file @
79bdff76
...
@@ -63,6 +63,10 @@ _default_theme_config = {
...
@@ -63,6 +63,10 @@ _default_theme_config = {
'locations'
:
[
'public/themes/lms.css'
]
'locations'
:
[
'public/themes/lms.css'
]
}
}
_default_options_config
=
{
'pb_mcq_hide_previous_answer'
:
False
}
# Make '_' a no-op so we can scrape strings
# Make '_' a no-op so we can scrape strings
def
_
(
text
):
def
_
(
text
):
...
@@ -121,6 +125,7 @@ class BaseMentoringBlock(
...
@@ -121,6 +125,7 @@ class BaseMentoringBlock(
icon_class
=
'problem'
icon_class
=
'problem'
block_settings_key
=
'mentoring'
block_settings_key
=
'mentoring'
theme_key
=
'theme'
theme_key
=
'theme'
options_key
=
'options'
@property
@property
def
url_name
(
self
):
def
url_name
(
self
):
...
@@ -156,18 +161,28 @@ class BaseMentoringBlock(
...
@@ -156,18 +161,28 @@ class BaseMentoringBlock(
return
[
self
.
display_name
]
return
[
self
.
display_name
]
return
[]
return
[]
def
get_
theme
(
self
):
def
get_
settings
(
self
,
settings_key
,
default
):
"""
"""
Gets theme settings from settings service. Falls back to default (LMS) theme
Get settings identified by `settings_key` from settings service.
if settings service is not available, xblock theme settings are not set or does
contain mentoring theme settings.
Fall back on `default` if settings service is unavailable
or settings have not been customized.
"""
"""
settings_service
=
self
.
runtime
.
service
(
self
,
"settings"
)
settings_service
=
self
.
runtime
.
service
(
self
,
"settings"
)
if
settings_service
:
if
settings_service
:
xblock_settings
=
settings_service
.
get_settings_bucket
(
self
)
xblock_settings
=
settings_service
.
get_settings_bucket
(
self
)
if
xblock_settings
and
self
.
theme_key
in
xblock_settings
:
if
xblock_settings
and
settings_key
in
xblock_settings
:
return
xblock_settings
[
self
.
theme_key
]
return
xblock_settings
[
settings_key
]
return
_default_theme_config
return
default
def
get_theme
(
self
):
"""
Get theme settings for this block from settings service.
Fall back on default (LMS) theme if settings service is not available,
or theme has not been customized.
"""
return
self
.
get_settings
(
self
.
theme_key
,
_default_theme_config
)
def
include_theme_files
(
self
,
fragment
):
def
include_theme_files
(
self
,
fragment
):
theme
=
self
.
get_theme
()
theme
=
self
.
get_theme
()
...
@@ -175,6 +190,18 @@ class BaseMentoringBlock(
...
@@ -175,6 +190,18 @@ class BaseMentoringBlock(
for
theme_file
in
theme_files
:
for
theme_file
in
theme_files
:
fragment
.
add_css
(
ResourceLoader
(
theme_package
)
.
load_unicode
(
theme_file
))
fragment
.
add_css
(
ResourceLoader
(
theme_package
)
.
load_unicode
(
theme_file
))
def
get_options
(
self
):
"""
Get options settings for this block from settings service.
Fall back on default options if settings service is not available
or options have not been customized.
"""
return
self
.
get_settings
(
self
.
options_key
,
_default_options_config
)
def
get_option
(
self
,
option
):
return
self
.
get_options
()[
option
]
@XBlock.json_handler
@XBlock.json_handler
def
view
(
self
,
data
,
suffix
=
''
):
def
view
(
self
,
data
,
suffix
=
''
):
"""
"""
...
@@ -368,6 +395,8 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
...
@@ -368,6 +395,8 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
return
Score
(
score
,
int
(
round
(
score
*
100
)),
correct
,
incorrect
,
partially_correct
)
return
Score
(
score
,
int
(
round
(
score
*
100
)),
correct
,
incorrect
,
partially_correct
)
def
student_view
(
self
,
context
):
def
student_view
(
self
,
context
):
from
.mcq
import
MCQBlock
# Import here to avoid circular dependency
# Migrate stored data if necessary
# Migrate stored data if necessary
self
.
migrate_fields
()
self
.
migrate_fields
()
...
@@ -379,6 +408,8 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
...
@@ -379,6 +408,8 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
fragment
=
Fragment
()
fragment
=
Fragment
()
child_content
=
u""
child_content
=
u""
mcq_hide_previous_answer
=
self
.
get_option
(
'pb_mcq_hide_previous_answer'
)
for
child_id
in
self
.
children
:
for
child_id
in
self
.
children
:
child
=
self
.
runtime
.
get_block
(
child_id
)
child
=
self
.
runtime
.
get_block
(
child_id
)
if
child
is
None
:
# child should not be None but it can happen due to bugs or permission issues
if
child
is
None
:
# child should not be None but it can happen due to bugs or permission issues
...
@@ -388,6 +419,10 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
...
@@ -388,6 +419,10 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
if
self
.
is_assessment
and
isinstance
(
child
,
QuestionMixin
):
if
self
.
is_assessment
and
isinstance
(
child
,
QuestionMixin
):
child_fragment
=
child
.
render
(
'assessment_step_view'
,
context
)
child_fragment
=
child
.
render
(
'assessment_step_view'
,
context
)
else
:
else
:
if
mcq_hide_previous_answer
and
isinstance
(
child
,
MCQBlock
):
context
[
'hide_prev_answer'
]
=
True
else
:
context
[
'hide_prev_answer'
]
=
False
child_fragment
=
child
.
render
(
'mentoring_view'
,
context
)
child_fragment
=
child
.
render
(
'mentoring_view'
,
context
)
except
NoSuchViewError
:
except
NoSuchViewError
:
if
child
.
scope_ids
.
block_type
==
'html'
and
getattr
(
self
.
runtime
,
'is_author_mode'
,
False
):
if
child
.
scope_ids
.
block_type
==
'html'
and
getattr
(
self
.
runtime
,
'is_author_mode'
,
False
):
...
...
problem_builder/public/js/questionnaire.js
View file @
79bdff76
...
@@ -138,6 +138,8 @@ function MCQBlock(runtime, element) {
...
@@ -138,6 +138,8 @@ function MCQBlock(runtime, element) {
var
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
);
var
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
);
var
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
);
var
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
);
if
(
choiceInputDOM
.
prop
(
'checked'
))
{
// We're showing previous answers,
// so go ahead and display results as well
if
(
result
.
status
===
"correct"
&&
choiceInputDOM
.
val
()
===
result
.
submission
)
{
if
(
result
.
status
===
"correct"
&&
choiceInputDOM
.
val
()
===
result
.
submission
)
{
choiceDOM
.
addClass
(
'correct'
);
choiceDOM
.
addClass
(
'correct'
);
choiceResultDOM
.
addClass
(
'checkmark-correct icon-ok fa-check'
);
choiceResultDOM
.
addClass
(
'checkmark-correct icon-ok fa-check'
);
...
@@ -156,6 +158,7 @@ function MCQBlock(runtime, element) {
...
@@ -156,6 +158,7 @@ function MCQBlock(runtime, element) {
messageView
.
showMessage
(
choiceTipsDOM
);
messageView
.
showMessage
(
choiceTipsDOM
);
}
}
});
});
}
});
});
if
(
_
.
isNull
(
result
.
submission
))
{
if
(
_
.
isNull
(
result
.
submission
))
{
...
...
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