feat(assessment): assign the demonstration category and keep result history
This commit is contained in:
1 parent
b3c6dc870b
commit
8277133712
61 files changed
+4338
-268
No files matched your search
@@ -97,12 +97,11 @@ BEGIN
|
||||
AND policy.policy_key = 'product'
|
||||
AND policy.kind = 'demo'
|
||||
AND policy.version = NEW.product_policy_version
|
||||
AND policy.document #>> '{assessment,attempt,real_mode}' = 'demo_basic'
|
||||
AND policy.document #>> '{assessment,attempt,basic_pass_mark_bp}' = '8000';
|
||||
AND policy.document #>> '{assessment,attempt,real_mode}' = 'demo_basic';
|
||||
IF NOT FOUND OR policy_version <> NEW.product_policy_version THEN
|
||||
RAISE EXCEPTION USING
|
||||
ERRCODE = '23514', CONSTRAINT = 'assessment_synthetic_category_review_policy',
|
||||
MESSAGE = 'synthetic category review policy is not an explicit demo basic policy';
|
||||
MESSAGE = 'synthetic category review policy is not a demo basic policy';
|
||||
END IF;
|
||||
|
||||
NEW.reviewed_at := clock_timestamp();
|
||||
@@ -263,6 +262,7 @@ LANGUAGE plpgsql AS $$
|
||||
DECLARE
|
||||
review assessment_synthetic_category_reviews%ROWTYPE;
|
||||
attempt assessment_attempts%ROWTYPE;
|
||||
pass_mark_text text;
|
||||
BEGIN
|
||||
IF NEW.schema_version = 1 THEN
|
||||
RETURN NEW;
|
||||
@@ -337,6 +337,21 @@ BEGIN
|
||||
ERRCODE = '23514', CONSTRAINT = 'assessment_attempt_result_category_assignment',
|
||||
MESSAGE = 'category assignment is not a passing reviewed demo decision';
|
||||
END IF;
|
||||
|
||||
-- The threshold that confirmed the result is the pass mark of the policy
|
||||
-- version pinned to the attempt, read from the stored document and not
|
||||
-- from a constant. The text is checked before the cast.
|
||||
IF NEW.category_decision->>'status' = 'assigned' THEN
|
||||
SELECT policy.document #>> '{assessment,attempt,basic_pass_mark_bp}' INTO pass_mark_text
|
||||
FROM policy_versions AS policy
|
||||
WHERE policy.id = NEW.product_policy_version_id AND policy.policy_key = 'product';
|
||||
IF NOT FOUND OR pass_mark_text IS NULL OR pass_mark_text !~ '^[0-9]{1,5}$' OR
|
||||
NEW.pass_mark_basis_points IS DISTINCT FROM pass_mark_text::integer THEN
|
||||
RAISE EXCEPTION USING
|
||||
ERRCODE = '23514', CONSTRAINT = 'assessment_attempt_result_category_threshold',
|
||||
MESSAGE = 'category assignment does not use the pass mark of its pinned policy version';
|
||||
END IF;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$;
|
||||
|
||||
Reference in new issue
Block a user