Created
February 5, 2025 18:19
-
-
Save viadanna/5e9701766d2181bfb7238a0dd5f70e49 to your computer and use it in GitHub Desktop.
Check for capa XBlocks in all courses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xmodule.modulestore.django import modulestore | |
def get_course_ids(): | |
return {summary.id for summary in modulestore().get_course_summaries()} | |
def check_capa(course_id): | |
course = modulestore().get_course(course_id, depth=None, lazy=True) | |
for section in course.get_children(): | |
for subsec in section.get_children(): | |
for unit in subsec.get_children(): | |
for xb in unit.get_children(): | |
try: | |
if "loncapa" in xb.data: | |
return True | |
except: | |
pass | |
return False | |
def main(): | |
ids = list(get_course_ids()) | |
print("Verifying %d courses" % len(ids)) | |
for i, course_id in enumerate(sorted(ids)): | |
print(i, course_id, check_capa(course_id)) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment