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
ffeeddc2
Commit
ffeeddc2
authored
Sep 14, 2014
by
Sola
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed variable naming
parent
46f15993
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
19 deletions
+18
-19
crowdxblock/crowdxblock.py
+16
-16
crowdxblock/static/js/src/crowdxblock.js
+1
-1
setup.py
+1
-2
No files found.
crowdxblock/crowdxblock.py
View file @
ffeeddc2
...
...
@@ -236,8 +236,8 @@ class CrowdXBlock(XBlock):
Hint ratings in hint_database are updated and the resulting hint rating (or flagged status) is returned to JS.
Args:
data['answer']: The incorrect answer that corresponds to the hint that is being voted on
data['
value
']: The hint that is being voted on
data['
student_
answer']: The incorrect answer that corresponds to the hint that is being voted on
data['
used_hint
']: The hint that is being voted on
data['student_rating']: The rating chosen by the student. The value is -1, 1, or 0.
Returns:
...
...
@@ -245,20 +245,20 @@ class CrowdXBlock(XBlock):
If the hint has already been voted on, 'You have already voted on this hint!'
will be returned to JS.
"""
original_data
=
data
[
'answer'
]
# original strings are saved to return later
answer_data
=
data
[
'answer'
]
original_data
=
data
[
'
student_
answer'
]
# original strings are saved to return later
answer_data
=
data
[
'
student_
answer'
]
# answer_data is manipulated to remove symbols to prevent errors that
# might arise due to certain symbols. I don't think I have this fully working but am not sure.
data_rating
=
data
[
'student_rating'
]
data_
value
=
data
[
'value
'
]
data_
hint
=
data
[
'used_hint
'
]
answer_data
=
self
.
remove_symbols
(
answer_data
)
if
str
(
data
[
'student_rating'
])
==
str
(
0
):
# if student flagged hint
self
.
hint_flagged
(
data
[
'
value
'
],
answer_data
)
self
.
hint_flagged
(
data
[
'
used_hint
'
],
answer_data
)
return
{
"rating"
:
'thiswasflagged'
,
'origdata'
:
original_data
}
if
str
(
answer_data
)
not
in
self
.
Voted
:
self
.
Voted
.
append
(
str
(
answer_data
))
# add data to Voted to prevent multiple votes
rating
=
self
.
change_rating
(
data_
value
,
int
(
data_rating
),
answer_data
)
# change hint rating
rating
=
self
.
change_rating
(
data_
hint
,
int
(
data_rating
),
answer_data
)
# change hint rating
if
str
(
rating
)
==
str
(
0
):
# if the rating is "0", return "zzeerroo" instead. "0" showed up as "null" in JS
return
{
"rating"
:
str
(
'zzeerroo'
),
'origdata'
:
original_data
}
...
...
@@ -267,31 +267,31 @@ class CrowdXBlock(XBlock):
else
:
return
{
"rating"
:
str
(
'You have already voted on this hint!'
),
'origdata'
:
original_data
}
def
hint_flagged
(
self
,
data_
value
,
answer_data
):
def
hint_flagged
(
self
,
data_
hint
,
answer_data
):
"""
This is used to add a hint to the self.flagged dictionary. When a hint is returned with the rating
of 0, it is considered to be flagged.
Args:
data_
value: This is equal to the data['value
'] in self.rate_hint
answer_data: This is equal to the data['answer'] in self.rate_hint
data_
hint: This is equal to the data['used_hint
'] in self.rate_hint
answer_data: This is equal to the data['
student_
answer'] in self.rate_hint
"""
for
answer_keys
in
self
.
hint_database
:
if
answer_keys
==
data_
value
:
if
answer_keys
==
data_
hint
:
for
hint_keys
in
self
.
hint_database
[
str
(
answer_keys
)]:
if
str
(
hint_keys
)
==
answer_data
:
self
.
Flagged
[
str
(
hint_keys
)]
=
str
(
answer_keys
)
def
change_rating
(
self
,
data_
value
,
data_rating
,
answer_data
):
def
change_rating
(
self
,
data_
hint
,
data_rating
,
answer_data
):
"""
This function is used to change the rating of a hint when it is voted on.
Initiated by rate_hint. The temporary_dictionary is manipulated to be used
in self.rate_hint
Args:
data_
value: This is equal to the data['value
'] in self.rate_hint
data_
hint: This is equal to the data['used_hint
'] in self.rate_hint
data_rating: This is equal to the data['student_rating'] in self.rate_hint
answer_data: This is equal to the data['answer'] in self.rate_hint
answer_data: This is equal to the data['
student_
answer'] in self.rate_hint
Returns:
The rating associated with the hint is returned. This rating is identical
...
...
@@ -299,9 +299,9 @@ class CrowdXBlock(XBlock):
"""
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer_data
)])
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
temporary_dictionary
[
str
(
data_
value
)]
+=
int
(
data_rating
)
temporary_dictionary
[
str
(
data_
hint
)]
+=
int
(
data_rating
)
self
.
hint_database
[
str
(
answer_data
)]
=
temporary_dictionary
return
str
(
temporary_dictionary
[
str
(
data_
value
)])
return
str
(
temporary_dictionary
[
str
(
data_
hint
)])
def
remove_symbols
(
self
,
answer_data
):
"""
...
...
crowdxblock/static/js/src/crowdxblock.js
View file @
ffeeddc2
...
...
@@ -197,7 +197,7 @@ function CrowdXBlock(runtime, element){
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
data
:
JSON
.
stringify
({
"student_rating"
:
$
(
this
).
attr
(
'data-rate'
),
"
answer"
:
$
(
this
).
attr
(
'id'
),
"value
"
:
$
(
this
).
attr
(
'data-value'
)}),
data
:
JSON
.
stringify
({
"student_rating"
:
$
(
this
).
attr
(
'data-rate'
),
"
student_answer"
:
$
(
this
).
attr
(
'id'
),
"used_hint
"
:
$
(
this
).
attr
(
'data-value'
)}),
success
:
finish
});})
...
...
setup.py
View file @
ffeeddc2
...
...
@@ -36,4 +36,4 @@ setup(
]
},
package_data
=
package_data
(
"crowdxblock"
,
[
"static"
,
"public"
]),
)
\ No newline at end of file
)
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