Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,068 additions
and
137 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class Metric < ActiveRecord::Base | ||
|
||
|
||
def update_suggestion_chance(response, suggestion_chance) | ||
response.suggestion_chance_percentage = suggestion_chance; | ||
response.save! | ||
end | ||
|
||
def suggestion_chance_average(assignment) | ||
# this method will compute the suggestion_chances average for all responses for the particular assignment | ||
# if no responses exist for particular assignment, return -1 as average suggestion chance | ||
# make a list of responses for a particular assignment | ||
responses = [] | ||
response_map_list = ResponseMap.where(reviewed_object_id: assignment) | ||
response_map_list.each do |rm| | ||
responses += Response.where(map_id: rm.id) # get response for | ||
end | ||
#sum up the suggestion chance percentages | ||
sum = 0 | ||
not_nil_count = 0 | ||
responses.each do |r| | ||
if !r.suggestion_chance_percentage.nil? | ||
sum += r.suggestion_chance_percentage | ||
not_nil_count += 1 | ||
end | ||
end | ||
#return average | ||
if not_nil_count > 0 | ||
return sum / not_nil_count | ||
end | ||
return -1 | ||
end | ||
|
||
def get_sentiment_text(avg_sentiment_for_response) | ||
#convert average into keyword | ||
(avg_sentiment_for_response < -0.3) ? "Negative":(avg_sentiment_for_response > 0.3)?"Positive":"Neutral" | ||
end | ||
|
||
end |
Oops, something went wrong.