Skip to content

Commit

Permalink
Updating in-house file
Browse files Browse the repository at this point in the history
  • Loading branch information
trampgeek committed Dec 10, 2024
1 parent 27dc3e5 commit 2f5138b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ucprivate/miscqueries.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# List all courses and their contextids
SELECT crs.id, ctx.id as contextid, crs.shortname as name
FROM mdl_course crs
JOIN mdl_context ctx ON ctx.instanceid = crs.id
WHERE ctx.contextlevel = 50
ORDER BY name;

# List all questions in a given course
SELECT q.id, qv.version, q.name
FROM mdl_context ctx
JOIN mdl_course crs on crs.id = ctx.instanceid
JOIN mdl_question_categories qc on qc.contextid = ctx.id
JOIN mdl_question_bank_entries qbe on qbe.questioncategoryid = qc.id
JOIN mdl_question_versions qv on qv.questionbankentryid = qbe.id
JOIN mdl_question q on q.id = qv.questionid
WHERE crs.shortname='COSC131-24S1'
ORDER BY q.name;

# Change the text of questions in a given course
UPDATE mdl_question q
SET questiontext = REPLACE(q.questiontext, 'Pylint', 'Ruff')
WHERE q.id IN (
SELECT subquery.id
FROM (
SELECT q.id
FROM mdl_context ctx
JOIN mdl_course crs ON crs.id = ctx.instanceid
JOIN mdl_question_categories qc ON qc.contextid = ctx.id
JOIN mdl_question_bank_entries qbe ON qbe.questioncategoryid = qc.id
JOIN mdl_question_versions qv ON qv.questionbankentryid = qbe.id
JOIN mdl_question q ON q.id = qv.questionid
WHERE crs.shortname = 'COSC131-25S1'
) AS subquery
);

0 comments on commit 2f5138b

Please sign in to comment.