Skip to content

Commit

Permalink
Fixing conflicts #210
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Fadel authored and Mohamed Fadel committed Apr 25, 2014
1 parent 52dfbd1 commit 928ad57
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions tutor/app/controllers/hints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,48 @@ def edit
end
end

# [Edit helping hints - Story 4.13 ]
# This action takes the passed parameters from
# the creation form, edits a Hint record
# which assigned to the respective problem. If the
# edit fails the user is redirected to the form
# with a "Failed" message.
# Parameters:
# hint_params[]: A list that has all fields entered by the user to in the
# edit_hint form
# Returns:
# flash[:notice]: A message indicating the success or failure of the edit
# Author: Mimi
def update
@new_tip = Hint.find_by_id(hint_params[:id])
@new_tip.message = hint_params[:message]
@new_tip.submission_counter = hint_params[:submission_counter]
@model_answer = @new_tip.model_answer_id
bool = @new_tip.save
if bool == true
flash[:notice] = "Hint successfully edited"
redirect_to :controller => 'model_answers', :action => 'edit', :id => @model_answer
else
if @new_tip.errors.any?
flash[:notice] = @new_tip.errors.full_messages.first
end
redirect_to :back
end
end

# [Edit helping hints - Story 4.13 ]
# Description:
# take the parameters from the from
# Parameters: none
# Returns:
# Hash of paramas
# Author: Mimi
private
def hint_params
params.require(:hint).permit(:message, :submission_counter, :id)
end
end

# [Adding Helping Hints - 4.12]
# Creates a new record to Hint Table
# Parameters:
Expand Down Expand Up @@ -74,7 +116,4 @@ def permitCreate
params.require(:Hint).permit(:submission_counter, :message)

end
def hint_params
params.require(:hint).permit(:message, :submission_counter, :id)
end
end
end

0 comments on commit 928ad57

Please sign in to comment.