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
76f5ee71
Commit
76f5ee71
authored
Mar 16, 2015
by
solashirai
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issues with logger.listen
parent
f716196e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
crowdsourcehinter/crowdsourcehinter.py
+15
-1
crowdsourcehinter/static/js/src/crowdsourcehinter.js
+21
-6
No files found.
crowdsourcehinter/crowdsourcehinter.py
View file @
76f5ee71
...
...
@@ -8,9 +8,11 @@ import copy
from
copy
import
deepcopy
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
Dict
,
List
,
Boolean
from
xblock.fields
import
Scope
,
Dict
,
List
,
Boolean
,
String
from
xblock.fragment
import
Fragment
from
eventtracking
import
tracker
log
=
logging
.
getLogger
(
__name__
)
class
CrowdsourceHinter
(
XBlock
):
...
...
@@ -59,6 +61,10 @@ class CrowdsourceHinter(XBlock):
# When set to 'True' only the best hint will be shown to the student.
# Details on operation when set to 'False' are to be finalized.
show_best
=
Boolean
(
default
=
True
,
scope
=
Scope
.
user_state_summary
)
# This String represents the xblock element for which the hinter is running. It is necessary to manually
# set this value in the XML file under the format "hinting_element": "i4x://edX/DemoX/problem/Text_Input" .
# Without properly setting this String, the hinter will not correctly be able to use the Logger listen for problem_graded.
Element
=
String
(
default
=
""
,
scope
=
Scope
.
content
)
def
student_view
(
self
,
context
=
None
):
"""
...
...
@@ -103,6 +109,13 @@ class CrowdsourceHinter(XBlock):
return
self
.
xmodule_runtime
.
user_is_staff
@XBlock.json_handler
def
get_element
(
self
,
data
,
suffix
=
''
):
"""
Returns the self.element so that the javascript Logger.listen will be using the correct element.
"""
return
str
(
self
.
Element
);
@XBlock.json_handler
def
is_user_staff
(
self
,
_data
,
_suffix
=
''
):
"""
Return whether the user is staff.
...
...
@@ -404,4 +417,5 @@ class CrowdsourceHinter(XBlock):
xmlText
=
ast
.
literal_eval
((
node
.
text
)
.
encode
(
'utf-8'
))
block
.
generic_hints
.
append
(
xmlText
[
"generic_hints"
])
block
.
initial_hints
=
copy
.
copy
(
xmlText
[
"initial_hints"
])
block
.
Element
=
xmlText
[
"hinting_element"
]
return
block
crowdsourcehinter/static/js/src/crowdsourcehinter.js
View file @
76f5ee71
...
...
@@ -8,13 +8,24 @@ function CrowdsourceHinter(runtime, element){
if
(
executeHinter
){
var
isShowingHintFeedback
=
false
;
var
hinting_element
;
var
isStaff
=
false
;
$
(
".csh_HintsToUse"
,
element
).
text
(
""
);
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_element'
),
data
:
JSON
.
stringify
(
"helloworld"
),
success
:
function
(
result
){
console
.
log
(
"hinting_element being set"
,
result
);
hinting_element
=
result
;
}
});
function
stopScript
(){
//This function is used to prevent a particular instance of the hinter from acting after
//switching between edX course's units.
executeHinter
=
false
;
console
.
log
(
"executeHinter set to false"
);
}
Logger
.
listen
(
'seq_next'
,
null
,
stopScript
);
Logger
.
listen
(
'seq_prev'
,
null
,
stopScript
);
...
...
@@ -23,14 +34,18 @@ function CrowdsourceHinter(runtime, element){
//data about the problem obtained from Logger.listen('problem_graded') is passed on to the onStudentSubmission.
//directly passing data to onStudentSubmission does not appear to work
function
get_event_data
(
event_type
,
data
,
element
){
onStudentSubmission
(
data
);
console
.
log
(
data
);
//
onStudentSubmission(data);
console
.
log
(
"gradedevent listen"
);
}
Logger
.
listen
(
'problem_check'
,
null
,
get_event_data
);
function
print_info
(
event_type
,
data
,
element
){
console
.
log
(
data
);
Logger
.
listen
(
'problem_graded'
,
hinting_element
,
function
(){
console
.
log
(
"test"
)});
Logger
.
listen
(
'problem_graded'
,
'i4x://edX/DemoX/problem/Text_Input'
,
function
(){
console
.
log
(
"test2"
)});
function
get_event_data_temp
(
event_type
,
data
,
element
){
console
.
log
(
"checkevent listen"
);
console
.
log
(
hinting_element
);
console
.
log
(
typeof
(
'i4x://edX/DemoX/problem/Text_Input'
));
}
Logger
.
listen
(
'problem_
graded'
,
null
,
print_info
);
Logger
.
listen
(
'problem_
check'
,
null
,
get_event_data_temp
);
function
onStudentSubmission
(
problem_graded_event_data
){
//This function will determine whether or not the student correctly answered the question.
...
...
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