From b58e0553dece863032e514140237ba409d14de5b Mon Sep 17 00:00:00 2001 From: Matthew Hague <matthew.hague@rhul.ac.uk> Date: Wed, 7 Aug 2024 08:24:35 +0100 Subject: [PATCH] add(moodle): avoid duplicate searches in bulk-upload --- moodle/bulk-enrol.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/moodle/bulk-enrol.py b/moodle/bulk-enrol.py index 877ed08..160962c 100644 --- a/moodle/bulk-enrol.py +++ b/moodle/bulk-enrol.py @@ -147,11 +147,17 @@ cookies = get_moodle_cookies() info = get_enrol_info(cookies, url) with open(students_file) as f: + done = set() for line in f: search = line.strip() if len(search) == 0: continue + # avoid duplicates since search results exclude enrolled users + if search in done: + continue + done.add(search) + student = get_user(cookies, info, search) if student is None: print(f"WARNING: no hit for {search}, ignoring.") -- GitLab