save progress. added user feedback view and stuff

This commit is contained in:
Thomas Hille
2017-04-11 15:00:35 +02:00
parent 341cd3a003
commit 73c3b902a3
7 changed files with 105 additions and 0 deletions

View 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

View 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

View 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)

View File

@ -0,0 +1,3 @@
h1 = t('shared.new_model', model: UserExerciseFeedback.model_name.human)
= render('form')

View File

@ -546,4 +546,9 @@ en:
previous_label: '&#8592; Previous Page'
file_template:
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"

View File

@ -86,6 +86,13 @@ Rails.application.routes.draw do
end
end
resources :user_exercise_feedbacks do
member do
get :reload
post :submit
end
end
resources :interventions do
member do
post :clone

View 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