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
1ff860a1
Commit
1ff860a1
authored
Sep 29, 2015
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure num_attempts info is always up-to-date by fetching it from
server when initializing Step Builder XBlock on the client.
parent
47fe2f6f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
problem_builder/mentoring.py
+6
-0
problem_builder/public/js/mentoring_with_steps.js
+21
-2
No files found.
problem_builder/mentoring.py
View file @
1ff860a1
...
...
@@ -1055,6 +1055,12 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
}
@XBlock.json_handler
def
get_num_attempts
(
self
,
data
,
suffix
):
return
{
'num_attempts'
:
self
.
num_attempts
}
@XBlock.json_handler
def
try_again
(
self
,
data
,
suffix
=
''
):
self
.
active_step
=
0
...
...
problem_builder/public/js/mentoring_with_steps.js
View file @
1ff860a1
...
...
@@ -372,11 +372,14 @@ function MentoringWithStepsBlock(runtime, element) {
}
function
initXBlockView
()
{
// Hide steps until we're ready
hideAllSteps
();
// Initialize references to relevant DOM elements and set up event handlers
checkmark
=
$
(
'.assessment-checkmark'
,
element
);
submitDOM
=
$
(
element
).
find
(
'.submit .input-main'
);
submitDOM
.
on
(
'click'
,
submit
);
submitDOM
.
show
();
nextDOM
=
$
(
element
).
find
(
'.submit .input-next'
);
if
(
atReviewStep
())
{
...
...
@@ -384,7 +387,6 @@ function MentoringWithStepsBlock(runtime, element) {
}
else
{
nextDOM
.
on
(
'click'
,
updateDisplay
);
}
nextDOM
.
show
();
reviewDOM
=
$
(
element
).
find
(
'.submit .input-review'
);
reviewDOM
.
on
(
'click'
,
showGrade
);
...
...
@@ -400,12 +402,29 @@ function MentoringWithStepsBlock(runtime, element) {
reviewLinkDOM
=
$
(
element
).
find
(
'.review-link'
);
reviewLinkDOM
.
on
(
'click'
,
showGrade
);
// Initialize individual steps
// (sets up click handlers for questions and makes sure answer data is up-to-date)
var
options
=
{
onChange
:
onChange
};
initSteps
(
options
);
// Refresh info about number of attempts used:
// In the LMS, the HTML of multiple units can be loaded at once,
// and the user can flip among them. If that happens, information about
// number of attempts student has used up may be out of date.
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'get_num_attempts'
);
$
.
post
(
handlerUrl
,
JSON
.
stringify
({}))
.
success
(
function
(
response
)
{
attemptsDOM
.
data
(
'num_attempts'
,
response
.
num_attempts
);
// Finally, show controls and content
submitDOM
.
show
();
nextDOM
.
show
();
updateDisplay
();
});
}
initClickHandlers
();
...
...
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