save progress. added user feedback view and stuff
This commit is contained in:
42
app/controllers/user_exercise_feedbacks_controller.rb
Normal file
42
app/controllers/user_exercise_feedbacks_controller.rb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
class UserExerciseFeedbackController < ApplicationController
|
||||||
|
include CommonBehavior
|
||||||
|
|
||||||
|
def authorize!
|
||||||
|
authorize(@uef)
|
||||||
|
end
|
||||||
|
private :authorize!
|
||||||
|
|
||||||
|
def create
|
||||||
|
@tag = Tag.new(tag_params)
|
||||||
|
authorize!
|
||||||
|
create_and_respond(object: @tag)
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
destroy_and_respond(object: @tag)
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
def uef_params
|
||||||
|
params[:tag].permit(:feedback_text, :difficulty)
|
||||||
|
end
|
||||||
|
private :uef_params
|
||||||
|
|
||||||
|
def new
|
||||||
|
@uef = UserExerciseFeedback.new
|
||||||
|
authorize!
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
update_and_respond(object: @UserExerciseFeedback, params: uef_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
name
|
||||||
|
end
|
||||||
|
end
|
34
app/policies/user_exercise_feedback_policy.rb
Normal file
34
app/policies/user_exercise_feedback_policy.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
class TagPolicy < AdminOrAuthorPolicy
|
||||||
|
def author?
|
||||||
|
@user == @record.author
|
||||||
|
end
|
||||||
|
private :author?
|
||||||
|
|
||||||
|
def batch_update?
|
||||||
|
admin?
|
||||||
|
end
|
||||||
|
|
||||||
|
def show?
|
||||||
|
@user.internal_user?
|
||||||
|
end
|
||||||
|
|
||||||
|
[:clone?, :destroy?, :edit?, :update?].each do |action|
|
||||||
|
define_method(action) { admin? || author?}
|
||||||
|
end
|
||||||
|
|
||||||
|
[:reload?].each do |action|
|
||||||
|
define_method(action) { everyone }
|
||||||
|
end
|
||||||
|
|
||||||
|
class Scope < Scope
|
||||||
|
def resolve
|
||||||
|
if @user.admin?
|
||||||
|
@scope.all
|
||||||
|
elsif @user.internal_user?
|
||||||
|
@scope.where('user_id = ? OR public = TRUE', @user.id)
|
||||||
|
else
|
||||||
|
@scope.none
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
8
app/views/user_exercise_feedbacks/_form.html.slim
Normal file
8
app/views/user_exercise_feedbacks/_form.html.slim
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
= form_for(@uef) do |f|
|
||||||
|
= render('shared/form_errors', object: @uef)
|
||||||
|
.form-group
|
||||||
|
= f.label(:feedback_text)
|
||||||
|
= f.text_field(:feedback_text, class: 'form-control', required: true)
|
||||||
|
= f.label(:difficulty)
|
||||||
|
= f.text_field(:difficulty, class: 'form-control', required: true)
|
||||||
|
.actions = render('shared/submit_button', f: f, object: @uef)
|
3
app/views/user_exercise_feedbacks/new.html.slim
Normal file
3
app/views/user_exercise_feedbacks/new.html.slim
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
h1 = t('shared.new_model', model: UserExerciseFeedback.model_name.human)
|
||||||
|
|
||||||
|
= render('form')
|
@ -546,4 +546,9 @@ en:
|
|||||||
previous_label: '← Previous Page'
|
previous_label: '← Previous Page'
|
||||||
file_template:
|
file_template:
|
||||||
no_template_label: "Empty File"
|
no_template_label: "Empty File"
|
||||||
|
user_exercise_feedback:
|
||||||
|
easy: "it was easy"
|
||||||
|
some_what_easy: "it was somewhat easy"
|
||||||
|
some_what_difficult: "it was somewhat difficult"
|
||||||
|
difficult: "difficult"
|
||||||
|
|
||||||
|
@ -86,6 +86,13 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :user_exercise_feedbacks do
|
||||||
|
member do
|
||||||
|
get :reload
|
||||||
|
post :submit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :interventions do
|
resources :interventions do
|
||||||
member do
|
member do
|
||||||
post :clone
|
post :clone
|
||||||
|
6
db/migrate/20170411090543_improve_user_feedback.rb
Normal file
6
db/migrate/20170411090543_improve_user_feedback.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class ImproveUserFeedback < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :user_exercise_feedbacks, :difficulty
|
||||||
|
add_column :user_exercise_feedbacks, :difficulty, :string
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue
Block a user