Merge pull request #9 from teste-de-progresso/update-new-assessement-page

add assessement endpoint
This commit is contained in:
João Geonizeli
2023-09-21 14:05:17 -03:00
committed by GitHub
7 changed files with 124 additions and 8 deletions

View File

@@ -7,12 +7,14 @@ import { AssessmentRoutePaths, DashboardRoutePaths, QuestionRoutePaths } from ".
import { RootState } from "../../services/store"; import { RootState } from "../../services/store";
import { turnOff } from "../../services/store/unsavedChanges"; import { turnOff } from "../../services/store/unsavedChanges";
import { Dialog } from '../Dialog'; import { Dialog } from '../Dialog';
import { useCurrentUser } from "../../contexts";
export const AppbarTabs = () => { export const AppbarTabs = () => {
const unsavedChanges = useSelector((state: RootState) => state.unsavedChanges) const unsavedChanges = useSelector((state: RootState) => state.unsavedChanges)
const dispatch = useDispatch() const dispatch = useDispatch()
const location = useLocation() const location = useLocation()
const history = useHistory() const history = useHistory()
const { isOnlyTeacher } = useCurrentUser()
const [newPath, setNewPath] = useState<string>() const [newPath, setNewPath] = useState<string>()
@@ -45,14 +47,16 @@ export const AppbarTabs = () => {
tabel: 'Questões', tabel: 'Questões',
pathname: QuestionRoutePaths.index, pathname: QuestionRoutePaths.index,
isCurrent: location.pathname.includes('question'), isCurrent: location.pathname.includes('question'),
}, }]
{
if (!isOnlyTeacher) {
links.push({
icon: <DocumentIcon className="w-6" />, icon: <DocumentIcon className="w-6" />,
tabel: 'Avaliações', tabel: 'Avaliações',
pathname: AssessmentRoutePaths.index, pathname: AssessmentRoutePaths.index,
isCurrent: false, isCurrent: false,
})
} }
]
return ( return (
<> <>

23
app/models/assessment.rb Normal file
View File

@@ -0,0 +1,23 @@
# == Schema Information
#
# Table name: assessments
#
# id :bigint not null, primary key
# observations :text
# params :jsonb
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_assessments_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
class Assessment < ApplicationRecord
belongs_to :user
end

View File

@@ -0,0 +1,13 @@
class AssessmentPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.all
end
def index?
@roles.find do |role|
admin nde coordinator center_director pro_rector teacher
end
end
end
end

View File

@@ -0,0 +1,12 @@
class CreateAssessments < ActiveRecord::Migration[7.0]
def change
create_table :assessments do |t|
t.string :title
t.text :observations
t.jsonb :params
t.references :user, null: false, foreign_key: true
t.timestamps
end
end
end

13
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_08_05_233401) do ActiveRecord::Schema[7.0].define(version: 2023_07_05_145916) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@@ -56,6 +56,16 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_05_233401) do
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end end
create_table "assessments", force: :cascade do |t|
t.string "title"
t.text "observations"
t.jsonb "params"
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_assessments_on_user_id"
end
create_table "axes", force: :cascade do |t| create_table "axes", force: :cascade do |t|
t.string "name" t.string "name"
t.datetime "created_at", null: false t.datetime "created_at", null: false
@@ -155,6 +165,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_05_233401) do
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "assessments", "users"
add_foreign_key "questions", "subjects" add_foreign_key "questions", "subjects"
add_foreign_key "questions", "users" add_foreign_key "questions", "users"
add_foreign_key "review_messages", "questions" add_foreign_key "review_messages", "questions"

View File

@@ -0,0 +1,28 @@
# == Schema Information
#
# Table name: assessments
#
# id :bigint not null, primary key
# observations :text
# params :jsonb
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_assessments_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
FactoryBot.define do
factory :assessment do
title { "MyString" }
observations { "MyText" }
params { "" }
user { nil }
end
end

View File

@@ -0,0 +1,25 @@
# == Schema Information
#
# Table name: assessments
#
# id :bigint not null, primary key
# observations :text
# params :jsonb
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_assessments_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
require 'rails_helper'
RSpec.describe Assessment, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end