diff --git a/tutor/app/controllers/hints_controller.rb b/tutor/app/controllers/hints_controller.rb index 52284707..bd7bcf27 100644 --- a/tutor/app/controllers/hints_controller.rb +++ b/tutor/app/controllers/hints_controller.rb @@ -41,6 +41,6 @@ def create private def permitCreate params.require(:Hint).permit(:submission_counter, :message) - + end end \ No newline at end of file diff --git a/tutor/app/models/hint.rb b/tutor/app/models/hint.rb index 660b3fb9..7517bede 100644 --- a/tutor/app/models/hint.rb +++ b/tutor/app/models/hint.rb @@ -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 diff --git a/tutor/app/views/hints/edit.html.erb b/tutor/app/views/hints/edit.html.erb new file mode 100644 index 00000000..e199c630 --- /dev/null +++ b/tutor/app/views/hints/edit.html.erb @@ -0,0 +1,23 @@ +<% if flash[:notice] -%> +
+ <%= f.label "Hint description" %>
+ <%= f.text_area :message, :cols => "100", :rows => "8", autofocus:true, class:"form-control", style:"width:300px", value:Hint.find_by_id(params[:id]).message %>
+
+ <%= f.label :"The number of wrong submissions that hint appears after" %>
+ <%= f.text_area :submission_counter, :rows => "1", class:"form-control", style: "width:300px", value:Hint.find_by_id(params[:id]).submission_counter %>
+
+ <%= f.submit"Save", class:"btn btn-success"%> +
+<% end %> \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index 850c73fc..6a17fad8 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -39,6 +39,7 @@ resources :model_answers resources :solutions resources :topics + resources :hints resources :lecturers resources :teaching_assistants resources :students