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
f521eb01
Commit
f521eb01
authored
May 15, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #37 from mtyaka/autosubmit
Update display when answer is changed.
parents
e039d7fc
8715a610
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
26 deletions
+46
-26
mentoring/mentoring.py
+7
-7
mentoring/public/js/answer.js
+1
-1
mentoring/public/js/mentoring.js
+36
-16
mentoring/public/js/questionnaire.js
+2
-2
No files found.
mentoring/mentoring.py
View file @
f521eb01
...
@@ -138,6 +138,13 @@ class MentoringBlock(XBlockWithLightChildren):
...
@@ -138,6 +138,13 @@ class MentoringBlock(XBlockWithLightChildren):
child
.
save
()
child
.
save
()
completed
=
completed
and
child_result
[
'completed'
]
completed
=
completed
and
child_result
[
'completed'
]
if
self
.
max_attempts_reached
:
message
=
self
.
get_message_html
(
'max_attempts_reached'
)
elif
completed
:
message
=
self
.
get_message_html
(
'completed'
)
else
:
message
=
self
.
get_message_html
(
'incomplete'
)
# Once it has been completed once, keep completion even if user changes values
# Once it has been completed once, keep completion even if user changes values
if
self
.
completed
:
if
self
.
completed
:
completed
=
True
completed
=
True
...
@@ -146,13 +153,6 @@ class MentoringBlock(XBlockWithLightChildren):
...
@@ -146,13 +153,6 @@ class MentoringBlock(XBlockWithLightChildren):
if
self
.
max_attempts_reached
:
if
self
.
max_attempts_reached
:
completed
=
False
completed
=
False
if
completed
:
message
=
self
.
get_message_html
(
'completed'
)
elif
self
.
max_attempts_reached
:
message
=
self
.
get_message_html
(
'max_attempts_reached'
)
else
:
message
=
self
.
get_message_html
(
'incomplete'
)
if
self
.
has_missing_dependency
:
if
self
.
has_missing_dependency
:
completed
=
False
completed
=
False
message
=
'You need to complete all previous steps before being able to complete '
+
\
message
=
'You need to complete all previous steps before being able to complete '
+
\
...
...
mentoring/public/js/answer.js
View file @
f521eb01
...
@@ -3,7 +3,7 @@ function AnswerBlock(runtime, element) {
...
@@ -3,7 +3,7 @@ function AnswerBlock(runtime, element) {
init
:
function
(
options
)
{
init
:
function
(
options
)
{
// register the child validator
// register the child validator
$
(
':input'
,
element
).
on
(
'keyup'
,
options
.
blockValidator
);
$
(
':input'
,
element
).
on
(
'keyup'
,
_
.
debounce
(
options
.
onChange
,
1000
)
);
var
checkmark
=
$
(
'.answer-checkmark'
,
element
);
var
checkmark
=
$
(
'.answer-checkmark'
,
element
);
var
completed
=
$
(
'.xblock-answer'
,
element
).
data
(
'completed'
);
var
completed
=
$
(
'.xblock-answer'
,
element
).
data
(
'completed'
);
...
...
mentoring/public/js/mentoring.js
View file @
f521eb01
function
MentoringBlock
(
runtime
,
element
)
{
function
MentoringBlock
(
runtime
,
element
)
{
var
attemptsTemplate
=
_
.
template
(
$
(
'#xblock-attempts-template'
).
html
());
var
attemptsTemplate
=
_
.
template
(
$
(
'#xblock-attempts-template'
).
html
());
var
children
;
// Keep track of children. A Child need a single object scope for its data.
var
children
;
// Keep track of children. A Child need a single object scope for its data.
var
submitXHR
;
function
renderAttempts
()
{
function
renderAttempts
()
{
var
data
=
$
(
'.attempts'
,
element
).
data
();
var
data
=
$
(
'.attempts'
,
element
).
data
();
...
@@ -83,27 +84,46 @@ function MentoringBlock(runtime, element) {
...
@@ -83,27 +84,46 @@ function MentoringBlock(runtime, element) {
}
}
}
}
function
initXBlock
()
{
function
submit
()
{
var
submit_dom
=
$
(
element
).
find
(
'.submit .input-main'
);
var
success
=
true
;
var
data
=
{};
submit_dom
.
bind
(
'click'
,
function
()
{
var
children
=
getChildren
(
element
);
var
success
=
true
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
data
=
{};
var
child
=
children
[
i
];
var
children
=
getChildren
(
element
);
if
(
child
.
name
!==
undefined
)
{
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
data
[
child
.
name
]
=
callIfExists
(
child
,
'submit'
);
var
child
=
children
[
i
];
if
(
child
.
name
!==
undefined
)
{
data
[
child
.
name
]
=
callIfExists
(
child
,
'submit'
);
}
}
}
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'submit'
);
}
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
data
)).
success
(
handleSubmitResults
);
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'submit'
);
});
if
(
submitXHR
)
{
submitXHR
.
abort
();
}
submitXHR
=
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
data
)).
success
(
handleSubmitResults
);
}
function
resubmit
()
{
// Don't autosubmit if number of attempts is limited.
var
max_attempts
=
$
(
'.attempts'
,
element
).
data
(
'max_attempts'
);
// Only autosubmit if messages are already shown.
var
messages_dom
=
$
(
'.messages'
,
element
);
if
(
messages_dom
.
html
().
trim
()
&&
!
max_attempts
)
{
submit
();
}
}
function
onChange
()
{
validateXBlock
();
resubmit
();
}
function
initXBlock
()
{
$
(
element
).
find
(
'.submit .input-main'
).
bind
(
'click'
,
submit
);
// init children (especially mrq blocks)
// init children (especially mrq blocks)
var
children
=
getChildren
(
element
);
var
children
=
getChildren
(
element
);
var
options
=
{
var
options
=
{
blockValidator
:
validateXBlock
onChange
:
onChange
};
};
_
.
each
(
children
,
function
(
child
)
{
_
.
each
(
children
,
function
(
child
)
{
callIfExists
(
child
,
'init'
,
options
);
callIfExists
(
child
,
'init'
,
options
);
...
...
mentoring/public/js/questionnaire.js
View file @
f521eb01
...
@@ -46,7 +46,7 @@ function MessageView(element) {
...
@@ -46,7 +46,7 @@ function MessageView(element) {
function
MCQBlock
(
runtime
,
element
)
{
function
MCQBlock
(
runtime
,
element
)
{
return
{
return
{
init
:
function
(
options
)
{
init
:
function
(
options
)
{
$
(
'input[type=radio]'
,
element
).
on
(
'change'
,
options
.
blockValidator
);
$
(
'input[type=radio]'
,
element
).
on
(
'change'
,
options
.
onChange
);
},
},
submit
:
function
()
{
submit
:
function
()
{
...
@@ -123,7 +123,7 @@ function MCQBlock(runtime, element) {
...
@@ -123,7 +123,7 @@ function MCQBlock(runtime, element) {
function
MRQBlock
(
runtime
,
element
)
{
function
MRQBlock
(
runtime
,
element
)
{
return
{
return
{
init
:
function
(
options
)
{
init
:
function
(
options
)
{
$
(
'input[type=checkbox]'
,
element
).
on
(
'change'
,
options
.
blockValidator
);
$
(
'input[type=checkbox]'
,
element
).
on
(
'change'
,
options
.
onChange
);
},
},
submit
:
function
()
{
submit
:
function
()
{
...
...
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