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
17201a0c
Commit
17201a0c
authored
Sep 17, 2015
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functionality for resetting new mentoring block.
parent
d02539cb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
2 deletions
+48
-2
problem_builder/mentoring.py
+13
-0
problem_builder/public/js/mentoring_with_steps.js
+30
-2
problem_builder/step.py
+4
-0
problem_builder/templates/html/mentoring_with_steps.html
+1
-0
No files found.
problem_builder/mentoring.py
View file @
17201a0c
...
@@ -916,6 +916,19 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
...
@@ -916,6 +916,19 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
'step'
:
self
.
step
'step'
:
self
.
step
}
}
@XBlock.json_handler
def
try_again
(
self
,
data
,
suffix
=
''
):
self
.
step
=
0
step_blocks
=
[
self
.
runtime
.
get_block
(
child_id
)
for
child_id
in
self
.
steps
]
for
step
in
step_blocks
:
step
.
reset
()
return
{
'result'
:
'success'
}
def
author_edit_view
(
self
,
context
):
def
author_edit_view
(
self
,
context
):
"""
"""
Add some HTML to the author view that allows authors to add child blocks.
Add some HTML to the author view that allows authors to add child blocks.
...
...
problem_builder/public/js/mentoring_with_steps.js
View file @
17201a0c
...
@@ -4,7 +4,7 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -4,7 +4,7 @@ function MentoringWithStepsBlock(runtime, element) {
function
(
c
)
{
return
c
.
element
.
className
.
indexOf
(
'pb-mentoring-step'
)
>
-
1
;
}
function
(
c
)
{
return
c
.
element
.
className
.
indexOf
(
'pb-mentoring-step'
)
>
-
1
;
}
);
);
var
step
=
$
(
'.mentoring'
,
element
).
data
(
'step'
);
var
step
=
$
(
'.mentoring'
,
element
).
data
(
'step'
);
var
active_child
,
checkmark
,
submitDOM
,
nextDOM
;
var
active_child
,
checkmark
,
submitDOM
,
nextDOM
,
tryAgainDOM
,
submitXHR
;
function
isLastChild
()
{
function
isLastChild
()
{
return
(
active_child
===
steps
.
length
-
1
);
return
(
active_child
===
steps
.
length
-
1
);
...
@@ -15,7 +15,6 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -15,7 +15,6 @@ function MentoringWithStepsBlock(runtime, element) {
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
step
+
1
))
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
step
+
1
))
.
success
(
function
(
response
)
{
.
success
(
function
(
response
)
{
step
=
response
.
step
;
step
=
response
.
step
;
console
.
log
(
'Step: '
+
step
);
});
});
}
}
...
@@ -36,6 +35,11 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -36,6 +35,11 @@ function MentoringWithStepsBlock(runtime, element) {
nextDOM
.
removeAttr
(
"disabled"
);
nextDOM
.
removeAttr
(
"disabled"
);
if
(
nextDOM
.
is
(
':visible'
))
{
nextDOM
.
focus
();
}
if
(
nextDOM
.
is
(
':visible'
))
{
nextDOM
.
focus
();
}
if
(
isLastChild
())
{
tryAgainDOM
.
removeAttr
(
'disabled'
);
tryAgainDOM
.
show
();
}
}
}
function
submit
()
{
function
submit
()
{
...
@@ -103,6 +107,27 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -103,6 +107,27 @@ function MentoringWithStepsBlock(runtime, element) {
}
}
}
}
function
handleTryAgain
(
result
)
{
if
(
result
.
result
!==
'success'
)
return
;
active_child
=
-
1
;
displayNextChild
();
tryAgainDOM
.
hide
();
submitDOM
.
show
();
if
(
!
isLastChild
())
{
nextDOM
.
show
();
}
}
function
tryAgain
()
{
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'try_again'
);
if
(
submitXHR
)
{
submitXHR
.
abort
();
}
submitXHR
=
$
.
post
(
handlerUrl
,
JSON
.
stringify
({})).
success
(
handleTryAgain
);
}
function
initXBlockView
()
{
function
initXBlockView
()
{
checkmark
=
$
(
'.assessment-checkmark'
,
element
);
checkmark
=
$
(
'.assessment-checkmark'
,
element
);
...
@@ -114,6 +139,9 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -114,6 +139,9 @@ function MentoringWithStepsBlock(runtime, element) {
nextDOM
.
bind
(
'click'
,
displayNextChild
);
nextDOM
.
bind
(
'click'
,
displayNextChild
);
nextDOM
.
show
();
nextDOM
.
show
();
tryAgainDOM
=
$
(
element
).
find
(
'.submit .input-try-again'
);
tryAgainDOM
.
bind
(
'click'
,
tryAgain
);
var
options
=
{
var
options
=
{
onChange
:
onChange
onChange
:
onChange
};
};
...
...
problem_builder/step.py
View file @
17201a0c
...
@@ -146,6 +146,10 @@ class MentoringStepBlock(
...
@@ -146,6 +146,10 @@ class MentoringStepBlock(
'results'
:
submit_results
,
'results'
:
submit_results
,
}
}
def
reset
(
self
):
while
self
.
student_results
:
self
.
student_results
.
pop
()
def
author_edit_view
(
self
,
context
):
def
author_edit_view
(
self
,
context
):
"""
"""
Add some HTML to the author view that allows authors to add child blocks.
Add some HTML to the author view that allows authors to add child blocks.
...
...
problem_builder/templates/html/mentoring_with_steps.html
View file @
17201a0c
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
<span
class=
"assessment-checkmark fa icon-2x"
></span>
<span
class=
"assessment-checkmark fa icon-2x"
></span>
<input
type=
"button"
class=
"input-main"
value=
"Submit"
disabled=
"disabled"
/>
<input
type=
"button"
class=
"input-main"
value=
"Submit"
disabled=
"disabled"
/>
<input
type=
"button"
class=
"input-next"
value=
"Next Step"
disabled=
"disabled"
/>
<input
type=
"button"
class=
"input-next"
value=
"Next Step"
disabled=
"disabled"
/>
<input
type=
"button"
class=
"input-try-again"
value=
"Try again"
disabled=
"disabled"
/>
</div>
</div>
</div>
</div>
...
...
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