Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1705 To track the time students spend on reviewing others' submission #875

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f7690de
Committing new model, controller for responsetime and application.js
srjhawar Nov 30, 2016
c80d08b
Add changes to call responsetime controller to record start and end t…
payalchheda Nov 30, 2016
8794ce9
edit and view pages can also track succesfully now
navisingh14 Dec 1, 2016
d2123f8
Added response time table in reviewer_details_popup view
srjhawar Dec 1, 2016
7726541
Merge branch 'master' of https://github.com/navisingh14/expertiza
srjhawar Dec 1, 2016
0d394ae
Global timer
Dec 1, 2016
aff8111
Global timer
Dec 1, 2016
aca3119
merge resolved
Dec 1, 2016
5d5b41f
Added missing </div> in reviewer_details_popup.html.erb
srjhawar Dec 1, 2016
f7bdc58
Add time spent on reviewing to Instructor review report view
payalchheda Dec 1, 2016
97b73b9
Change time recorded in review_mapping_helper to mins instead of seconds
payalchheda Dec 1, 2016
19f40fb
Update time recorded in review_mapping_helper to mins with precision …
payalchheda Dec 1, 2016
3a07bfa
Update time recorded (previous commit was buggy) in review_mapping_he…
payalchheda Dec 1, 2016
528ed01
Changed decimal precision to 2 for response times
srjhawar Dec 1, 2016
4847eba
Remove missing template error and remove logging statements
payalchheda Dec 2, 2016
70659d2
Merge remote-tracking branch 'origin/master'
payalchheda Dec 2, 2016
f6fb42e
Reviewer view - table changes
Dec 2, 2016
be93cd4
Reviewer view-table changes
Dec 2, 2016
9a247c0
Refactor file names to response_time*
payalchheda Dec 2, 2016
0f45999
change to refactor file names to response_time*
payalchheda Dec 2, 2016
78a243a
Changed the float precision value to 2 for individual link times
srjhawar Dec 2, 2016
10bfd78
Recitified total time which was not seen for multiple rounds. Total t…
srjhawar Dec 2, 2016
181d1d3
Renamed view file to html.erb
srjhawar Dec 3, 2016
8a9221d
changing spec/controllers/response_time_controller
navisingh14 Dec 3, 2016
c6349ad
Chart for links
Dec 3, 2016
d16be93
Chart view for links Merge branch 'master' of https://github.com/navi…
Dec 3, 2016
3add518
Merge branch 'master' of https://github.com/navisingh14/expertiza
navisingh14 Dec 3, 2016
d7af8a1
changed definition of test name
navisingh14 Dec 3, 2016
1a9e83d
changed formatting
navisingh14 Dec 3, 2016
30bc6aa
minor changes
navisingh14 Dec 3, 2016
39c067d
Adding gem responders
srjhawar Dec 3, 2016
2138a63
Changed the pop up timeout limit to 5 mins
srjhawar Dec 3, 2016
00b415e
Merge branch 'master' of https://github.com/navisingh14/expertiza
srjhawar Dec 3, 2016
3057e63
merging commit
navisingh14 Dec 4, 2016
d4fe16e
Gemfile.lock updated
navisingh14 Dec 4, 2016
e508331
db:migrate
navisingh14 Dec 4, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ gem 'protected_attributes'
gem 'rails4-autocomplete'
gem 'rake'
gem 'rb-readline'
gem 'responders'
gem 'rest-client', '~> 1.8'
gem 'RedCloth'
gem 'rgl', require: 'rgl/adjacency'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ GEM
tilt
ref (2.0.0)
request_store (1.2.0)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
Expand Down Expand Up @@ -480,6 +482,7 @@ DEPENDENCIES
rake
rb-readline
react-rails (~> 1.0)
responders
rest-client (~> 1.8)
rgl
rjb
Expand Down
29 changes: 28 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,31 @@ dateFormat.i18n = {
// For convenience...
Date.prototype.format = function (mask, utc) {
return dateFormat(this, mask, utc);
};
};

function ISODateString(d){
function pad(n){return n<10 ? '0'+n : n}
return d.getUTCFullYear()+'-'
+ pad(d.getUTCMonth()+1)+'-'
+ pad(d.getUTCDate()) +' '
+ pad(d.getUTCHours())+':'
+ pad(d.getUTCMinutes())+':'
+ pad(d.getUTCSeconds())
}

function startTime(map_id, round, link){
startGlobalTimer();
var d = new Date();
var timeoutCount=0;
$.ajax({
type:'POST',
url:'/response_time/record_start_time',
data:$.param({ response_time:{map_id: map_id, round: round, link: link , start: ISODateString(d)}})
})
}






2 changes: 2 additions & 0 deletions app/assets/javascripts/responsetime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/responsetime.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the responsetime controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 2 additions & 0 deletions app/controllers/response_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def edit
@return = params[:return]
@response = Response.find(params[:id])

@current_round = @response.round
@map = @response.map
@contributor = @map.contributor
set_all_responses
Expand Down Expand Up @@ -144,6 +145,7 @@ def new_feedback
# view response
def view
@response = Response.find(params[:id])
@round = @response.round
@map = @response.map
set_content
end
Expand Down
43 changes: 43 additions & 0 deletions app/controllers/response_time_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class ResponseTimeController < ApplicationController
def action_allowed?
true
end
#Three cases :
#1. When user clicks same link within some time interval and end time of previous instance is nil, update this instance's end time with current param's start time
# and again form a new object for new click
#2. start and end time is nil. Means fresh new link
#3. start and end time is not nil. Means fresh new link
def record_start_time
@responsetime_match = ResponseTime.where(map_id: params[:response_time][:map_id], round: params[:response_time][:round], link: params[:response_time][:link])
if @responsetime_match
@responsetime_match.each do |responsetime_entry|
if responsetime_entry.end.nil?
responsetime_entry.update_attribute('end', params[:response_time][:start])
end
end
end #start and end time is nil. Means fresh new link
@responsetime = ResponseTime.new(responsetime_params)
@responsetime.save
render :nothing => true
end

def record_end_time
@data= params.require(:response_time)
@linkArray=Array.new
@responsetime_match = ResponseTime.where(map_id: @data[:map_id], round: @data[:round])
@responsetime_match.each do |responsetime_entry|
if responsetime_entry.end.nil?
@linkArray.push(responsetime_entry.link)
responsetime_entry.update_attribute('end', @data[:end])
end
end
respond_to do|format|
format.json {render json: @linkArray}
end
end


def responsetime_params
params.require(:response_time).permit(:map_id, :round, :link, :start)
end
end
2 changes: 2 additions & 0 deletions app/helpers/response_time_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ResponseTimeHelper
end
14 changes: 14 additions & 0 deletions app/helpers/review_mapping_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ def get_certain_round_review_and_feedback_response_map_for_feedback_report(autho
@rspan = @review_responses.length
end

def get_time_spent_on_review_for_certain_team_for_each_round(map_id)
(1..@assignment.num_review_rounds).each {|round| instance_variable_set("@time_spent_round_" + round.to_s,0) }
(1..@assignment.num_review_rounds).each do |round|
sum_time = 0
@response_times = ResponseTime.where(map_id: map_id, round: round)
@response_times.each do |link_time|
individual_time = (link_time.end - link_time.start)/60
sum_time = individual_time + sum_time
end
if sum_time > 0
instance_variable_set("@time_spent_round_" + round.to_s, sum_time.inspect)
end
end
end
#
# for calibration report
#
Expand Down
2 changes: 2 additions & 0 deletions app/models/response_time.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ResponseTime < ActiveRecord::Base
end
151 changes: 150 additions & 1 deletion app/views/popup/reviewer_details_popup.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,156 @@
<td> <%= @user.handle %></td>
</tr>


</table>

</div>

<% def link_time(map_id, round, link) %>
<% sum_time = 0 %>
<% links = ResponseTime.where(map_id: map_id, round: round, link: link) %>
<% links.each do |link_time| %>
<% if link_time.end.nil? %>
<% individual_time = 0 %>
<% else %>
<% individual_time = (link_time.end - link_time.start)/60 %>
<% end %>
<% sum_time = individual_time + sum_time %>
<% end %>
<% return sum_time %>
<% end %>


<div id="responsetime">
<% reviewee_list = Array.new %>
<% total_time_list = Array.new %>
<% timeHash = Hash.new %>
<h3> Response time details</h3>
<a id = "details" class= "show" onclick="showDetails()">show details</a>
<div id="chartContainer" style="height: 200px; width: 100%; display: none; "></div>
<div>
<table width="100%">
<tr>
<th align="right">Reviewee id </th>
<th align="right">Total Time (mins)</th>
<th align="right">Round </th>
<th align="right">Links</th>
<th align="right">Time per link (mins)</th>
<th></th>
</tr>
<% @reviewers = Participant.where(user_id: @user.id) %>
<% @reviewers.each do |reviewer| %> <!-- for reviewer-->
<% @response_maps = ResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: @id) %>
<% @number_of_rounds = Assignment.find(@id).rounds_of_reviews %>
<% reviewee_count = 0 %>
<% @response_maps.each do |map| %> <!-- for reviewee-->
<% map_total_time = 0 %>
<% (1..@number_of_rounds).each do |each_round| %> <!-- for rounds-->
<% @per_round_time = Array.new %>
<% @responsetime_match = ResponseTime.where(map_id: map.id, round:each_round)%>
<% @reviewed_object_id = map.reviewed_object_id %>
<% @reviewee_id = map.reviewee_id %>

<% link_list = Array.new %>
<% @count = 0 %> <!--- To print revieweeId only once-->
<% @dummy = " " %> <!---Empty string as a placeholder-->
<% @responsetime_match.each do |responsetime_entry| %>
<% if link_list.include?(responsetime_entry.link) %><!-- only unique links per round-->
<% else %>
<% link_list.push(responsetime_entry.link) %>
<tr>
<% if @count == 0 %> <!--- print revieweeId,time, round only for the first row-->
<td><%= @reviewee_id %></td>
<td id="<%=reviewee_count.to_s %>"></td>
<td><%= responsetime_entry.round %></td>
<% else %> <!--- Else print dummy-->
<td><%= @dummy %></td>
<td><%= @dummy %></td>
<td><%= " "%></td>
<%end%>
<td><%= responsetime_entry.link %></td>
<% individual_link_time = link_time(responsetime_entry.map_id,responsetime_entry.round,responsetime_entry.link) %>
<% map_total_time = map_total_time + individual_link_time %>
<% each_link_detail = Array.new %>
<% each_link_detail << responsetime_entry.link %>
<% each_link_detail << individual_link_time %>
<% @per_round_time << each_link_detail %>
<td align="center"><%= sprintf("%.2f",individual_link_time) %></td>
<% if @count == 0 %>
<td><a onclick="drawChart(<%= @reviewee_id.to_s %>,<%= each_round.to_s %>)">Alternate view </a></td>
<% else %>
<td><%= " "%></td>
<%end%>
</tr>
<% end %>
<% @count=@count+1 %>
<%end %> <!-- end for link-->
<% timeHash[(@reviewee_id.to_s).concat(each_round.to_s)] = @per_round_time %>
<% end%> <!-- end for round-->
<% reviewee_list << @reviewee_id %>
<% total_time_list << map_total_time.round(2) %>
<% reviewee_count = reviewee_count+1%>
<% end %> <!-- end for reviewee-->
<% end %> <!-- end for reviewer-->
</table>
</div>

<!--- Script to update the total time column after the page load-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/canvasjs/1.7.0/canvasjs.js"> </script> <!-- Canvas JS CDN -->
<script type="text/javascript">
var timeReportHash;
var showDetailsEnabled = false;
window.onload = function () {

timeReportHash = <%= timeHash.to_json.to_s.html_safe %>;
totalTimeList = <%= total_time_list%>
for(each=0;each<totalTimeList.length;each++){
var eachId=each.toString();
document.getElementById(eachId).innerHTML=totalTimeList[each];
}

}
function showDetails(){
if(showDetailsEnabled){
$( "#chartContainer" ).toggle();
if($("#details").text()=="show details"){
$("#details").text('hide details');
}
else{
$("#details").text('show details');
}
}
}
function drawChart(reviewee_id,round){
showDetailsEnabled=true; //To enable the show details link
if($("#chartContainer").css("display")== 'none'){
$( "#chartContainer" ).toggle();
$("#details").text('hide details');
}
var allLinks = timeReportHash[(reviewee_id.toString()).concat(round.toString())];
var dataArray=[]; //Data to be passed to chart
for(i=0;i<allLinks.length;i++){
var dataPoint={}
dataPoint["y"] = allLinks[i][1];
dataPoint["indexLabel"] = allLinks[i][0];
dataArray.push(dataPoint);
}

var chart = new CanvasJS.Chart("chartContainer",
{
data: [
{
type: "pie",
showInLegend: false,
legendText: "{indexLabel}",
dataPoints : dataArray
}
]
});
chart.render();
$(".canvasjs-chart-credit").css("display","none");//To remove the water mark from the chart


}
</script>

</div>
6 changes: 3 additions & 3 deletions app/views/response/response.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ jQuery(document).ready(function() {
<% if !topic_id.nil? %>
<h2>You are reviewing <%= SignUpTopic.find(topic_id).topic_name %></h2>
<% end %>

<% @response_check = true %>
<%if @assignment.has_teams?%>
<% topic_id = SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id) %>
<%= render :partial => 'submitted_content/main', :locals => {:reviewee_participant => @contributor.participants.first,:participant => @contributor.participants.first, :stage => @assignment.get_current_stage(topic_id)} %>
<%= render :partial => 'submitted_content/main', :locals => {:reviewee_participant => @contributor.participants.first,:participant => @contributor.participants.first, :stage => @assignment.get_current_stage(topic_id), :map_id => @map.id, :round => @current_round, :response_check => @response_check} %>
<%else%>
<% topic_id = SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id) %>
<%= render :partial => 'submitted_content/main', :locals => {:participant => @contributor, :stage => @assignment.get_current_stage(topic_id)} %>
<%= render :partial => 'submitted_content/main', :locals => {:participant => @contributor, :stage => @assignment.get_current_stage(topic_id), :map_id => @map.id, :round => @current_round, :response_check => @response_check} %>
<%end%>
<hr/>
<% end %>
Expand Down
7 changes: 5 additions & 2 deletions app/views/response/view.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<h1><%= @title %> for <%= @assignment.name %></h1>
<% @response_check = true %>
<% if !(@map.instance_of? TeammateReviewResponseMap) %>
<% topic_id = SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id) %>
<%= render :partial => 'submitted_content/main', :locals => {:participant => @contributor.participants.first, :stage => @assignment.get_current_stage(topic_id)} %>
<% @response_check = true %>
<%= render :partial => 'submitted_content/main', :locals => {:map_id => @map.id, :round => @round, :response_check => @response_check, :participant => @contributor.participants.first, :stage => @assignment.get_current_stage(topic_id)} %>
<% end %>
<% @review_versions = @map.get_all_versions() %>
<% if !@review_versions.empty? %>
Expand All @@ -12,6 +14,7 @@
<hr/>
<% end %>


<% file_url = nil %>
<%= @response.display_as_html(nil, nil, file_url) %>
<br/>
Expand All @@ -33,4 +36,4 @@

<%= @map.show_feedback(@response) %>
<br/>
<a href="javascript:window.history.back()">Back</a>
<a href="javascript:window.history.back()">Back</a>
2 changes: 2 additions & 0 deletions app/views/response_time/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%h1 ResponseTime#new
%p Find me in app/views/response_time/new.html.haml
8 changes: 5 additions & 3 deletions app/views/review_mapping/_review_report.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<thead>
<tr bgcolor='#CCCCCC'>
<!-- class value decides whether the column should be sortable or not -->
<th width = "16%" class="sorter-true">Reviewer <span></span></th>
<th width = "14%" class="sorter-false">Reviews done per round<span></span></th>
<th width = "20%" class="sorter-false">Team reviewed <span></span></th>
<th width = "13%" class="sorter-true">Reviewer <span></span></th>
<th width = "13%" class="sorter-false">Reviews done per round<span></span></th>
<th width = "14%" class="sorter-false">Team reviewed <span></span></th>
<th width = "10%" class="sorter-false">Time per review in mins <span></span></th>
<th width = "14%" class="sorter-false">Score awarded / Avg. score <span></span></th>
<th width = "10%" class="sorter-true">Metrics <span></span></th>
<th width = "36%" class="sorter-false">Assign grade and write comments <span></span></th>
Expand Down Expand Up @@ -48,6 +49,7 @@
<!--later we can create a hyperlink question type to deal with this situation.-->
<%= list_hyperlink_submission(r.id, ri.id, 5386) if @id.to_i == 806 %>
</td>
<%= render partial: 'review_submissions_time_spent', locals: {bgcolor: @bgcolor, map_id: ri.id} %>
<%= render partial: 'team_score', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: r.id} %>
<% if index == 0 %>
<!--Metrics-->
Expand Down
11 changes: 11 additions & 0 deletions app/views/review_mapping/_review_submissions_time_spent.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% get_time_spent_on_review_for_certain_team_for_each_round(map_id) %>
<td bgcolor=<%= bgcolor %> align='left' >
<% (1..@assignment.num_review_rounds).each do |round| %>
<% if ((instance_variable_get("@time_spent_round_" + round.to_s)).to_f) > 0 %>
<%= sprintf("%.2f",instance_variable_get("@time_spent_round_" + round.to_s)) %>
<% else %>
---
<% end %>
<%= ', ' unless round == @assignment.num_review_rounds %>
<%end%>
</td>