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
3dae4d29
Commit
3dae4d29
authored
Feb 25, 2013
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset part-1
parent
4713c5f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletions
+47
-1
common/lib/xmodule/xmodule/js/src/poll/poll_main.js
+35
-0
common/lib/xmodule/xmodule/poll_module.py
+12
-1
No files found.
common/lib/xmodule/xmodule/js/src/poll/poll_main.js
View file @
3dae4d29
...
...
@@ -50,7 +50,32 @@ PollMain.prototype = {
_this
.
ajax_url
+
'/'
+
answer
,
{},
function
(
response
)
{
_this
.
showAnswerGraph
(
response
.
poll_answers
,
response
.
total
);
_this
.
resetButton
.
show
();
if
(
_this
.
wrapperSectionEl
!==
null
)
{
$
(
_this
.
wrapperSectionEl
).
find
(
'.xmodule_ConditionalModule'
).
each
(
function
(
index
,
value
)
{
new
window
.
Conditional
(
value
,
_this
.
id
.
replace
(
/^poll_/
,
''
));
});
}
}
);
},
// End-of: 'submitAnswer': function (answer, answerEl) {
'submitReset'
:
function
()
{
var
_this
;
_this
=
this
;
// Send the data to the server as an AJAX request. Attach a callback that will
// be fired on server's response.
$
.
postWithPrefix
(
_this
.
ajax_url
+
'/'
+
'reset'
,
{},
function
(
response
)
{
_this
.
questionAnswered
=
false
;
$
(
_this
.
questionEl
).
find
(
'.button'
).
removeClass
(
'answered'
);
_this
.
graphAnswerEl
.
hide
();
$
(
_this
.
questionEl
).
find
(
'.stats'
).
hide
();
_this
.
resetButton
.
hide
();
if
(
_this
.
wrapperSectionEl
!==
null
)
{
$
(
_this
.
wrapperSectionEl
).
find
(
'.xmodule_ConditionalModule'
).
each
(
function
(
index
,
value
)
{
new
window
.
Conditional
(
value
,
_this
.
id
.
replace
(
/^poll_/
,
''
));
...
...
@@ -158,6 +183,15 @@ PollMain.prototype = {
this
.
graphAnswerEl
.
hide
();
this
.
graphAnswerEl
.
appendTo
(
this
.
questionEl
);
if
(
_this
.
jsonConfig
.
reset
===
"True"
)
{
_this
.
resetButton
=
$
(
'<div class="button reset-button">Reset</div>'
);
_this
.
resetButton
.
appendTo
(
_this
.
questionEl
);
_this
.
resetButton
.
hide
();
_this
.
resetButton
.
on
(
'click'
,
function
()
{
_this
.
submitReset
();
});
}
// If it turns out that the user already answered the question, show the answers graph.
if
(
this
.
questionAnswered
===
true
)
{
this
.
showAnswerGraph
(
this
.
jsonConfig
.
poll_answers
,
this
.
jsonConfig
.
total
);
...
...
@@ -234,6 +268,7 @@ function PollMain(el) {
});
_this
.
questionEl
.
children
(
'.poll_question_div'
).
html
(
JSON
.
stringify
(
_this
.
jsonConfig
));
_this
.
postInit
();
}
);
...
...
common/lib/xmodule/xmodule/poll_module.py
View file @
3dae4d29
...
...
@@ -75,6 +75,16 @@ class PollModule(XModule):
'poll_answers'
:
self
.
poll_answers
,
'total'
:
sum
(
self
.
poll_answers
.
values
())
})
elif
dispatch
==
'reset_poll'
and
self
.
voted
:
self
.
voted
=
False
# FIXME: fix this, when xblock will support mutable types.
# Now we use this hack.
temp_poll_answers
=
self
.
poll_answers
temp_poll_answers
[
self
.
poll_answer
]
-=
1
self
.
poll_answers
=
temp_poll_answers
self
.
poll_answer
=
''
else
:
# return error message
return
json
.
dumps
({
'error'
:
'Unknown Command!'
})
...
...
@@ -119,7 +129,8 @@ class PollModule(XModule):
# to show answered poll after reload:
'poll_answer'
:
self
.
poll_answer
,
'poll_answers'
:
self
.
poll_answers
if
self
.
voted
else
{},
'total'
:
sum
(
self
.
poll_answers
.
values
())
if
self
.
voted
else
0
})
'total'
:
sum
(
self
.
poll_answers
.
values
())
if
self
.
voted
else
0
,
'reset'
:
self
.
descriptor
.
xml_attributes
.
get
(
'reset'
,
True
)})
class
PollDescriptor
(
MakoModuleDescriptor
,
XmlDescriptor
):
...
...
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