Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
527fe0ac
Commit
527fe0ac
authored
Feb 08, 2013
by
Valera Rozuvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connected client side check of state at initialization.
parent
b0c616e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
33 deletions
+43
-33
common/lib/xmodule/xmodule/js/src/poll/poll_main.js
+43
-33
No files found.
common/lib/xmodule/xmodule/js/src/poll/poll_main.js
View file @
527fe0ac
...
@@ -26,6 +26,8 @@ PollMain.prototype = {
...
@@ -26,6 +26,8 @@ PollMain.prototype = {
tickSets
=
{};
tickSets
=
{};
c1
=
0
;
c1
=
0
;
logme
(
'poll_answers: '
,
poll_answers
,
'_this.jsonConfig.answers: '
,
_this
.
jsonConfig
.
answers
);
$
.
each
(
poll_answers
,
function
(
index
,
value
)
{
$
.
each
(
poll_answers
,
function
(
index
,
value
)
{
var
numValue
,
text
;
var
numValue
,
text
;
...
@@ -113,6 +115,7 @@ PollMain.prototype = {
...
@@ -113,6 +115,7 @@ PollMain.prototype = {
'total'
:
'10'
'total'
:
'10'
};
};
logme
(
'One.'
);
_this
.
showAnswerGraph
(
response
.
poll_answers
,
response
.
total
);
_this
.
showAnswerGraph
(
response
.
poll_answers
,
response
.
total
);
}());
}());
}
else
{
}
else
{
...
@@ -123,19 +126,9 @@ PollMain.prototype = {
...
@@ -123,19 +126,9 @@ PollMain.prototype = {
function
(
response
)
{
function
(
response
)
{
logme
(
'response:'
,
response
);
logme
(
'response:'
,
response
);
logme
(
'Two.'
);
_this
.
showAnswerGraph
(
response
.
poll_answers
,
response
.
total
);
_this
.
showAnswerGraph
(
response
.
poll_answers
,
response
.
total
);
_this
.
jsonConfig
.
poll_answer
=
answer
;
_this
.
jsonConfig
.
total
=
response
.
total
;
$
.
each
(
response
.
poll_answers
,
function
(
index
,
value
)
{
_this
.
jsonConfig
.
poll_answers
[
index
]
=
value
;
});
logme
(
'Current "jsonConfig": '
);
logme
(
_this
.
jsonConfig
);
_this
.
questionEl
.
children
(
'.poll_question_div'
).
html
(
JSON
.
stringify
(
_this
.
jsonConfig
));
/*
/*
_this.vertModEl.find('.xmodule_ConditionalModule').each(
_this.vertModEl.find('.xmodule_ConditionalModule').each(
function (index, value) {
function (index, value) {
...
@@ -154,6 +147,18 @@ PollMain.prototype = {
...
@@ -154,6 +147,18 @@ PollMain.prototype = {
// Access this object inside inner functions.
// Access this object inside inner functions.
_this
=
this
;
_this
=
this
;
if
(
(
this
.
jsonConfig
.
poll_answer
.
length
>
0
)
&&
(
this
.
jsonConfig
.
answers
.
hasOwnProperty
(
this
.
jsonConfig
.
poll_answer
)
===
false
)
)
{
this
.
questionEl
.
append
(
'<h3>Error!</h3>'
+
'<p>XML data format changed. List of answers was modified, but poll data was not updated.</p>'
);
return
;
}
// Get the DOM id of the question.
// Get the DOM id of the question.
this
.
id
=
this
.
questionEl
.
attr
(
'id'
);
this
.
id
=
this
.
questionEl
.
attr
(
'id'
);
...
@@ -193,6 +198,7 @@ PollMain.prototype = {
...
@@ -193,6 +198,7 @@ PollMain.prototype = {
// If it turns out that the user already answered the question, show the answers graph.
// If it turns out that the user already answered the question, show the answers graph.
if
(
this
.
questionAnswered
===
true
)
{
if
(
this
.
questionAnswered
===
true
)
{
logme
(
'Three'
);
this
.
showAnswerGraph
(
this
.
jsonConfig
.
poll_answers
,
this
.
jsonConfig
.
total
);
this
.
showAnswerGraph
(
this
.
jsonConfig
.
poll_answers
,
this
.
jsonConfig
.
total
);
}
}
}
// End-of: 'postInit': function () {
}
// End-of: 'postInit': function () {
...
@@ -290,9 +296,35 @@ function PollMain(el) {
...
@@ -290,9 +296,35 @@ function PollMain(el) {
_this
.
postInit
();
_this
.
postInit
();
}());
}());
return
;
}
else
{
}
else
{
try
{
try
{
this
.
jsonConfig
=
JSON
.
parse
(
this
.
questionEl
.
children
(
'.poll_question_div'
).
html
());
this
.
jsonConfig
=
JSON
.
parse
(
this
.
questionEl
.
children
(
'.poll_question_div'
).
html
());
$
.
postWithPrefix
(
''
+
this
.
questionEl
.
data
(
'ajax-url'
)
+
'/'
+
'get_state'
,
{},
function
(
response
)
{
logme
(
'Get pre init state.'
);
logme
(
'response:'
,
response
);
_this
.
jsonConfig
.
poll_answer
=
response
.
poll_answer
;
_this
.
jsonConfig
.
total
=
response
.
total
;
$
.
each
(
response
.
poll_answers
,
function
(
index
,
value
)
{
_this
.
jsonConfig
.
poll_answers
[
index
]
=
value
;
});
logme
(
'Current "jsonConfig": '
);
logme
(
_this
.
jsonConfig
);
_this
.
questionEl
.
children
(
'.poll_question_div'
).
html
(
JSON
.
stringify
(
_this
.
jsonConfig
));
_this
.
postInit
();
}
);
return
;
}
catch
(
err
)
{
}
catch
(
err
)
{
logme
(
logme
(
'ERROR: Invalid JSON config for poll ID "'
+
this
.
id
+
'".'
,
'ERROR: Invalid JSON config for poll ID "'
+
this
.
id
+
'".'
,
...
@@ -302,28 +334,6 @@ function PollMain(el) {
...
@@ -302,28 +334,6 @@ function PollMain(el) {
return
;
return
;
}
}
}
}
if
(
(
this
.
jsonConfig
.
poll_answer
.
length
>
0
)
&&
(
this
.
jsonConfig
.
answers
.
hasOwnProperty
(
this
.
jsonConfig
.
poll_answer
)
===
false
)
)
{
this
.
questionEl
.
append
(
'<h3>Error!</h3>'
+
'<p>XML data format changed. List of answers was modified, but poll data was not updated.</p>'
);
return
;
}
$
.
postWithPrefix
(
_this
.
ajax_url
+
'/'
+
'get_state'
,
{},
function
(
response
)
{
logme
(
'Get pre init state.'
);
logme
(
'response:'
,
response
);
_this
.
postInit
();
}
);
}
// End-of: function PollMain(el) {
}
// End-of: function PollMain(el) {
});
// End-of: define('PollMain', ['logme'], function (logme) {
});
// End-of: define('PollMain', ['logme'], function (logme) {
...
...
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