lms .cli .courses .gradebook .get
Get specific entries in a course's gradebook.
usage: python3 -m lms.cli.courses.gradebook.get [-h] [--version]
[--server SERVER]
[--server-type {blackboard,canvas,moodle}]
[--auth-user AUTH_USER]
[--auth-password AUTH_PASSWORD]
[--auth-token AUTH_TOKEN]
[--course COURSE]
[--format {json,table,text}]
[--include-extra-fields]
[--pretty-headers]
[--skip-headers]
[--assignment ASSIGNMENTS]
[--user USERS]
Get specific entries in a course's gradebook.
options:
-h, --help show this help message and exit
--version show program's version number and exit
--course COURSE The course to target for this operation.
--assignment ASSIGNMENTS
Include this assignment in the gradebook (all
assignments are included if this option is not
specified).
--user USERS Include this user in the gradebook (all users are
included if this option is not specified).
server options:
--server SERVER The address of the LMS server to connect to.
--server-type {blackboard,canvas,moodle}
The type of LMS being connected to (this can normally
be guessed from the server address).
authentication options:
--auth-user AUTH_USER
The user to authenticate with.
--auth-password AUTH_PASSWORD
The password to authenticate with.
--auth-token AUTH_TOKEN
The token to authenticate with.
output formatting options:
--format {json,table,text}
The format to display the output as (default: text).
--include-extra-fields
Include non-common (usually LMS-specific) fields in
results (default: False).
--pretty-headers When displaying headers, try to make them look
"pretty" (default: False).
--skip-headers Skip headers when outputting results, will not apply
to all formats (default: False).
1""" 2Get specific entries in a course's gradebook. 3""" 4 5import argparse 6import sys 7 8import lms.backend.instance 9import lms.cli.common 10import lms.cli.parser 11 12def run_cli(args: argparse.Namespace) -> int: 13 """ Run the CLI. """ 14 15 config = args._config_info.application_config 16 backend = lms.backend.instance.get_backend(config) 17 18 course_query = lms.cli.common.check_required_course(backend, config) 19 if (course_query is None): 20 return 1 21 22 assignment_queries = backend.parse_assignment_queries(args.assignments) 23 user_queries = backend.parse_user_queries(args.users) 24 25 gradebook = backend.courses_gradebook_get(course_query, assignment_queries, user_queries) 26 27 output = lms.model.base.base_list_to_output_format([gradebook], config.output_format, 28 skip_headers = args.skip_headers, 29 pretty_headers = args.pretty_headers, 30 include_extra_fields = args.include_extra_fields, 31 extract_single_list = True, 32 ) 33 34 print(output) 35 36 return 0 37 38def main() -> int: 39 """ Get a parser, parse the args, and call run. """ 40 return run_cli(_get_parser().parse_args()) 41 42def _get_parser() -> argparse.ArgumentParser: 43 """ Get the parser. """ 44 45 parser = lms.cli.parser.get_parser(__doc__.strip(), 46 include_output_format = True, 47 include_course = True, 48 ) 49 50 parser.add_argument('--assignment', dest = 'assignments', 51 action = 'append', type = str, default = [], 52 help = 'Include this assignment in the gradebook (all assignments are included if this option is not specified).') 53 54 parser.add_argument('--user', dest = 'users', 55 action = 'append', type = str, default = [], 56 help = 'Include this user in the gradebook (all users are included if this option is not specified).') 57 58 return parser 59 60if (__name__ == '__main__'): 61 sys.exit(main())
def
run_cli(args: argparse.Namespace) -> int:
13def run_cli(args: argparse.Namespace) -> int: 14 """ Run the CLI. """ 15 16 config = args._config_info.application_config 17 backend = lms.backend.instance.get_backend(config) 18 19 course_query = lms.cli.common.check_required_course(backend, config) 20 if (course_query is None): 21 return 1 22 23 assignment_queries = backend.parse_assignment_queries(args.assignments) 24 user_queries = backend.parse_user_queries(args.users) 25 26 gradebook = backend.courses_gradebook_get(course_query, assignment_queries, user_queries) 27 28 output = lms.model.base.base_list_to_output_format([gradebook], config.output_format, 29 skip_headers = args.skip_headers, 30 pretty_headers = args.pretty_headers, 31 include_extra_fields = args.include_extra_fields, 32 extract_single_list = True, 33 ) 34 35 print(output) 36 37 return 0
Run the CLI.
def
main() -> int:
39def main() -> int: 40 """ Get a parser, parse the args, and call run. """ 41 return run_cli(_get_parser().parse_args())
Get a parser, parse the args, and call run.