Permalink
Browse files

Renamed transcription model/controller to reduce length.

  • Loading branch information...
1 parent 99b6b37 commit f51b5e99aca5b1003070757fad11d62e764acfb2 @aantix committed Jan 13, 2012
Showing with 270 additions and 151 deletions.
  1. +3 −1 Gemfile
  2. +8 −10 Gemfile.lock
  3. +4 −1 README.rdoc
  4. +29 −24 app/controllers/{transcriptions_controller.rb → trans_controller.rb}
  5. +15 −0 app/models/tran.rb
  6. +8 −0 app/models/tran_seg.rb
  7. +0 −12 app/models/transcription.rb
  8. +0 −4 app/models/transcription_segment.rb
  9. +22 −0 app/models/video_segment.rb
  10. +4 −2 app/views/candidates/_candidate.html.erb
  11. +10 −0 app/views/trans/_accept_hit.html.erb
  12. +12 −0 app/views/trans/_errors.html.erb
  13. +9 −50 app/views/{transcriptions → trans}/_form.html.erb
  14. +19 −0 app/views/trans/_instructions.html.erb
  15. +1 −1 app/views/{transcriptions → trans}/_video.html.erb
  16. 0 app/views/{transcriptions → trans}/edit.html.erb
  17. +1 −1 app/views/{transcriptions → trans}/index.html.erb
  18. 0 app/views/{transcriptions → trans}/new.html.erb
  19. 0 app/views/{transcriptions → trans}/show.html.erb
  20. +1 −1 config/environments/production.rb
  21. +10 −0 config/initializers/turkee.rb
  22. +2 −2 config/routes.rb
  23. +24 −0 db/migrate/20120109094416_create_turkee_tasks.rb
  24. +16 −0 db/migrate/20120109094417_create_turkee_imported_assignments.rb
  25. +5 −0 db/migrate/20120109204159_add_turkee_task_id_to_video_segment.rb
  26. +26 −1 db/schema.rb
  27. +29 −29 spec/controllers/{transcriptions_controller_spec.rb → trans_controller_spec.rb}
  28. +1 −1 spec/models/transcription_segment_spec.rb
  29. +1 −1 spec/models/transcription_spec.rb
  30. +2 −2 spec/requests/transcriptions_spec.rb
  31. +8 −8 spec/routing/transcriptions_routing_spec.rb
View
@@ -7,7 +7,9 @@ gem 'rails', '3.1.3'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
-gem 'turkee', :git => 'git://github.com/aantix/turkee.git', :branch => 'turkee_rails31'
+#gem 'turkee', :git => 'git://github.com/aantix/turkee.git'
+gem 'turkee', :path => "/Users/jjones/Projects/turkee"
+
gem 'youtube_search'
gem 'nested_form', :git => "git@github.com:aantix/nested_form.git"
View
@@ -1,14 +1,4 @@
GIT
- remote: git://github.com/aantix/turkee.git
- revision: 2a2022784832da40dc309a48dd722a461b142646
- branch: turkee_rails31
- specs:
- turkee (1.1.1)
- lockfile
- rails (>= 3.1.1)
- rturk (>= 2.3.0)
-
-GIT
remote: git@github.com:aantix/nested_form.git
revision: cf722a8a20db881c8c81176cfcc8e3a1edbe6142
specs:
@@ -24,6 +14,14 @@ GIT
less-rails (~> 2.1.0)
railties
+PATH
+ remote: /Users/jjones/Projects/turkee
+ specs:
+ turkee (1.1.1)
+ lockfile
+ rails (>= 3.1.1)
+ rturk (>= 2.3.0)
+
GEM
remote: http://rubygems.org/
specs:
View
@@ -24,7 +24,10 @@ There you will see the form that is presented to the Turkers. That is all I hav
== Requesting Work from the Turkers
-rake turkee:post_hit["https://www.yourapp.com","Please complete our survey","Tell us your favorite color.","Survey",100,0.05,2]
+title = "I'm in need YOUR Help! Transcribe presidential campaign speeches for the hearing impaired."
+description = "I have a lot of campaign speeches that I would like to transcribe. For this 60 segment, type in exactly what each candidate says."
+VideoSegment.reset_turk_tasks
+VideoSegment.create_turk_tasks(title,description,2,0.03,2)
== Copyright
@@ -1,19 +1,19 @@
-class TranscriptionsController < ApplicationController
- # GET /transcriptions
- # GET /transcriptions.json
+class TransController < ApplicationController
+ # GET /trans
+ # GET /trans.json
def index
- @transcriptions = Transcription.all
+ @transcriptions = Tran.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @transcriptions }
end
end
- # GET /transcriptions/1
- # GET /transcriptions/1.json
+ # GET /trans/1
+ # GET /trans/1.json
def show
- @transcription = Transcription.find(params[:id])
+ @transcription = Tran.find(params[:id])
respond_to do |format|
format.html # show.html.erb
@@ -22,28 +22,33 @@ def show
end
def new
- @transcription = Transcription.new
- @categories = Category.select_items
- @candidates = Candidate.all_sorted
+ @assignment_id = params[:assignmentId]
+ @disabled = Turkee::TurkeeFormHelper::disable_form_fields?(@assignment_id)
+
+ @transcription = Tran.new
+ @transcription.tran_segs.build
+
+ @categories = Category.select_items
+ @candidates = []
@transcription.video_segment = VideoSegment.find(params[:video_segment_id]) rescue nil
raise "Must provide a video segment id" if @transcription.video_segment_id.nil?
end
- # GET /transcriptions/1/edit
+ # GET /trans/1/edit
def edit
- @transcription = Transcription.find(params[:id])
+ @transcription = Tran.find(params[:id])
end
- # POST /transcriptions
- # POST /transcriptions.json
+ # POST /trans
+ # POST /trans.json
def create
- @transcription = Transcription.new(params[:transcription])
+ @transcription = Tran.new(params[:transcription])
respond_to do |format|
if @transcription.save
- format.html { redirect_to @transcription, notice: 'Transcription was successfully created.' }
+ format.html { redirect_to @transcription, notice: 'Tran was successfully created.' }
format.json { render json: @transcription, status: :created, location: @transcription }
else
format.html { render action: "new" }
@@ -52,14 +57,14 @@ def create
end
end
- # PUT /transcriptions/1
- # PUT /transcriptions/1.json
+ # PUT /trans/1
+ # PUT /trans/1.json
def update
- @transcription = Transcription.find(params[:id])
+ @transcription = Tran.find(params[:id])
respond_to do |format|
if @transcription.update_attributes(params[:transcription])
- format.html { redirect_to @transcription, notice: 'Transcription was successfully updated.' }
+ format.html { redirect_to @transcription, notice: 'Tran was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
@@ -68,14 +73,14 @@ def update
end
end
- # DELETE /transcriptions/1
- # DELETE /transcriptions/1.json
+ # DELETE /trans/1
+ # DELETE /trans/1.json
def destroy
- @transcription = Transcription.find(params[:id])
+ @transcription = Tran.find(params[:id])
@transcription.destroy
respond_to do |format|
- format.html { redirect_to transcriptions_url }
+ format.html { redirect_to trans_url }
format.json { head :ok }
end
end
View
@@ -0,0 +1,15 @@
+# Represents a transcription for a given video segment.
+# Shortened from Transcription to Tran to get in under the Mechanical field input name limit.
+class Tran < ActiveRecord::Base
+ set_table_name "transcriptions"
+
+ belongs_to :video_segment
+
+ has_many :tran_segs, :foreign_key => "transcription_id"
+ accepts_nested_attributes_for :tran_segs
+
+ def candidate
+ video_segment.video.candidate
+ end
+
+end
@@ -0,0 +1,8 @@
+# TranscriptionSegment
+# Shortened from TranscriptionSegment to TranSeg to get in under the Mechanical field input name limit.
+class TranSeg < ActiveRecord::Base
+ set_table_name "transcription_segments"
+
+ belongs_to :tran
+ belongs_to :candidate
+end
@@ -1,12 +0,0 @@
-class Transcription < ActiveRecord::Base
- belongs_to :video_segment
-
- has_many :transcription_segments
- accepts_nested_attributes_for :transcription_segments
-
-
- def candidate
- video_segment.video.candidate
- end
-
-end
@@ -1,4 +0,0 @@
-class TranscriptionSegment < ActiveRecord::Base
- belongs_to :transcription
- belongs_to :candidate
-end
@@ -1,6 +1,8 @@
class VideoSegment < ActiveRecord::Base
belongs_to :video
belongs_to :candidate
+
+ scope :unprocessed, :conditions => 'turkee_task_id is NULL'
SEGMENT_LENGTH = 60 # seconds
@@ -28,4 +30,24 @@ def end_of
def self.create_segment(video, offset, duration)
video.video_segments.create(:offset => offset, :duration => duration)
end
+
+ def self.reset_turk_tasks
+ VideoSegment.update_all(:turkee_task_id => nil)
+ end
+
+ def self.create_turk_tasks(title,description,num_assignments,reward,duration)
+ hit_urls = []
+ VideoSegment.unprocessed.each do |video_segment|
+ turk_task = Turkee::TurkeeTask.create_hit(HOST, title, description, :Tran,
+ num_assignments, reward, duration, 70, :video_segment_id => video_segment.id)
+
+ hit_urls << turk_task.hit_url
+
+ video_segment.turkee_task_id = turk_task.id
+ video_segment.save
+ end
+
+ puts "HIT URLs :"
+ puts hit_urls.join("\n")
+ end
end
@@ -1,5 +1,7 @@
-<div class="span4">
- <%= f.radio_button :candidate_id, candidate.id, :checked => (candidate == transcription.candidate) %>
+<div class="span2">
+ <%= f.radio_button :candidate_id,
+ candidate.id,
+ :checked => (candidate == transcription.candidate) %>
<% if candidate.image? %>
<%= image_tag("candidates/#{candidate.image}", :alt => candidate.name, :title => candidate.name) %>
@@ -0,0 +1,10 @@
+<% if @disabled %>
+ <div class="row alert-message block-message error">
+ <div class="span16">
+ <h3>
+ <%= image_tag 'stop_sign.gif' %>
+ &nbsp;&nbsp;Click the <span class="alt">"Accept Hit"</span> button above.
+ </h3>
+ </div>
+ </div>
+<% end %>
@@ -0,0 +1,12 @@
+<% if @transcription.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@transcription.errors.count, "error") %> prohibited this transcription from being
+ saved:</h2>
+
+ <ul>
+ <% @transcription.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+<% end %>
@@ -1,75 +1,34 @@
-<% if @disabled %>
- <div class="row">
- <div class="span16">
- <h3>
- <%= image_tag 'stop_sign.gif' %>
- &nbsp;&nbsp;Click the <span class="alt">"Accept Hit"</span> button above.
- </h3>
- </div>
- </div>
-<% end %>
+<%= render :partial => 'accept_hit' %>
-
-<div class="row alert-message block-message warning">
- <div class="span16">
- <h2>
- Directions:
- </h2>
- <p>
- I need <i>your</i> HELP. Please watch the <%= @transcription.video_segment.duration %> second video segment below.
- </p>
-
- <p>
- For every candidate that speaks, select the <span class='btn large success'>add speaker</span> button, select who is speaking, and transcribe their text.
- </p>
-
- <p>
- I cannot pay much but I plan to provide these transcriptions free to the public. This should be a big help to the
- hearing impaired.
- </p>
-
- </div>
-</div>
+<%= render :partial => 'instructions' %>
<div class="row">
<div class="span16">
<%= turkee_nested_form_for(@transcription, params) do |f| %>
- <%# nested_form_for @transcription do |f| %>
<fieldset>
- <% if @transcription.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@transcription.errors.count, "error") %> prohibited this transcription from being
- saved:</h2>
-
- <ul>
- <% @transcription.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
+ <%= render :partial => 'errors' %>
<%= render :partial => 'video', :locals => {:video_segment => @transcription.video_segment} %>
<div class="alert-message block-message warning">
<%= f.hidden_field :video_segment_id, :value => @transcription.video_segment.id %>
<p>
- <%= f.link_to_add "Add Speaker", :transcription_segments, :class => 'btn large success' %>
+ <%= f.link_to_add "Add Speaker", :tran_segs, :class => 'btn large success', :disabled => @disabled %>
</p>
- <%= f.fields_for :transcription_segments do |segment| %>
+ <%= f.fields_for :tran_segs do |segment| %>
<div class="row">
<div class="clearfix fields">
<%= f.label :candidate_id, "Who's speaking?" %>
<div class="input">
- <% @candidates.in_groups_of(4).each do |candidate_group| %>
+ <% @candidates.in_groups_of(6).each do |group| %>
<div class="row">
- <% candidate_group.each do |c| %>
+ <% group.each do |c| %>
<%= render :partial => 'candidates/candidate',
:object => c,
- :locals => {:f => segment, :transcription => @transcription} %>
+ :locals => {:f => segment, :transcription => @transcription} unless c.nil? %>
<% end %>
</div>
<% end %>
@@ -98,7 +57,7 @@
</div>
<div class="actions">
- <%= f.submit(nil, :class => 'btn large primary') %>
+ <%= f.submit(nil, :class => 'btn large primary', :disabled => @disabled) %>
</div>
</fieldset>
@@ -0,0 +1,19 @@
+<div class="row alert-message block-message warning">
+ <div class="span16">
+ <h2>
+ Directions:
+ </h2>
+ <p>
+ I need <i>your</i> HELP. Please watch the <%= @transcription.video_segment.duration %> second video segment below.
+ </p>
+
+ <p>
+ For every candidate that speaks, click the <span class='btn large success'>Add Speaker</span> button, select who is speaking, and transcribe their text.
+ </p>
+
+ <p>
+ I cannot pay much, but rest assured, your transcribed text will be provided for free for the public's use and to better inform the hearing impaired community for the upcoming elections.
+ </p>
+
+ </div>
+</div>
@@ -8,7 +8,7 @@
var end = <%= video_segment.end_of %>;
var splice = true;
var played = false;
- var url = "http://www.youtube.com/v/" + id + "&start=" + start + "&end=" + end + "&autoplay=1&enablejsapi=1";
+ var url = "http://www.youtube.com/v/" + id + "&start=" + start + "&end=" + end + "&autoplay=0&enablejsapi=1";
swfobject.embedSWF(url, "player", "640", "350", "8", null, null, { allowScriptAccess: "always" }, { id: "video" });
Oops, something went wrong.

0 comments on commit f51b5e9

Please sign in to comment.