Merge pull request #9 from teste-de-progresso/update-new-assessement-page
add assessement endpoint
This commit is contained in:
@@ -7,12 +7,14 @@ import { AssessmentRoutePaths, DashboardRoutePaths, QuestionRoutePaths } from ".
|
||||
import { RootState } from "../../services/store";
|
||||
import { turnOff } from "../../services/store/unsavedChanges";
|
||||
import { Dialog } from '../Dialog';
|
||||
import { useCurrentUser } from "../../contexts";
|
||||
|
||||
export const AppbarTabs = () => {
|
||||
const unsavedChanges = useSelector((state: RootState) => state.unsavedChanges)
|
||||
const dispatch = useDispatch()
|
||||
const location = useLocation()
|
||||
const history = useHistory()
|
||||
const { isOnlyTeacher } = useCurrentUser()
|
||||
|
||||
const [newPath, setNewPath] = useState<string>()
|
||||
|
||||
@@ -45,14 +47,16 @@ export const AppbarTabs = () => {
|
||||
tabel: 'Questões',
|
||||
pathname: QuestionRoutePaths.index,
|
||||
isCurrent: location.pathname.includes('question'),
|
||||
},
|
||||
{
|
||||
}]
|
||||
|
||||
if (!isOnlyTeacher) {
|
||||
links.push({
|
||||
icon: <DocumentIcon className="w-6" />,
|
||||
tabel: 'Avaliações',
|
||||
pathname: AssessmentRoutePaths.index,
|
||||
isCurrent: false,
|
||||
})
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
23
app/models/assessment.rb
Normal file
23
app/models/assessment.rb
Normal 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
|
||||
13
app/policies/assessment_policy.rb
Normal file
13
app/policies/assessment_policy.rb
Normal 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
|
||||
12
db/migrate/20230705145916_create_assessments.rb
Normal file
12
db/migrate/20230705145916_create_assessments.rb
Normal 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
13
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# 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
|
||||
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
|
||||
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|
|
||||
t.string "name"
|
||||
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_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "assessments", "users"
|
||||
add_foreign_key "questions", "subjects"
|
||||
add_foreign_key "questions", "users"
|
||||
add_foreign_key "review_messages", "questions"
|
||||
|
||||
28
spec/factories/assessments.rb
Normal file
28
spec/factories/assessments.rb
Normal 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
|
||||
25
spec/models/assessment_spec.rb
Normal file
25
spec/models/assessment_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user