Skip to content

Commit

Permalink
Merge cebdfcd into 40716c3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry Shijie Li committed Dec 6, 2017
2 parents 40716c3 + cebdfcd commit e05a890
Show file tree
Hide file tree
Showing 31 changed files with 1,298 additions and 33 deletions.
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,3 @@ DEPENDENCIES
uglifier
will_paginate
zip-zip

BUNDLED WITH
1.11.2
2 changes: 2 additions & 0 deletions app/assets/javascripts/submission_viewing_events.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.
73 changes: 73 additions & 0 deletions app/assets/stylesheets/scaffolds.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}

p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}

pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}

a {
color: #000;

&:visited {
color: #666;
}

&:hover {
color: #fff;
background-color: #000;
}
}

div {
&.field, &.actions {
margin-bottom: 10px;
}
}

#notice {
color: green;
}

.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;

h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}

ul li {
font-size: 12px;
list-style: square;
}
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/submission_viewing_events.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the submission_viewing_events 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 @@ -53,6 +53,7 @@ def edit
@next_action = "update"
@return = params[:return]
@response = Response.find(params[:id])
@current_round = @response.round
@map = @response.map
@contributor = @map.contributor
set_all_responses
Expand All @@ -75,6 +76,7 @@ def update
return unless action_allowed?
# the response to be updated
@response = Response.find(params[:id])
@current_round = @response.round
msg = ""
begin
@map = @response.map
Expand Down
64 changes: 64 additions & 0 deletions app/controllers/submission_viewing_events_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
class SubmissionViewingEventsController < ApplicationController
def action_allowed?
true
end

# record time when link or file is opened in new window
def record_start_time
map_id = params[:submission_viewing_event][:map_id]
round = params[:submission_viewing_event][:round]
link = params[:submission_viewing_event][:link]
start_at = params[:submission_viewing_event][:start_at]
# check if this link is already opened and timed
@submission_viewing_event_records = SubmissionViewingEvent.where(map_id: map_id, round: round, link: link)
# if opened, end these records with current time
if @submission_viewing_event_records
@submission_viewing_event_records.each do |time_record|
if time_record.end_at.nil?
time_record.update_attribute('end_at', start_at)
end
end
end
# create new response time record for current link
@submission_viewing_event = SubmissionViewingEvent.new(submission_viewing_event_params)
@submission_viewing_event.save
render :nothing => true
end

# record time when link or file window is closed
def record_end_time
@data = params.require(:submission_viewing_event)
@submission_viewing_event_records = SubmissionViewingEvent.where(map_id: @data[:map_id], round: @data[:round], link: @data[:link])
@submission_viewing_event_records.each do |time_record|
if time_record.end_at.nil?
time_record.update_attribute('end_at', @data[:end_at])
break
end
end
respond_to do |format|
format.json {head :no_content}
end
end

# mark end_at review time for all uncommited links/files
def mark_end_time
@data= params.require(:submission_viewing_event)
@linkArray=Array.new
@submissionviewingevent_matches = SubmissionViewingEvent.where(map_id: @data[:map_id], round: @data[:round])
@submissionviewingevent_matches.each do |submissionviewingevent_entry|
if submissionviewingevent_entry.end_at.nil?
@linkArray.push(submissionviewingevent_entry.link)
submissionviewingevent_entry.update_attribute('end_at', @data[:end_at])
end
end
respond_to do|format|
format.json {render json: @linkArray}
end
end

private
# Only allow a trusted parameter "white list" through.
def submission_viewing_event_params
params.require(:submission_viewing_event).permit(:map_id, :round, :link, :start_at, :end_at)
end
end
24 changes: 24 additions & 0 deletions app/helpers/review_mapping_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,30 @@ 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
@submission_viewing_events = SubmissionViewingEvent.where(map_id: map_id, round: round)
@submission_viewing_events.each do |link_time|
#start_time = link_time.start_at.nil?? 0: link_time.start_at
#end_time = link_time.end_at.nil?? 0: link_time.end_at
if link_time.start_at.nil? || link_time.end_at.nil?
individual_time = 0
else
start_time = link_time.start_at
end_time = link_time.end_at
individual_time = (end_time.to_i - start_time.to_i)/60.0
end
individual_time = individual_time<0? 0: individual_time
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/helpers/submission_viewing_events_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SubmissionViewingEventsHelper
end
8 changes: 2 additions & 6 deletions app/helpers/submitted_content_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ def display_directory_tree(participant, files, display_to_reviewer_flag)
ret += "\n <input type=hidden id='filenames_#{index}' name='filenames[#{index}]' value='#{File.basename(file)}'>"
ret += "\n <input type=hidden id='directories_#{index}' name='directories[#{index}]' value='#{File.dirname(file)}'>"

if File.exist?(file) && File.directory?(file)
if (File.exist?(file) && File.directory?(file))
ret += link_to File.basename(file), :controller => 'submitted_content', :action => 'edit', :id => participant.id, "current_folder[name]" => file
else
ret += "\n "
ret += link_to File.basename(file), :controller => 'submitted_content',
:action => 'download',
:id => participant.id,
:download => File.basename(file),
"current_folder[name]" => File.dirname(file)
ret += link_to File.basename(file), {:controller => 'submitted_content', :action => 'download',:id => participant.id, :download => File.basename(file), "current_folder[name]" => File.dirname(file)}, :class => "fileLink", :download => File.basename(file).to_s
end
ret += "\n </td>\n <td valign = top>\n"
ret += File.size(file).to_s
Expand Down
2 changes: 2 additions & 0 deletions app/models/submission_viewing_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class SubmissionViewingEvent < ActiveRecord::Base
end

0 comments on commit e05a890

Please sign in to comment.