Skip to content

Commit

Permalink
Remove helping hints Issue #211
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Fadel authored and Mohamed Fadel committed Apr 22, 2014
1 parent 41cb87c commit 0cecad7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tutor/app/controllers/hints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def new
@answer = ModelAnswer.find(params[:model_answer_id])
@@answer_id = params[:model_answer_id]
end

# [Adding Helping Hints - 4.12]
# Creates a new record to Hint Table
# Parameters:
Expand Down Expand Up @@ -58,4 +58,21 @@ def create
# Author: Mohamed Fadel
def permitCreate
params.require(:Hint).permit(:submission_counter, :message)
end
end

# [Delete a Hint - Story 4.21]
# This action takes the hint id, remove it from the database
# and then redirects the user to the edit page accompanied
# with a "Hint deleted" message.
# Parameters:
# params[:id]: The current hint's id
# Returns:
# none
# Author: Mohamed Fadel
def destroy
hint = Hint.find_by_id(params[:id])
hint.destroy
flash[:success_deletion] = "Hint deleted."
redirect_to :controller => 'model_answers', :action => 'edit', :id => @@answer_id
end
end
7 changes: 7 additions & 0 deletions tutor/app/views/hints/_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--Add delete button to the edit view in model answers
Author: Mohamed Fadel-->

<th style = "width:20%">Delete</th>

<td><%= button_to "Delete", {controller: :hints, action: :destroy, id: hint1.id},
:method => :delete, class: 'btn btn-primary btn-xs' %></td>

0 comments on commit 0cecad7

Please sign in to comment.