Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crowdsourcehinter
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
crowdsourcehinter
Commits
fd9a6500
Commit
fd9a6500
authored
Sep 21, 2014
by
Sola
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed student hint submission, squashed bug
parent
75ecb3a6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
20 deletions
+18
-20
crowdxblock/crowdxblock.py
+3
-6
crowdxblock/static/js/src/crowdxblock.js
+15
-14
No files found.
crowdxblock/crowdxblock.py
View file @
fd9a6500
...
...
@@ -362,17 +362,14 @@ class CrowdXBlock(XBlock):
"""
submission
=
data
[
'submission'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
answer
=
data
[
'answer'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
for
answer_keys
in
self
.
hint_database
:
if
str
(
answer_keys
)
==
str
(
answer
):
# find the answer for which a hint is being submitted
if
str
(
submission
)
not
in
self
.
hint_database
[
str
(
answer_keys
)]:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer_keys
)])
if
str
(
submission
)
not
in
self
.
hint_database
[
str
(
answer
)]:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer
)])
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
temporary_dictionary
.
update
({
submission
:
0
})
# once again, manipulating temporary_dictionary and setting
# self.hint_database equal to it due to being unable to directly
# edit self.hint_databse. Most likely scope error
self
.
hint_database
[
str
(
answer_keys
)]
=
temporary_dictionary
self
.
hint_database
[
str
(
answer
)]
=
temporary_dictionary
return
else
:
# if the hint exists already, simply upvote the previously entered hint
...
...
crowdxblock/static/js/src/crowdxblock.js
View file @
fd9a6500
...
...
@@ -121,7 +121,7 @@ function CrowdXBlock(runtime, element){
indexid
=
indexid
.
replace
(
/
\=
/g
,
'eeqquuaallss'
);
if
(
$
(
"#submit"
+
valueid
).
length
==
0
){
$
(
'.hintansarea'
).
append
(
"<p id=
\"
submit"
+
valueid
+
"
\"
class=
\"
hintsarea
\"
> </p>"
);
$
(
'#submit'
+
valueid
).
append
(
"<p> </p><b>Incorrect Answer:
\
b"
+
" "
+
value
+
"<p> <input id=
\"
submitbuttonfor"
+
index
id
+
"
\"
style=
\"
float: right; float: top;
\"
type=
\"
button
\"
class=
\"
submitbutton
\"
value=
\"
Submit a hint
\"
> <p id=
\"
hintstoshow"
+
valueid
+
"
\"
> <b><u>Hints in the Data Base:</u>
\
b </p></div>"
);
$
(
'#submit'
+
valueid
).
append
(
"<p> </p><b>Incorrect Answer:
\
b"
+
" "
+
value
+
"<p> <input id=
\"
submitbuttonfor"
+
value
id
+
"
\"
style=
\"
float: right; float: top;
\"
type=
\"
button
\"
class=
\"
submitbutton
\"
value=
\"
Submit a hint
\"
> <p id=
\"
hintstoshow"
+
valueid
+
"
\"
> <b><u>Hints in the Data Base:</u>
\
b </p></div>"
);
}
if
(
indexid
.
slice
(
0
,
22
)
!=
"There are no hints for"
){
if
(
$
.
inArray
(
index
,
HintUsed
)
==
-
1
){
...
...
@@ -148,42 +148,43 @@ function CrowdXBlock(runtime, element){
if
(
issubmitting
==
repeatcounter
){
id
=
this
.
id
;
id
=
id
.
slice
(
15
);
value
=
document
.
getElementById
(
id
).
getAttribute
(
'data-value'
);
//
value = document.getElementById(id).getAttribute('data-value');
$
(
'.submitbutton'
).
show
();
$
(
'.math'
).
remove
();
$
(
'#submit'
).
remove
();
$
(
this
).
hide
();
$
(
'#hintstoshow'
+
value
).
prepend
(
"<p><input type=
\"
text
\"
name=
\"
studentinput
\"
id=
\"
"
+
id
+
"
\"
class=
\"
math
\"
size=
\"
40
\"
><input id=
\"
submit
\"
type=
\"
button
\"
data-is=
\"
"
+
id
+
"
\"
class=
\"
button
\"
value=
\"
Submit Hint
\"
> </p>"
);
$
(
'#hintstoshow'
+
id
).
prepend
(
"<p><input type=
\"
text
\"
name=
\"
studentinput
\"
id=
\"
"
+
id
+
"
\"
class=
\"
math
\"
size=
\"
40
\"
><input id=
\"
submit
\"
type=
\"
button
\"
data-is=
\"
"
+
id
+
"
\"
class=
\"
button
\"
value=
\"
Submit Hint
\"
> </p>"
);
}})
$
(
document
).
on
(
'click'
,
'#submit'
,
function
(){
issubmittinghint
+=
1
;
if
(
issubmittinghint
==
repeatcounter
){
if
(
$
(
'.math'
).
val
()
!=
null
){
var
answerdata
=
String
;
var
valueid
=
String
;
issubmitting
=
0
;
$
(
'#submit'
).
each
(
function
(){
valueid
=
$
(
this
).
attr
(
'data-is
'
);
answerdata
=
$
(
'.math'
).
attr
(
'id
'
);
});
$
(
'.submitbutton'
).
show
();
console
.
log
(
'valueidworks'
+
valueid
);
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'give_hint'
),
data
:
JSON
.
stringify
({
"submission"
:
$
(
'.math'
).
val
(),
"answer"
:
valueid
}),
//give hin for first incorrect answer
success
:
finish
data
:
JSON
.
stringify
({
"submission"
:
$
(
'.math'
).
val
(),
"answer"
:
answerdata
}),
//give hin for first incorrect answer
//
success: finish
});
$
(
"#answer"
).
val
(
''
);
data_value
=
document
.
getElementById
(
valueid
).
getAttribute
(
'data-value'
);
data_value
=
String
(
'hintstoshow'
+
data_value
);
//
data_value = document.getElementById(valueid).getAttribute('data-value');
data_value
=
String
(
'hintstoshow'
+
answerdata
);
$
(
this
).
remove
();
$
(
'.math'
).
remove
();
document
.
getElementById
(
"submitbuttonfor"
+
valueid
).
remove
();
$
(
'#submitbuttonfor'
+
valueid
).
remove
();
$
(
'#'
+
valueid
).
remove
();
value
=
document
.
getElementById
(
id
).
getAttribute
(
'data-value'
);
$
(
'#hintstoshow'
+
value
).
prepend
(
"<p> Thankyou! </p>"
);
$
(
'#submit'
+
valueid
).
prepend
(
'Thankyou for your hint!'
);
document
.
getElementById
(
"submitbuttonfor"
+
answerdata
).
remove
();
$
(
'#submitbuttonfor'
+
answerdata
).
remove
();
$
(
'#'
+
answerdata
).
remove
();
//
value = document.getElementById(id).getAttribute('data-value');
//
$('#hintstoshow' + value).prepend("<p> Thankyou! </p>");
$
(
'#submit'
+
answerdata
).
prepend
(
'Thankyou for your hint!'
);
}}})
$
(
document
).
on
(
'click'
,
'.hintbutton'
,
function
(){
//upvote
...
...
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