autograder .cli .courses .users .enroll
Enroll a user in a course.
usage: python3 -m autograder.cli.courses.users.enroll [-h] [--version]
[--server SERVER]
[--course COURSE]
[--user USER]
[--pass PASS]
[--dry-run]
[--skip-inserts]
[--skip-updates]
[--send-emails]
--new-email NEW_EMAIL
[--new-name NEW_NAME]
[--new-course-role {unknown,other,student,grader,admin,owner}]
[--new-lms-id NEW_LMS_ID]
[--testing-mode]
Enroll a user in a course.
options:
-h, --help show this help message and exit
--version show program's version number and exit
command-specific options:
--server SERVER The URL of the autograder server to communicate with.
--course COURSE The ID of the course to make this request to.
--user USER The email of the user making this request.
--pass PASS The password of the user making this request.
--dry-run Do not commit/finalize the operation, just do all the
steps and state what the result would look like.
--skip-inserts Skip insert operations.
--skip-updates Skip update operations.
--send-emails Send any relevant emails to users affected by this
operation (e.g., a user being enrolled in a course).
--new-email NEW_EMAIL
The email for the new user.
--new-name NEW_NAME
The name for the new user.
--new-course-role {unknown,other,student,grader,admin,owner}
The course role for the new user. (default: student)
--new-lms-id NEW_LMS_ID
The LMS ID for the new user.
testing options:
--testing-mode Run as if a test is being run (default: False).
1""" 2Enroll a user in a course. 3""" 4 5import argparse 6import sys 7 8import edq.util.json 9 10import autograder.api.courses.users.enroll 11import autograder.cli.parser 12 13def run_cli(args: argparse.Namespace) -> int: 14 """ Run the CLI. """ 15 16 config = args._config_info.application_config 17 18 config.raw_course_users = [ 19 { 20 'email': config.new_email, 21 'name': config.new_name, 22 'course-role': config.new_course_role, 23 'course-lms-id': config.new_lms_id, 24 }, 25 ] 26 27 result = autograder.api.courses.users.enroll.send(config, exit_on_error = True) 28 print(edq.util.json.dumps(result, indent = 4)) 29 30 return 0 31 32def main() -> int: 33 """ Get a parser, parse the args, and call run. """ 34 35 return run_cli(_get_parser().parse_args()) 36 37def _get_parser() -> argparse.ArgumentParser: 38 """ Get a parser for this operation. """ 39 40 parser = autograder.cli.parser.get_parser( 41 __doc__.strip(), 42 autograder.api.courses.users.enroll.API_PARAMS) 43 44 return parser 45 46if (__name__ == '__main__'): 47 sys.exit(main())
def
run_cli(args: argparse.Namespace) -> int:
14def run_cli(args: argparse.Namespace) -> int: 15 """ Run the CLI. """ 16 17 config = args._config_info.application_config 18 19 config.raw_course_users = [ 20 { 21 'email': config.new_email, 22 'name': config.new_name, 23 'course-role': config.new_course_role, 24 'course-lms-id': config.new_lms_id, 25 }, 26 ] 27 28 result = autograder.api.courses.users.enroll.send(config, exit_on_error = True) 29 print(edq.util.json.dumps(result, indent = 4)) 30 31 return 0
Run the CLI.
def
main() -> int:
33def main() -> int: 34 """ Get a parser, parse the args, and call run. """ 35 36 return run_cli(_get_parser().parse_args())
Get a parser, parse the args, and call run.