def output_cohorts_info(obj, format_string, path): from psmdlsyncer.sql import MoodleDBSession from psmdlsyncer.php import ModUserEnrollments from psmdlsyncer.sql import MoodleDBSession from psmdlsyncer.models.datastores.moodle import MoodleTree moodle = MoodleTree() moodle.process() m = MoodleDBSession() mod = ModUserEnrollments() if path is None: import sys output_func = sys.stdout.write else: output_func = path.write format_string += '\n' for idnumber, username, cohort in m.get_cohorts_with_username(): if cohort: if moodle.teachers.get_from_attribute('username', username): output_func(format_string.format(idnumber=idnumber, cohort=cohort, username=username))
from psmdlsyncer.sql import MoodleDBSession from psmdlsyncer.php import ModUserEnrollments from psmdlsyncer.sql import MoodleDBSession from psmdlsyncer.models.datastores.moodle import MoodleTree if __name__ == '__main__': moodle = MoodleTree() moodle.process() m = MoodleDBSession() mod = ModUserEnrollments() for idnumber, username, cohort in m.get_cohorts_with_username(): if cohort: if moodle.teachers.get_from_attribute('username', username): print(idnumber, username, cohort) from IPython import embed;embed()