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
6598d2b0
Commit
6598d2b0
authored
Jan 23, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JS changes to get "Mentoring With Only One Step" scenario working
parent
338c6d50
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
72 deletions
+34
-72
mentoring/components/public/js/questionnaire.js
+11
-3
mentoring/public/js/mentoring.js
+19
-50
mentoring/public/js/mentoring_standard_view.js
+4
-19
No files found.
mentoring/components/public/js/questionnaire.js
View file @
6598d2b0
...
...
@@ -61,10 +61,12 @@ function MessageView(element, mentoring) {
};
}
function
MCQBlock
(
runtime
,
element
,
mentoring
)
{
function
MCQBlock
(
runtime
,
element
)
{
return
{
mode
:
null
,
mentoring
:
null
,
init
:
function
(
options
)
{
this
.
mentoring
=
options
.
mentoring
;
this
.
mode
=
options
.
mode
;
$
(
'input[type=radio]'
,
element
).
on
(
'change'
,
options
.
onChange
);
},
...
...
@@ -83,6 +85,8 @@ function MCQBlock(runtime, element, mentoring) {
if
(
this
.
mode
===
'assessment'
)
return
;
mentoring
=
this
.
mentoring
;
var
messageView
=
MessageView
(
element
,
mentoring
);
messageView
.
clearResult
();
...
...
@@ -123,7 +127,7 @@ function MCQBlock(runtime, element, mentoring) {
},
clearResult
:
function
()
{
MessageView
(
element
,
mentoring
).
clearResult
();
MessageView
(
element
,
this
.
mentoring
).
clearResult
();
},
validate
:
function
(){
...
...
@@ -136,7 +140,9 @@ function MCQBlock(runtime, element, mentoring) {
function
MRQBlock
(
runtime
,
element
,
mentoring
)
{
return
{
mode
:
null
,
mentoring
:
null
,
init
:
function
(
options
)
{
this
.
mentoring
=
options
.
mentoring
;
this
.
mode
=
options
.
mode
;
$
(
'input[type=checkbox]'
,
element
).
on
(
'change'
,
options
.
onChange
);
},
...
...
@@ -155,6 +161,8 @@ function MRQBlock(runtime, element, mentoring) {
if
(
this
.
mode
===
'assessment'
)
return
;
mentoring
=
this
.
mentoring
;
var
messageView
=
MessageView
(
element
,
mentoring
);
if
(
result
.
message
)
{
...
...
@@ -193,7 +201,7 @@ function MRQBlock(runtime, element, mentoring) {
},
clearResult
:
function
()
{
MessageView
(
element
,
mentoring
).
clearResult
();
MessageView
(
element
,
this
.
mentoring
).
clearResult
();
},
validate
:
function
(){
...
...
mentoring/public/js/mentoring.js
View file @
6598d2b0
function
MentoringBlock
(
runtime
,
element
)
{
var
attemptsTemplate
=
_
.
template
(
$
(
'#xblock-attempts-template'
).
html
());
var
data
=
$
(
'.mentoring'
,
element
).
data
();
var
children_dom
=
[];
// Keep track of children. A Child need a single object scope for its data.
var
children
=
[];
var
children
=
runtime
.
children
(
element
);
var
step
=
data
.
step
;
var
mentoring
=
{
callIfExists
:
callIfExists
,
setContent
:
setContent
,
renderAttempts
:
renderAttempts
,
renderDependency
:
renderDependency
,
children
:
children
,
initChildren
:
initChildren
,
getChildByName
:
getChildByName
,
step
:
step
,
publish_event
:
publish_event
};
function
publish_event
(
data
)
{
$
.
ajax
({
type
:
"POST"
,
...
...
@@ -66,41 +77,14 @@ function MentoringBlock(runtime, element) {
}
}
function
readChildren
()
{
var
doms
=
$
(
'.xblock-light-child'
,
element
);
$
.
each
(
doms
,
function
(
index
,
child_dom
)
{
var
child_type
=
$
(
child_dom
).
attr
(
'data-type'
);
var
child
=
window
[
child_type
];
children_dom
.
push
(
child_dom
);
children
.
push
(
child
);
if
(
typeof
child
!==
'undefined'
)
{
child
=
child
(
runtime
,
child_dom
,
mentoring
);
child
.
name
=
$
(
child_dom
).
attr
(
'name'
);
children
[
children
.
length
-
1
]
=
child
;
}
});
}
/* Init and display a child. */
function
displayChild
(
index
,
options
)
{
function
initChildren
(
options
)
{
options
=
options
||
{};
options
.
mentoring
=
mentoring
;
options
.
mode
=
data
.
mode
;
if
(
index
>=
children
.
length
)
return
children
.
length
;
var
template
=
$
(
'#light-child-template'
,
children_dom
[
index
]).
html
();
$
(
children_dom
[
index
]).
append
(
template
);
$
(
children_dom
[
index
]).
show
();
var
child
=
children
[
index
];
callIfExists
(
child
,
'init'
,
options
);
return
child
;
}
function
displayChildren
(
options
)
{
$
.
each
(
children_dom
,
function
(
index
)
{
displayChild
(
index
,
options
);
});
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
child
=
children
[
i
];
callIfExists
(
child
,
'init'
,
options
);
}
}
function
getChildByName
(
element
,
name
)
{
...
...
@@ -112,21 +96,6 @@ function MentoringBlock(runtime, element) {
}
}
var
mentoring
=
{
callIfExists
:
callIfExists
,
setContent
:
setContent
,
renderAttempts
:
renderAttempts
,
renderDependency
:
renderDependency
,
readChildren
:
readChildren
,
children_dom
:
children_dom
,
children
:
children
,
displayChild
:
displayChild
,
displayChildren
:
displayChildren
,
getChildByName
:
getChildByName
,
step
:
step
,
publish_event
:
publish_event
};
if
(
data
.
mode
===
'standard'
)
{
MentoringStandardView
(
runtime
,
element
,
mentoring
);
}
...
...
mentoring/public/js/mentoring_standard_view.js
View file @
6598d2b0
...
...
@@ -73,7 +73,7 @@ function MentoringStandardView(runtime, element, mentoring) {
onChange
:
onChange
};
mentoring
.
display
Children
(
options
);
mentoring
.
init
Children
(
options
);
mentoring
.
renderAttempts
();
mentoring
.
renderDependency
();
...
...
@@ -81,17 +81,6 @@ function MentoringStandardView(runtime, element, mentoring) {
validateXBlock
();
}
function
handleRefreshResults
(
results
)
{
$
(
element
).
html
(
results
.
html
);
mentoring
.
readChildren
();
initXBlockView
();
}
function
refreshXBlock
()
{
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'view'
);
$
.
post
(
handlerUrl
,
'{}'
).
success
(
handleRefreshResults
);
}
// validate all children
function
validateXBlock
()
{
var
is_valid
=
true
;
...
...
@@ -100,8 +89,7 @@ function MentoringStandardView(runtime, element, mentoring) {
if
((
data
.
max_attempts
>
0
)
&&
(
data
.
num_attempts
>=
data
.
max_attempts
))
{
is_valid
=
false
;
}
else
{
}
else
{
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
child
=
children
[
i
];
if
(
child
&&
child
.
name
!==
undefined
)
{
...
...
@@ -112,15 +100,12 @@ function MentoringStandardView(runtime, element, mentoring) {
}
}
}
if
(
!
is_valid
)
{
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
}
else
{
}
else
{
submitDOM
.
removeAttr
(
"disabled"
);
}
}
// We need to manually refresh, XBlocks are currently loaded together with the section
refreshXBlock
(
element
);
initXBlockView
();
}
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