<commit_before>-- BLOCK lock_with_grading_log_id
SELECT
    gl.auth_user_id,
    ((gl.graded_at IS NOT NULL) OR (gl.grading_request_canceled_at IS NOT NULL)) AS grading_not_needed,
    iq.id AS instance_question_id,
    ai.id AS assessment_instance_id,
    s.credit
FROM
    grading_logs AS gl
    JOIN submissions AS s ON (s.id = gl.submission_id)
    JOIN variants AS v ON (v.id = s.variant_id)
    JOIN instance_questions AS iq ON (iq.id = v.instance_question_id)
    JOIN assessment_instances AS ai ON (ai.id = iq.assessment_instance_id)
WHERE
    gl.id = $grading_log_id
FOR UPDATE OF ai;

-- BLOCK lock_with_assessment_instance_id
SELECT
    ai.id
FROM
    assessment_instances AS ai
WHERE
    ai.id = $assessment_instance_id
FOR UPDATE OF ai;

-- BLOCK select_work_list
SELECT
    s.id AS submission_id,
    iq.id AS instance_question_id,
    to_jsonb(v) AS variant,
    to_jsonb(q) AS question,
    to_jsonb(c) AS course
FROM
    assessment_instances AS ai
    JOIN instance_questions AS iq ON (iq.assessment_instance_id = ai.id)
    JOIN assessment_questions AS aq ON (aq.id = iq.assessment_question_id)
    JOIN questions AS q ON (q.id = aq.question_id)
    JOIN variants AS v ON (v.instance_question_id = iq.id)
    JOIN LATERAL (
        SELECT *
        FROM submissions AS s
        WHERE s.variant_id = v.id
        ORDER BY date DESC
        LIMIT 1
    ) AS s ON (s.variant_id = v.id)
    JOIN assessments AS a ON (a.id = ai.assessment_id)
    JOIN course_instances AS ci ON (ci.id = a.course_instance_id)
    JOIN pl_courses AS c ON (c.id = ci.course_id)
WHERE
    ai.id = $assessment_instance_id
    AND s.score IS NULL<commit_msg>disallow grade/finish on closed exams<commit_after>-- BLOCK lock_with_grading_log_id
SELECT
    gl.auth_user_id,
    ((gl.graded_at IS NOT NULL) OR (gl.grading_request_canceled_at IS NOT NULL)) AS grading_not_needed,
    iq.id AS instance_question_id,
    ai.id AS assessment_instance_id,
    s.credit
FROM
    grading_logs AS gl
    JOIN submissions AS s ON (s.id = gl.submission_id)
    JOIN variants AS v ON (v.id = s.variant_id)
    JOIN instance_questions AS iq ON (iq.id = v.instance_question_id)
    JOIN assessment_instances AS ai ON (ai.id = iq.assessment_instance_id)
WHERE
    gl.id = $grading_log_id
FOR UPDATE OF ai;

-- BLOCK lock_with_assessment_instance_id
SELECT
    ai.id
FROM
    assessment_instances AS ai
WHERE
    ai.id = $assessment_instance_id
    AND ai.open
FOR UPDATE OF ai;

-- BLOCK select_work_list
SELECT
    s.id AS submission_id,
    iq.id AS instance_question_id,
    to_jsonb(v) AS variant,
    to_jsonb(q) AS question,
    to_jsonb(c) AS course
FROM
    assessment_instances AS ai
    JOIN instance_questions AS iq ON (iq.assessment_instance_id = ai.id)
    JOIN assessment_questions AS aq ON (aq.id = iq.assessment_question_id)
    JOIN questions AS q ON (q.id = aq.question_id)
    JOIN variants AS v ON (v.instance_question_id = iq.id)
    JOIN LATERAL (
        SELECT *
        FROM submissions AS s
        WHERE s.variant_id = v.id
        ORDER BY date DESC
        LIMIT 1
    ) AS s ON (s.variant_id = v.id)
    JOIN assessments AS a ON (a.id = ai.assessment_id)
    JOIN course_instances AS ci ON (ci.id = a.course_instance_id)
    JOIN pl_courses AS c ON (c.id = ci.course_id)
WHERE
    ai.id = $assessment_instance_id
    AND s.score IS NULL
{'fraction_non_alphanumeric': 0.07005988023952096, 'fraction_numerical': 0.0005988023952095808, 'mean_word_length': 3.0399032648125757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4851424', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1195, 'n_words': 357}