사례개념화 워크시트 저장 추가
This commit is contained in:
parent
7f4a2d90c7
commit
bd389a97cc
15 changed files with 614 additions and 42 deletions
|
|
@ -70,3 +70,61 @@ CREATE POLICY p_session_evaluation_delete
|
|||
AND s.learner_id = app.current_uid()
|
||||
)
|
||||
);
|
||||
|
||||
-- Learner-edited case formulation worksheet for session review.
|
||||
CREATE TABLE IF NOT EXISTS app.case_worksheet (
|
||||
session_id UUID PRIMARY KEY REFERENCES app.sessions(id) ON DELETE CASCADE,
|
||||
payload JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
ALTER TABLE app.case_worksheet ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
DROP POLICY IF EXISTS p_case_worksheet_select ON app.case_worksheet;
|
||||
DROP POLICY IF EXISTS p_case_worksheet_insert ON app.case_worksheet;
|
||||
DROP POLICY IF EXISTS p_case_worksheet_update ON app.case_worksheet;
|
||||
DROP POLICY IF EXISTS p_case_worksheet_delete ON app.case_worksheet;
|
||||
|
||||
CREATE POLICY p_case_worksheet_select
|
||||
ON app.case_worksheet FOR SELECT USING (
|
||||
app.current_role_name() IN ('admin','instructor')
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM app.sessions s
|
||||
WHERE s.id = app.case_worksheet.session_id
|
||||
AND s.learner_id = app.current_uid()
|
||||
)
|
||||
);
|
||||
|
||||
CREATE POLICY p_case_worksheet_insert
|
||||
ON app.case_worksheet FOR INSERT WITH CHECK (
|
||||
EXISTS (
|
||||
SELECT 1 FROM app.sessions s
|
||||
WHERE s.id = app.case_worksheet.session_id
|
||||
AND s.learner_id = app.current_uid()
|
||||
)
|
||||
);
|
||||
|
||||
CREATE POLICY p_case_worksheet_update
|
||||
ON app.case_worksheet FOR UPDATE USING (
|
||||
EXISTS (
|
||||
SELECT 1 FROM app.sessions s
|
||||
WHERE s.id = app.case_worksheet.session_id
|
||||
AND s.learner_id = app.current_uid()
|
||||
)
|
||||
) WITH CHECK (
|
||||
EXISTS (
|
||||
SELECT 1 FROM app.sessions s
|
||||
WHERE s.id = app.case_worksheet.session_id
|
||||
AND s.learner_id = app.current_uid()
|
||||
)
|
||||
);
|
||||
|
||||
CREATE POLICY p_case_worksheet_delete
|
||||
ON app.case_worksheet FOR DELETE USING (
|
||||
EXISTS (
|
||||
SELECT 1 FROM app.sessions s
|
||||
WHERE s.id = app.case_worksheet.session_id
|
||||
AND s.learner_id = app.current_uid()
|
||||
)
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue