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
ea2e6cf6
Commit
ea2e6cf6
authored
Sep 15, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #81 from open-craft/fix-multiple-mentoring-blocks
Properly scope variables in javascript
parents
5c5453db
25fca016
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
46 deletions
+42
-46
mentoring/public/js/answer.js
+5
-6
mentoring/public/js/mentoring-table.js
+1
-1
mentoring/public/js/mentoring.js
+6
-6
mentoring/public/js/mentoring_assessment_view.js
+3
-3
mentoring/public/js/mentoring_standard_view.js
+5
-5
mentoring/public/js/questionnaire.js
+22
-25
No files found.
mentoring/public/js/answer.js
View file @
ea2e6cf6
...
...
@@ -49,10 +49,10 @@ function AnswerBlock(runtime, element) {
if
(
blockquote_ro
.
length
>
0
)
return
true
;
var
input
=
$
(
':input'
,
element
)
,
input_value
=
input
.
val
().
replace
(
/^
\s
+|
\s
+$/gm
,
''
),
answer_length
=
input_value
.
length
,
data
=
input
.
data
();
var
input
=
$
(
':input'
,
element
)
;
var
input_value
=
input
.
val
().
replace
(
/^
\s
+|
\s
+$/gm
,
''
);
var
answer_length
=
input_value
.
length
;
var
data
=
input
.
data
();
// an answer cannot be empty event if min_characters is 0
if
(
_
.
isNumber
(
data
.
min_characters
))
{
...
...
@@ -61,8 +61,7 @@ function AnswerBlock(runtime, element) {
return
false
;
}
}
return
true
;
}
}
}
;
}
mentoring/public/js/mentoring-table.js
View file @
ea2e6cf6
...
...
@@ -5,5 +5,5 @@ function MentoringTableBlock(runtime, element) {
lessText
:
'less'
,
showChars
:
'500'
});
return
{}
return
{}
;
}
mentoring/public/js/mentoring.js
View file @
ea2e6cf6
...
...
@@ -14,8 +14,8 @@ function MentoringBlock(runtime, element) {
}
$
(
document
).
on
(
"click"
,
function
(
event
,
ui
)
{
target
=
$
(
event
.
target
);
feedback_box
=
".mentoring .feedback"
;
var
target
=
$
(
event
.
target
);
var
feedback_box
=
".mentoring .feedback"
;
if
(
target
.
is
(
feedback_box
))
{
return
;
}
...
...
@@ -60,8 +60,8 @@ function MentoringBlock(runtime, element) {
}
function
renderDependency
()
{
var
warning_dom
=
$
(
'.missing-dependency'
,
element
)
,
data
=
warning_dom
.
data
();
var
warning_dom
=
$
(
'.missing-dependency'
,
element
)
;
var
data
=
warning_dom
.
data
();
if
(
data
.
missing
===
'True'
)
{
warning_dom
.
show
();
...
...
@@ -72,8 +72,8 @@ function MentoringBlock(runtime, element) {
var
doms
=
$
(
'.xblock-light-child'
,
element
);
$
.
each
(
doms
,
function
(
index
,
child_dom
)
{
var
child_type
=
$
(
child_dom
).
attr
(
'data-type'
)
,
child
=
window
[
child_type
];
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'
)
{
...
...
mentoring/public/js/mentoring_assessment_view.js
View file @
ea2e6cf6
...
...
@@ -23,8 +23,8 @@ function MentoringAssessmentView(runtime, element, mentoring) {
var
data
=
$
(
'.grade'
,
element
).
data
();
cleanAll
();
$
(
'.grade'
,
element
).
html
(
gradeTemplate
(
data
));
reviewDOM
.
hide
()
submitDOM
.
hide
()
reviewDOM
.
hide
()
;
submitDOM
.
hide
()
;
nextDOM
.
hide
();
tryAgainDOM
.
show
();
...
...
@@ -192,7 +192,7 @@ function MentoringAssessmentView(runtime, element, mentoring) {
}
if
(
isLastChild
())
{
nextDOM
.
hide
()
nextDOM
.
hide
()
;
reviewDOM
.
show
();
}
...
...
mentoring/public/js/mentoring_standard_view.js
View file @
ea2e6cf6
function
MentoringStandardView
(
runtime
,
element
,
mentoring
)
{
var
submitXHR
;
var
submitDOM
;
var
submitDOM
,
messagesDOM
;
var
callIfExists
=
mentoring
.
callIfExists
;
...
...
@@ -8,13 +8,13 @@ function MentoringStandardView(runtime, element, mentoring) {
messagesDOM
.
empty
().
hide
();
$
.
each
(
results
.
submitResults
||
[],
function
(
index
,
submitResult
)
{
var
input
=
submitResult
[
0
]
,
result
=
submitResult
[
1
],
child
=
mentoring
.
getChildByName
(
element
,
input
);
var
input
=
submitResult
[
0
]
;
var
result
=
submitResult
[
1
];
var
child
=
mentoring
.
getChildByName
(
element
,
input
);
var
options
=
{
max_attempts
:
results
.
max_attempts
,
num_attempts
:
results
.
num_attempts
}
}
;
callIfExists
(
child
,
'handleSubmit'
,
result
,
options
);
});
...
...
mentoring/public/js/questionnaire.js
View file @
ea2e6cf6
...
...
@@ -17,15 +17,15 @@ function MessageView(element, mentoring) {
var
tip
=
$
(
'.tip'
,
popupDOM
)[
0
];
var
data
=
$
(
tip
).
data
();
if
(
data
&&
data
.
width
)
{
popupDOM
.
css
(
'width'
,
data
.
width
)
popupDOM
.
css
(
'width'
,
data
.
width
)
;
}
else
{
popupDOM
.
css
(
'width'
,
''
)
popupDOM
.
css
(
'width'
,
''
)
;
}
if
(
data
&&
data
.
height
)
{
popupDOM
.
css
(
'height'
,
data
.
height
);
}
else
{
popupDOM
.
css
(
'height'
,
''
)
popupDOM
.
css
(
'height'
,
''
)
;
}
popupDOM
.
show
();
...
...
@@ -45,7 +45,7 @@ function MessageView(element, mentoring) {
},
showMessage
:
function
(
message
)
{
if
(
_
.
isString
(
message
))
{
mentoring
.
setContent
(
this
.
messageDOM
,
message
)
mentoring
.
setContent
(
this
.
messageDOM
,
message
)
;
this
.
showPopup
(
this
.
messageDOM
);
}
else
{
...
...
@@ -58,7 +58,7 @@ function MessageView(element, mentoring) {
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
);
}
}
}
;
}
function
MCQBlock
(
runtime
,
element
,
mentoring
)
{
...
...
@@ -88,11 +88,11 @@ function MCQBlock(runtime, element, mentoring) {
var
choiceInputs
=
$
(
'.choice input'
,
element
);
$
.
each
(
choiceInputs
,
function
(
index
,
choiceInput
)
{
var
choiceInputDOM
=
$
(
choiceInput
)
,
choiceDOM
=
choiceInputDOM
.
closest
(
'.choice'
),
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
),
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
),
choiceTipsCloseDOM
;
var
choiceInputDOM
=
$
(
choiceInput
)
;
var
choiceDOM
=
choiceInputDOM
.
closest
(
'.choice'
);
var
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
);
var
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
);
var
choiceTipsCloseDOM
;
if
(
result
.
completed
&&
choiceInputDOM
.
val
()
===
result
.
submission
)
{
choiceResultDOM
.
addClass
(
'checkmark-correct icon-ok fa-check'
);
...
...
@@ -107,7 +107,7 @@ function MCQBlock(runtime, element, mentoring) {
choiceTipsCloseDOM
=
$
(
'.close'
,
choiceTipsDOM
);
choiceResultDOM
.
off
(
'click'
).
on
(
'click'
,
function
()
{
if
(
choiceTipsDOM
.
html
()
!=
''
)
{
if
(
choiceTipsDOM
.
html
()
!=
=
''
)
{
messageView
.
showMessage
(
choiceTipsDOM
);
}
});
...
...
@@ -128,10 +128,7 @@ function MCQBlock(runtime, element, mentoring) {
validate
:
function
(){
var
checked
=
$
(
'input[type=radio]:checked'
,
element
);
if
(
checked
.
length
)
{
return
true
;
}
return
false
;
return
Boolean
(
checked
.
length
);
}
};
}
...
...
@@ -145,8 +142,8 @@ function MRQBlock(runtime, element, mentoring) {
},
submit
:
function
()
{
var
checkedCheckboxes
=
$
(
'input[type=checkbox]:checked'
,
element
)
,
checkedValues
=
[];
var
checkedCheckboxes
=
$
(
'input[type=checkbox]:checked'
,
element
)
;
var
checkedValues
=
[];
$
.
each
(
checkedCheckboxes
,
function
(
index
,
checkedCheckbox
)
{
checkedValues
.
push
(
$
(
checkedCheckbox
).
val
());
...
...
@@ -165,16 +162,16 @@ function MRQBlock(runtime, element, mentoring) {
'<div class="close icon-remove-sign fa-times-circle"></div>'
);
}
var
questionnaireDOM
=
$
(
'fieldset.questionnaire'
,
element
)
,
data
=
questionnaireDOM
.
data
(),
hide_results
=
(
data
.
hide_results
===
'True'
)
?
true
:
false
;
var
questionnaireDOM
=
$
(
'fieldset.questionnaire'
,
element
)
;
var
data
=
questionnaireDOM
.
data
();
var
hide_results
=
(
data
.
hide_results
===
'True'
)
?
true
:
false
;
$
.
each
(
result
.
choices
,
function
(
index
,
choice
)
{
var
choiceInputDOM
=
$
(
'.choice input[value='
+
choice
.
value
+
']'
,
element
)
,
choiceDOM
=
choiceInputDOM
.
closest
(
'.choice'
),
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
),
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
),
choiceTipsCloseDOM
;
var
choiceInputDOM
=
$
(
'.choice input[value='
+
choice
.
value
+
']'
,
element
)
;
var
choiceDOM
=
choiceInputDOM
.
closest
(
'.choice'
);
var
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
);
var
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
);
var
choiceTipsCloseDOM
;
/* show hint if checked or max_attempts is disabled */
if
(
!
hide_results
&&
...
...
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