Skip to content

Commit

Permalink
issue alaashafaee#210 Fixing internal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Fadel authored and Mohamed Fadel committed Apr 25, 2014
2 parents 4795393 + 3aa3f58 commit 84905f4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tutor/app/controllers/hints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ def create
private
def permitCreate
params.require(:Hint).permit(:submission_counter, :message)

end
end
10 changes: 4 additions & 6 deletions tutor/app/models/hint.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
class Hint < ActiveRecord::Base

#Validations
validates :message, presence: true
validates :submission_counter, presence: true, numericality: {
only_integer: true, greater_than_or_equal_to: 0, message: "is not valid"}

#Relations
belongs_to :model_answer
belongs_to :owner, polymorphic: true

#Scoops

#Methods

end
23 changes: 23 additions & 0 deletions tutor/app/views/hints/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<% if flash[:notice] -%>
<div class="alert alert-warning", style="width:180px;display:inline">
<%= flash[:notice] %>
</div>
<% end %>
<br/>
<br/>
<br/>
<!-- Rendering the form fields -->
<%= form_for @new_tip, url:{:controller => "hints", action:"update"} do |f| %>
<%= f.hidden_field :id, value: params[:id] %>
<p>
<%= f.label "Hint description" %><br>
<%= f.text_area :message, :cols => "100", :rows => "8", autofocus:true, class:"form-control", style:"width:300px", value:Hint.find_by_id(params[:id]).message %>
</p>
<p>
<%= f.label :"The number of wrong submissions that hint appears after" %><br>
<%= f.text_area :submission_counter, :rows => "1", class:"form-control", style: "width:300px", value:Hint.find_by_id(params[:id]).submission_counter %>
</p>
<p>
<%= f.submit"Save", class:"btn btn-success"%>
</p>
<% end %>
1 change: 1 addition & 0 deletions tutor/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
resources :model_answers
resources :solutions
resources :topics
resources :hints
resources :lecturers
resources :teaching_assistants
resources :students
Expand Down

0 comments on commit 84905f4

Please sign in to comment.