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
205ca5d1
Commit
205ca5d1
authored
Sep 29, 2014
by
Sola
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding staff un-flag capabilities
parent
b933c8b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
10 deletions
+49
-10
crowdxblock/crowdxblock.py
+19
-5
crowdxblock/static/js/src/crowdxblock.js
+30
-5
No files found.
crowdxblock/crowdxblock.py
View file @
205ca5d1
...
@@ -47,10 +47,6 @@ class CrowdXBlock(XBlock):
...
@@ -47,10 +47,6 @@ class CrowdXBlock(XBlock):
# Details on operation when set to 'False' are to be finalized.
# Details on operation when set to 'False' are to be finalized.
# TODO: make this into a boolean instead of a dict
# TODO: make this into a boolean instead of a dict
show_best
=
Dict
(
default
=
{
'showbest'
:
'True'
},
scope
=
Scope
.
user_state_summary
)
show_best
=
Dict
(
default
=
{
'showbest'
:
'True'
},
scope
=
Scope
.
user_state_summary
)
# This Dict determine whether or not the user is staff. This in turn will influence whether or not flagged hints
# will be shown. The method to actually determine whether or not the user is staff is not currently implemented.
# TODO: make this into a boolean instead of a dict
isStaff
=
Dict
(
default
=
{
'isStaff'
:
'true'
},
scope
=
Scope
.
user_state_summary
)
def
student_view
(
self
,
context
=
None
):
def
student_view
(
self
,
context
=
None
):
"""
"""
...
@@ -84,6 +80,24 @@ class CrowdXBlock(XBlock):
...
@@ -84,6 +80,24 @@ class CrowdXBlock(XBlock):
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
return
data
.
decode
(
"utf8"
)
return
data
.
decode
(
"utf8"
)
def
get_user_is_staff
(
self
):
"""
Return self.xmodule_runtime.user_is_staff
This is not a supported part of the XBlocks API. User data is still
being defined. However, It's the only way to get the data right now.
"""
return
self
.
xmodule_runtime
.
user_is_staff
@XBlock.json_handler
def
is_user_staff
(
self
,
_data
,
_suffix
=
''
):
"""
Return whether the user is staff.
Returns:
is_user_staff: indicator for whether the user is staff
"""
result
=
{
'is_user_staff'
:
self
.
get_user_is_staff
()}
return
result
@XBlock.json_handler
@XBlock.json_handler
def
get_hint
(
self
,
data
,
suffix
=
''
):
def
get_hint
(
self
,
data
,
suffix
=
''
):
"""
"""
...
@@ -197,7 +211,7 @@ class CrowdXBlock(XBlock):
...
@@ -197,7 +211,7 @@ class CrowdXBlock(XBlock):
feedback_data
=
{}
feedback_data
=
{}
number_of_hints
=
0
number_of_hints
=
0
# TODO: possibly simply check here whether or not user is staff
# TODO: possibly simply check here whether or not user is staff
if
self
.
isStaff
[
'isStaff'
]
==
'true'
:
if
data
[
'isStaff'
]
==
'true'
:
for
answer_keys
in
self
.
hint_database
:
for
answer_keys
in
self
.
hint_database
:
if
str
(
len
(
self
.
hint_database
[
str
(
answer_keys
)]))
!=
str
(
0
):
if
str
(
len
(
self
.
hint_database
[
str
(
answer_keys
)]))
!=
str
(
0
):
for
hints
in
self
.
hint_database
[
str
(
answer_keys
)]:
for
hints
in
self
.
hint_database
[
str
(
answer_keys
)]:
...
...
crowdxblock/static/js/src/crowdxblock.js
View file @
205ca5d1
...
@@ -12,6 +12,7 @@ function CrowdXBlock(runtime, element){
...
@@ -12,6 +12,7 @@ function CrowdXBlock(runtime, element){
repeatcounter
+=
1
;
repeatcounter
+=
1
;
//use to determine whether or not to initialize hint feedback
//use to determine whether or not to initialize hint feedback
var
hasReceivedHint
=
false
;
var
hasReceivedHint
=
false
;
var
isStaff
=
false
;
Logger
.
listen
(
'seq_next'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_next'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_goto'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_goto'
,
null
,
clearingvariables
);
...
@@ -65,11 +66,27 @@ function CrowdXBlock(runtime, element){
...
@@ -65,11 +66,27 @@ function CrowdXBlock(runtime, element){
//send empty data for ajax call because not having a data field causes error
//send empty data for ajax call because not having a data field causes error
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_feedback'
),
url
:
runtime
.
handlerUrl
(
element
,
'is_user_staff'
),
//possibly send here if user is staff?
data
:
JSON
.
stringify
({}),
//doing so would be helpful to set up a "flagged" seciton for hints
success
:
function
(
result
)
{
data
:
JSON
.
stringify
(
""
),
console
.
log
(
result
);
success
:
getFeedback
if
(
result
[
'is_user_staff'
])
{
ifStaff
=
true
;
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_feedback'
),
data
:
JSON
.
stringify
({
"isStaff"
:
"true"
}),
success
:
getFeedback
});
}
else
{
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_feedback'
),
data
:
JSON
.
stringify
({
"isStaff"
:
"false"
}),
success
:
getFeedback
});
}
}
});
});
}
}
}
}
...
@@ -85,6 +102,14 @@ function CrowdXBlock(runtime, element){
...
@@ -85,6 +102,14 @@ function CrowdXBlock(runtime, element){
//so that when a button is clicked, the answer and hint can be sent to the python script
//so that when a button is clicked, the answer and hint can be sent to the python script
student_answer
=
value
;
student_answer
=
value
;
hint_used
=
index
;
hint_used
=
index
;
if
(
isStaff
==
true
)
{
$
(
'.feedback'
,
element
).
append
(
"<p class=
\"
flagged_hints"
\
"</p>"
);
if
(
student_answer
==
"Flagged"
)
{
$
(
".flagged_hints"
,
element
).
append
(
"<p class="
+
hint_used
+
"><div role=
\"
button
\"
class=
\"
return_hint
\"
"
+
" aria-label=
\"
return
\"
><b>O</b></div><div>"
+
hint_used
+
"</div> <div role=
\"
button
\"
class=
\"
purge_hint
\"
aria-label=
\"
purge
\"
><b>X</b></div></p>
}
}
if($("
.
submit
"+student_answer).length == 0){
if($("
.
submit
"+student_answer).length == 0){
$('.feedback', element).append("
<
p
class
=
\
"submit"
+
student_answer
+
"
\"
</p>"
);
$('.feedback', element).append("
<
p
class
=
\
"submit"
+
student_answer
+
"
\"
</p>"
);
$
(
".submit"
+
student_answer
,
element
).
append
(
"<b>Answer-specific hints for
\
b"
+
" "
+
student_answer
+
"<p><input id=
\"
submitbuttonfor"
+
student_answer
+
"
\"
style=
\"
float: right; float: top;
\"
type=
\"
button
\"
class=
\"
submitbutton
\"
value=
\"
Submit a hint
\"
><p class=
\"
showHintsFor"
+
student_answer
+
"
\"
> </p></div>"
);
$
(
".submit"
+
student_answer
,
element
).
append
(
"<b>Answer-specific hints for
\
b"
+
" "
+
student_answer
+
"<p><input id=
\"
submitbuttonfor"
+
student_answer
+
"
\"
style=
\"
float: right; float: top;
\"
type=
\"
button
\"
class=
\"
submitbutton
\"
value=
\"
Submit a hint
\"
><p class=
\"
showHintsFor"
+
student_answer
+
"
\"
> </p></div>"
);
...
...
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