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

Remove comments. #87

Merged
merged 1 commit into from
Oct 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/controllers/concepts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,15 @@ def modify_level

progress = ConceptProgress.where(concept_id: @concept.id,
enrollment_id: enrollment.id).first

comment = Comment.create(content: params[:comment],
commenter_name: current_student.full_name)

elsif teacher_signed_in?

enrollment = Enrollment.where(student_id: params[:student_id],
course_id: @concept.unit.course.id).first

progress = ConceptProgress.where(concept_id: @concept.id,
enrollment_id: enrollment.id).first

comment = Comment.create(content: params[:comment],
commenter_name: current_teacher.full_name)
end

progress.add_comment(comment)
progress.change_level(params[:level])

redirect_to @concept if progress.save
Expand Down
7 changes: 0 additions & 7 deletions app/models/comment.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/models/concept_progress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class ConceptProgress < ActiveRecord::Base

belongs_to :enrollment
belongs_to :concept
has_many :comments

validates_presence_of :level, :type_of_error, :next_steps

Expand All @@ -21,8 +20,4 @@ def init
def change_level(lev)
self.level = lev
end

def add_comment(com)
self.comments << com
end
end
25 changes: 4 additions & 21 deletions app/views/concepts/_modify_level_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<%= form_tag concepts_modify_level_path, id:"levelForm", method: 'post' do %>
<fieldset>
<div class="form-group">
<%= label_tag :comment %>
<%= text_area_tag :comment, nil,
size: "50x5",
class: "form-control" %><br>
<span class="hide help-block">You must leave a comment.</span><br>
<%= label_tag :level %>
<%= select_tag :level,
options_for_select([1,2,3,4]),
Expand All @@ -14,20 +9,8 @@
<%= hidden_field_tag 'student_id', params[:student_id]%>
</div>
<%= button_tag "Change Level",
id:"levelButton",
class:"btn btn-default",
"data-dismiss" => "modal" %>
id:"levelButton",
class:"btn btn-default",
"data-dismiss" => "modal" %>
</fieldset>
<%end%>

<script>
$('#levelButton').click(function() {

if($('#comment').val() == "" ){
$('.help-block').attr('class', 'help-block')
return false;
}else{
$('#levelForm').submit();
}
});
</script>
<% end %>
2 changes: 0 additions & 2 deletions app/views/concepts/_student.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<table class="table">
<thead>
<th>Level</th>
<th>Comment</th>
<th>Commented By</th>
</thead>
<%= render 'student_progress' %>
<table>
8 changes: 0 additions & 8 deletions app/views/concepts/_student_progress.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
<% new_progress %>
<% else %>
<td><%= current_student.current_progress(@concept.unit.course).level%></td>
<td>
<%= current_student.current_progress(@concept.unit.course).comments.last.content if !current_student.current_progress(@concept.unit.course).comments.last.nil? %>
</td>
<td>
<%= current_student.current_progress(@concept.unit.course).
comments.last.commenter_name if !current_student.current_progress(
@concept.unit.course).comments.last.nil? %>
</td>
<% end %>
<td>
<%= link_to "Edit Concept", '#levelModal',
Expand Down
6 changes: 0 additions & 6 deletions app/views/concepts/_teacher.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
<thead>
<th>Student</th>
<th>Level</th>
<th>Latest Comment</th>
<th>Commented By</th>
</thead>
<% if @concept.unit.course.enrollments.empty? %>

<div class="no-courses text-center">
There are currently no students enrolled.
</div>

<% else %>

<%= render 'teacher_progress' %>

<% end %>
</table>
34 changes: 13 additions & 21 deletions app/views/concepts/_teacher_progress.html.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
<% @concept.unit.course.enrollments.each do |e| %>
<% e.concept_progresses.each do |p| %>
<tr id=<%= e.student.id %> >
<td><%= e.student.full_name %></td>
<td><%= p.level %></td>
<td>
<%= p.comments.last.content if !p.comments.last.nil?%>
</td>
<td>
<%= p.comments.last.commenter_name if !p.comments.last.nil? %>
</td>
<td>
<%= link_to "Edit", '#levelModal',
:class => "btn btn-primary btn-sm changebutton",
:data => { :toggle => "modal" },
:id => e.student.id %>

<% end %>
</td>
</tr>
<tr id=<%= e.student.id %> >
<td><%= e.student.full_name %></td>
<td><%= p.level %></td>
<td>
<%= link_to "Edit", '#levelModal',
:class => "btn btn-primary btn-sm changebutton",
:data => { :toggle => "modal" },
:id => e.student.id %>
</td>
</tr>
<% end %>

<% end %>

<script>
$('a.changebutton').on("click", function(e) {
$('a.changebutton').on("click", function(e) {
$('#student_id').val(e.target.id)
})
})
</script>
5 changes: 5 additions & 0 deletions db/migrate/20131011034751_remove_comments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveComments < ActiveRecord::Migration
def change
drop_table :comments
end
end
12 changes: 1 addition & 11 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20131008095946) do

create_table "comments", force: true do |t|
t.string "content"
t.string "commenter_name"
t.integer "concept_progress_id"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "comments", ["created_at"], name: "index_comments_on_created_at"
ActiveRecord::Schema.define(version: 20131011034751) do

create_table "concept_progresses", force: true do |t|
t.datetime "created_at"
Expand Down
5 changes: 0 additions & 5 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,5 @@
enrollment_id 1
level 1
end

factory :comment do
content "This is why I modified my LT"
commenter_name "Person Name"
end
end

21 changes: 0 additions & 21 deletions spec/features/concept_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,6 @@
end

it { should have_content @student.full_name }

it "should not allow level changes without a comment" do
click_link "Edit"

select "2", from: "level"

click_link "Edit"

page.should have_css('div.fade') #modal form should remain active
page.should have_content("You must leave a comment.")
end

it "should allow level changes with a comment" do
click_link "Edit"
fill_in "Comment", with: "This is why I changed the level."
select "2", from: "level"

click_link "Edit"

page.should have_content("This is why I changed the level.")
end
end
end

Expand Down
23 changes: 0 additions & 23 deletions spec/models/comment_spec.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/models/concept_progress_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
it { should belong_to :enrollment }
it { should belong_to :concept}

it { should have_many :comments }

it { should respond_to :enrollment_id }
it { should respond_to :concept_id }

Expand Down