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
2af1ddca
Commit
2af1ddca
authored
Apr 07, 2016
by
Jacek Bzdak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed special handling when hiding video blocks.
parent
5a0c5535
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
40 deletions
+45
-40
problem_builder/public/js/lms_util.js
+22
-24
problem_builder/public/js/mentoring_with_steps.js
+15
-14
problem_builder/public/js/step.js
+8
-2
No files found.
problem_builder/public/js/lms_util.js
View file @
2af1ddca
(
function
()
{
(
function
()
{
/**
/**
* Manager for HTML XBlocks. These blocks are hid by detaching and shown
* Manager for HTML XBlocks. These blocks are hid
den
by detaching and shown
* by re-attaching them to the DOM.
This is only generic
way to generically
* by re-attaching them to the DOM.
This is only
way to generically
* handle things like video players (they should stop playing when removed from DOM).
* handle things like video players (they should stop playing when removed from DOM).
*
*
* @param html an html xblock
* @param html an html xblock
...
@@ -20,27 +20,25 @@
...
@@ -20,27 +20,25 @@
/**
/**
*
*
* Manager for HTML Video child. Videos are
paused when hiding them, and
re-sized when showing them.
* Manager for HTML Video child. Videos are re-sized when showing them.
* @param video an video xblock
* @param video an video xblock
*
*
*/
*/
function
VideoManager
(
video
)
{
function
VideoManager
(
video
)
{
this
.
show
=
function
()
{
this
.
show
=
function
()
{
if
(
typeof
video
.
resizer
===
'undefined'
){
if
(
typeof
video
.
resizer
===
'undefined'
)
{
// This one is tricky: but it looks like resizer is undefined only if the video is on the
// This one is tricky: but it looks like resizer is undefined only if the video is on the
// step that is initially visible (and then no resizing is necessary)
// step that is initially visible (and then no resizing is necessary)
return
;
return
;
}
}
video
.
resizer
.
align
();
video
.
resizer
.
align
();
};
};
this
.
hide
=
function
()
{
/**
if
(
typeof
video
.
videoPlayer
===
'undefined'
){
* Videos should be paused when user leaves a step containing a video. There is was a proposed implementation
// If video player is undefined this means that the video isn't loaded yet, so no need to
* but since it didn't work on every system we decided to drop it (it was out of scope for current task
// pause it.
* nevertheless). See OC-1441 for details.
return
;
*/
}
this
.
hide
=
function
()
{};
video
.
videoPlayer
.
pause
();
};
}
}
/**
/**
...
@@ -65,48 +63,48 @@
...
@@ -65,48 +63,48 @@
var
children
=
runtime
.
children
(
xblock_element
);
var
children
=
runtime
.
children
(
xblock_element
);
/**
/**
* A list of managers for children tha
n
need special care when showing or hiding.
* A list of managers for children tha
t
need special care when showing or hiding.
*
*
* @type {show, hide}[]
* @type {show, hide}[]
*/
*/
var
managedChildren
=
[];
var
managedChildren
=
[];
/***
/***
* This is a workaround for issue where jquery.xblock.Runtime doesn't return HTML
X
blocks when querying
* This is a workaround for issue where jquery.xblock.Runtime doesn't return HTML blocks when querying
* for children.
* for children.
*
*
* This can be removed when:
* This can be removed when:
*
*
* * We allow inclusion of Ooyala blocks inside
Problem
Builder and our clients migrate to Ooyala, in this case
* * We allow inclusion of Ooyala blocks inside
Step
Builder and our clients migrate to Ooyala, in this case
* we may drop special handling of HTML blocks. See discussions in OC-1441.
* we may drop special handling of HTML blocks. See discussions in OC-1441.
* * We include HTML blocks in runtime.children for runtime of jquery.xblock, then just add
* * We include HTML blocks in runtime.children for runtime of jquery.xblock, then just add
* `html: HtmlManager` to `Managers`, and remove this block.
* `html: HtmlManager` to `Managers`, and remove this block.
*/
*/
$
(
"div.xblock.xblock-student_view.xmodule_HtmlModule"
,
xblock_element
).
each
(
function
(
idx
,
element
)
{
$
(
"div.xblock.xblock-student_view.xmodule_HtmlModule"
,
xblock_element
).
each
(
function
(
idx
,
element
)
{
managedChildren
.
push
(
new
HtmlManager
({
element
:
element
}));
managedChildren
.
push
(
new
HtmlManager
({
element
:
element
}));
});
});
for
(
var
idx
=
0
;
idx
<
children
.
length
;
idx
++
){
for
(
var
idx
=
0
;
idx
<
children
.
length
;
idx
++
)
{
var
child
=
children
[
idx
];
var
child
=
children
[
idx
];
// NOTE: While following assertion is true for e.g Video blocks:
// NOTE: While
the
following assertion is true for e.g Video blocks:
// child.type == $(child.element).data('block-type') it is invalid
ated by
for all sb-* blocks
// child.type == $(child.element).data('block-type') it is invalid for all sb-* blocks
var
type
=
$
(
child
.
element
).
data
(
'block-type'
);
var
type
=
$
(
child
.
element
).
data
(
'block-type'
);
var
constructor
=
Managers
[
type
];
var
constructor
=
Managers
[
type
];
if
(
typeof
constructor
===
'undefined'
){
if
(
typeof
constructor
===
'undefined'
)
{
// This block does not requires special care, moving on
// This block does not requires special care, moving on
continue
;
continue
;
}
}
managedChildren
.
push
(
new
constructor
(
child
));
managedChildren
.
push
(
new
constructor
(
child
));
}
}
this
.
show
=
function
()
{
this
.
show
=
function
()
{
for
(
var
idx
=
0
;
idx
<
managedChildren
.
length
;
idx
++
)
{
for
(
var
idx
=
0
;
idx
<
managedChildren
.
length
;
idx
++
)
{
managedChildren
[
idx
].
show
();
managedChildren
[
idx
].
show
();
}
}
};
};
this
.
hide
=
function
()
{
this
.
hide
=
function
()
{
for
(
var
idx
=
0
;
idx
<
managedChildren
.
length
;
idx
++
)
{
for
(
var
idx
=
0
;
idx
<
managedChildren
.
length
;
idx
++
)
{
managedChildren
[
idx
].
hide
();
managedChildren
[
idx
].
hide
();
}
}
};
};
...
...
problem_builder/public/js/mentoring_with_steps.js
View file @
2af1ddca
...
@@ -40,7 +40,7 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -40,7 +40,7 @@ function MentoringWithStepsBlock(runtime, element) {
*
*
* @param func single arg function.
* @param func single arg function.
*/
*/
function
forEachStep
(
func
){
function
forEachStep
(
func
)
{
for
(
var
idx
=
0
;
idx
<
steps
.
length
;
idx
++
)
{
for
(
var
idx
=
0
;
idx
<
steps
.
length
;
idx
++
)
{
func
(
steps
[
idx
]);
func
(
steps
[
idx
]);
}
}
...
@@ -51,15 +51,15 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -51,15 +51,15 @@ function MentoringWithStepsBlock(runtime, element) {
*/
*/
function
showActiveStep
()
{
function
showActiveStep
()
{
var
step
=
getActiveStep
();
var
step
=
getActiveStep
();
step
.
show
();
step
.
show
Step
();
}
}
/**
/**
* Hides all steps
* Hides all steps
*/
*/
function
hideAllSteps
()
{
function
hideAllSteps
()
{
forEachStep
(
function
(
step
){
forEachStep
(
function
(
step
)
{
step
.
hide
();
step
.
hide
Step
();
});
});
}
}
...
@@ -251,17 +251,19 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -251,17 +251,19 @@ function MentoringWithStepsBlock(runtime, element) {
reviewButtonDOM
.
hide
();
reviewButtonDOM
.
hide
();
tryAgainDOM
.
show
();
tryAgainDOM
.
show
();
/**
// reviewStepDOM is detached in hideReviewStep
* We detach review step from DOM, this is required to handle HTML
* blocks that can be added to the Review step.
*
* NOTE: This is handled differently than step js. As the html contents
* of review step are replaced with fresh contents in submit function.
*/
reviewStepDOM
.
insertBefore
(
reviewStepAnchor
);
reviewStepDOM
.
insertBefore
(
reviewStepAnchor
);
reviewStepDOM
.
show
();
reviewStepDOM
.
show
();
}
}
/**
* We detach review step from DOM, this is required to handle HTML
* blocks with embedded videos, that can be added to that step.
*
* NOTE: Review steps are handled differently than "normal" steps:
* the HTML contents of a review step are replaced with fresh
* contents in submit function.
*/
function
hideReviewStep
()
{
function
hideReviewStep
()
{
reviewStepDOM
.
hide
();
reviewStepDOM
.
hide
();
reviewStepDOM
.
detach
();
reviewStepDOM
.
detach
();
...
@@ -312,7 +314,6 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -312,7 +314,6 @@ function MentoringWithStepsBlock(runtime, element) {
}
// Don't show attempts if unlimited attempts available (max_attempts === 0)
}
// Don't show attempts if unlimited attempts available (max_attempts === 0)
}
}
function
onChange
()
{
function
onChange
()
{
// We do not allow users to modify answers belonging to a step after submitting them:
// We do not allow users to modify answers belonging to a step after submitting them:
// Once an answer has been submitted ("Next Step" button is enabled),
// Once an answer has been submitted ("Next Step" button is enabled),
...
@@ -413,7 +414,7 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -413,7 +414,7 @@ function MentoringWithStepsBlock(runtime, element) {
submitXHR
=
$
.
post
(
handlerUrl
,
JSON
.
stringify
({})).
success
(
handleTryAgain
);
submitXHR
=
$
.
post
(
handlerUrl
,
JSON
.
stringify
({})).
success
(
handleTryAgain
);
}
}
function
notify
(
name
,
data
){
function
notify
(
name
,
data
)
{
// Notification interface does not exist in the workbench.
// Notification interface does not exist in the workbench.
if
(
runtime
.
notify
)
{
if
(
runtime
.
notify
)
{
runtime
.
notify
(
name
,
data
);
runtime
.
notify
(
name
,
data
);
...
@@ -439,7 +440,7 @@ function MentoringWithStepsBlock(runtime, element) {
...
@@ -439,7 +440,7 @@ function MentoringWithStepsBlock(runtime, element) {
var
itemFeedbackParentSelector
=
'.choice'
;
var
itemFeedbackParentSelector
=
'.choice'
;
var
itemFeedbackSelector
=
".choice .choice-tips"
;
var
itemFeedbackSelector
=
".choice .choice-tips"
;
function
clickedInside
(
selector
,
parent_selector
){
function
clickedInside
(
selector
,
parent_selector
)
{
return
target
.
is
(
selector
)
||
target
.
parents
(
parent_selector
).
length
>
0
;
return
target
.
is
(
selector
)
||
target
.
parents
(
parent_selector
).
length
>
0
;
}
}
...
...
problem_builder/public/js/step.js
View file @
2af1ddca
...
@@ -105,12 +105,18 @@ function MentoringStepBlock(runtime, element) {
...
@@ -105,12 +105,18 @@ function MentoringStepBlock(runtime, element) {
return
$
(
'.sb-step'
,
element
).
data
(
'has-question'
);
return
$
(
'.sb-step'
,
element
).
data
(
'has-question'
);
},
},
show
:
function
()
{
/**
* Shows a step, updating all children.
*/
showStep
:
function
()
{
$
(
element
).
show
();
$
(
element
).
show
();
childManager
.
show
();
childManager
.
show
();
},
},
hide
:
function
()
{
/**
* Hides a step, updating all children.
*/
hideStep
:
function
()
{
$
(
element
).
hide
();
$
(
element
).
hide
();
childManager
.
hide
();
childManager
.
hide
();
}
}
...
...
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