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