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
c3a7d6de
Commit
c3a7d6de
authored
Sep 25, 2015
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure relevant info is updated and retrieved sequentially after
submitting step.
parent
a0dfa541
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
24 deletions
+22
-24
problem_builder/public/js/mentoring_with_steps.js
+22
-24
No files found.
problem_builder/public/js/mentoring_with_steps.js
View file @
c3a7d6de
...
...
@@ -31,11 +31,25 @@ function MentoringWithStepsBlock(runtime, element) {
return
(
data
.
num_attempts
<
data
.
max_attempts
);
}
function
updateActiveStep
(
newValue
)
{
function
updateActiveStep
(
response
)
{
// Update UI
if
(
response
.
completed
===
'correct'
)
{
checkmark
.
addClass
(
'checkmark-correct icon-ok fa-check'
);
}
else
if
(
response
.
completed
===
'partial'
)
{
checkmark
.
addClass
(
'checkmark-partially-correct icon-ok fa-check'
);
}
else
{
checkmark
.
addClass
(
'checkmark-incorrect icon-exclamation fa-exclamation'
);
}
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'update_active_step'
);
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
newValue
))
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
activeStep
+
1
))
.
success
(
function
(
response
)
{
activeStep
=
response
.
active_step
;
if
(
activeStep
===
-
1
)
{
updateNumAttempts
();
}
else
{
handleResults
();
}
});
}
...
...
@@ -44,6 +58,7 @@ function MentoringWithStepsBlock(runtime, element) {
$
.
post
(
handlerUrl
,
JSON
.
stringify
({}))
.
success
(
function
(
response
)
{
attemptsDOM
.
data
(
'num_attempts'
,
response
.
num_attempts
);
updateGrade
();
});
}
...
...
@@ -55,6 +70,7 @@ function MentoringWithStepsBlock(runtime, element) {
gradeDOM
.
data
(
'correct_answer'
,
response
.
correct_answers
);
gradeDOM
.
data
(
'incorrect_answer'
,
response
.
incorrect_answers
);
gradeDOM
.
data
(
'partially_correct_answer'
,
response
.
partially_correct_answers
);
updateReviewTips
();
});
}
...
...
@@ -63,35 +79,17 @@ function MentoringWithStepsBlock(runtime, element) {
$
.
post
(
handlerUrl
,
JSON
.
stringify
({}))
.
success
(
function
(
response
)
{
gradeDOM
.
data
(
'assessment_review_tips'
,
response
.
review_tips
);
handleResults
();
});
}
function
handleResults
(
response
)
{
// Update active step so next step is shown on page reload (even if user does not click "Next Step")
updateActiveStep
(
activeStep
+
1
);
// If step submitted was last step of this mentoring block, update grade and number of attempts used
if
(
response
.
attempt_complete
)
{
updateNumAttempts
();
updateGrade
();
updateReviewTips
();
}
// Update UI
if
(
response
.
completed
===
'correct'
)
{
checkmark
.
addClass
(
'checkmark-correct icon-ok fa-check'
);
}
else
if
(
response
.
completed
===
'partial'
)
{
checkmark
.
addClass
(
'checkmark-partially-correct icon-ok fa-check'
);
}
else
{
checkmark
.
addClass
(
'checkmark-incorrect icon-exclamation fa-exclamation'
);
}
function
handleResults
()
{
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
nextDOM
.
removeAttr
(
"disabled"
);
if
(
nextDOM
.
is
(
':visible'
))
{
nextDOM
.
focus
();
}
if
(
isLast
Step
())
{
if
(
atReview
Step
())
{
if
(
reviewStepPresent
())
{
reviewDOM
.
removeAttr
(
'disabled'
);
}
else
{
...
...
@@ -108,7 +106,7 @@ function MentoringWithStepsBlock(runtime, element) {
function
submit
()
{
// We do not handle submissions at this level, so just forward to "submit" method of active step
var
step
=
steps
[
activeStep
];
step
.
submit
(
handleResults
);
step
.
submit
(
updateActiveStep
);
}
function
getResults
()
{
...
...
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