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
e708c6db
Commit
e708c6db
authored
Jan 01, 2015
by
solashirai
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further work on XML and fix to hint submission
parent
7756e09a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
crowdsourcehinter/crowdsourcehinter.py
+17
-7
crowdsourcehinter/static/js/src/crowdsourcehinter.js
+10
-5
No files found.
crowdsourcehinter/crowdsourcehinter.py
View file @
e708c6db
...
...
@@ -22,14 +22,17 @@ class CrowdsourceHinter(XBlock):
# Database of hints. hints are stored as such: {"incorrect_answer": {"hint": rating}}. each key (incorrect answer)
# has a corresponding dictionary (in which hints are keys and the hints' ratings are the values).
hint_database
=
Dict
(
default
=
{},
scope
=
Scope
.
user_state_summary
)
# Database of initial hints, set by the course instructor. If initial hints are set by the instructor, hint_database's contents
# will become identical to initial_hints. The datastructure for initial_hints is the same as for hint_databsae,
# {"incorrect_answer": {"hint": rating}}
initial_hints
=
Dict
(
default
=
{},
scope
=
Scope
.
content
)
# This is a list of incorrect answer submissions made by the student. this list is mostly used for
# feedback, to find which incorrect answer's hint a student voted on.
WrongAnswers
=
List
([],
scope
=
Scope
.
user_state
)
# A dictionary of
default
hints. default hints will be shown to students when there are no matches with the
# A dictionary of
generic_
hints. default hints will be shown to students when there are no matches with the
# student's incorrect answer within the hint_database dictionary (i.e. no students have made hints for the
# particular incorrect answer)
#
DefaultHints
=
List
(
default
=
[],
scope
=
Scope
.
content
)
generic_hints
=
List
(
default
=
[],
scope
=
Scope
.
content
)
# List of which hints have been shown to the student
# this list is used to prevent the same hint from showing up to a student (if they submit the same incorrect answers
# multiple times)
...
...
@@ -113,6 +116,12 @@ class CrowdsourceHinter(XBlock):
or another random hint for an incorrect answer
or 'Sorry, there are no more hints for this answer.' if no more hints exist
"""
# populate hint_database with hints from initial_hints if there are no hints in hint_database.
# this probably will occur only on the very first run of a unit containing this block.
if
not
bool
(
self
.
hint_database
):
temporarydict
=
{}
temporarydict
=
self
.
initial_hints
self
.
hint_database
=
temporarydict
answer
=
str
(
data
[
"submittedanswer"
])
answer
=
answer
.
lower
()
# for analyzing the student input string I make it lower case.
found_equal_sign
=
0
...
...
@@ -151,8 +160,8 @@ class CrowdsourceHinter(XBlock):
self
.
Used
.
append
(
not_used
)
return
{
'HintsToUse'
:
not_used
,
"StudentAnswer"
:
answer
}
else
:
if
len
(
self
.
DefaultH
ints
)
!=
0
:
not_used
=
random
.
choice
(
self
.
DefaultH
ints
)
if
len
(
self
.
generic_h
ints
)
!=
0
:
not_used
=
random
.
choice
(
self
.
generic_h
ints
)
self
.
Used
.
append
(
not_used
)
return
{
'HintsToUse'
:
not_used
,
"StudentAnswer"
:
answer
}
else
:
...
...
@@ -345,7 +354,7 @@ class CrowdsourceHinter(XBlock):
return
else
:
# if the hint exists already, simply upvote the previously entered hint
if
str
(
submission
)
in
self
.
DefaultH
ints
:
if
str
(
submission
)
in
self
.
generic_h
ints
:
return
else
:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer
)])
...
...
@@ -380,5 +389,6 @@ class CrowdsourceHinter(XBlock):
A minimal working test for parse_xml
"""
block
=
runtime
.
construct_xblock_from_class
(
cls
,
keys
)
block
.
DefaultHints
=
[
"Make sure to check your answer for basic mistakes like spelling!"
]
block
.
generic_hints
=
[
"Make sure to check your answer for basic mistakes like spelling!"
]
block
.
initial_hints
=
{
"michigann"
:
{
"You have an extra N in your answer"
:
1
}}
return
block
crowdsourcehinter/static/js/src/crowdsourcehinter.js
View file @
e708c6db
...
...
@@ -84,6 +84,11 @@ function CrowdsourceHinter(runtime, element){
html
=
Mustache
.
render
(
$
(
"#show_hint_feedback"
).
html
(),
data
);
});
$
(
this
).
append
(
html
);
var
html
=
""
;
var
template
=
$
(
'#add_hint_creation'
).
html
();
var
data
=
{};
html
=
Mustache
.
render
(
template
,
data
);
$
(
this
).
append
(
html
);
}
});
}
...
...
@@ -133,6 +138,11 @@ function CrowdsourceHinter(runtime, element){
var
data
=
{};
html
=
Mustache
.
render
(
template
,
data
);
$
(
this
).
append
(
html
);
var
html
=
""
;
var
template
=
$
(
'#add_hint_creation'
).
html
();
var
data
=
{};
html
=
Mustache
.
render
(
template
,
data
);
$
(
this
).
append
(
html
);
}
});
}
...
...
@@ -140,11 +150,6 @@ function CrowdsourceHinter(runtime, element){
else
{
showHintFeedback
(
hint
,
student_answer
);
}
var
html
=
""
;
var
template
=
$
(
'#add_hint_creation'
).
html
();
var
data
=
{};
html
=
Mustache
.
render
(
template
,
data
);
$
(
this
).
append
(
html
);
});
isShowingHintFeedback
=
true
;
}
...
...
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