-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57e309a
commit ad7345a
Showing
19 changed files
with
355 additions
and
152 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import autograder.api.common | ||
import autograder.api.config | ||
|
||
API_ENDPOINT = 'lms/sync/users' | ||
API_PARAMS = [ | ||
autograder.api.config.PARAM_COURSE_ID, | ||
autograder.api.config.PARAM_USER_EMAIL, | ||
autograder.api.config.PARAM_USER_PASS, | ||
autograder.api.config.PARAM_DRY_RUN, | ||
autograder.api.config.PARAM_SKIP_EMAILS, | ||
] | ||
|
||
DESCRIPTION = 'Sync autograder users with LMS users.' | ||
|
||
def send(arguments, **kwargs): | ||
return autograder.api.common.handle_api_request(arguments, API_PARAMS, API_ENDPOINT, **kwargs) | ||
|
||
def _get_parser(): | ||
parser = autograder.api.config.get_argument_parser( | ||
description = DESCRIPTION, | ||
params = API_PARAMS) | ||
|
||
return parser |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import autograder.api.common | ||
import autograder.api.config | ||
|
||
API_ENDPOINT = 'lms/upload/scores' | ||
API_PARAMS = [ | ||
autograder.api.config.PARAM_COURSE_ID, | ||
autograder.api.config.PARAM_USER_EMAIL, | ||
autograder.api.config.PARAM_USER_PASS, | ||
|
||
autograder.api.config.APIParam('assignment-lms-id', | ||
'The LMS ID of the assignment to upload scores to.', | ||
required = True), | ||
|
||
autograder.api.config.APIParam('scores', | ||
'A list of scores to upload.', | ||
required = True, cli_param = False), | ||
] | ||
|
||
DESCRIPTION = 'Get the information for an LMS user.' | ||
|
||
def send(arguments, **kwargs): | ||
return autograder.api.common.handle_api_request(arguments, API_PARAMS, API_ENDPOINT, **kwargs) | ||
|
||
def _get_parser(): | ||
parser = autograder.api.config.get_argument_parser( | ||
description = DESCRIPTION, | ||
params = API_PARAMS) | ||
|
||
return parser |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import autograder.api.common | ||
import autograder.api.config | ||
|
||
API_ENDPOINT = 'lms/user/get' | ||
API_PARAMS = [ | ||
autograder.api.config.PARAM_COURSE_ID, | ||
autograder.api.config.PARAM_USER_EMAIL, | ||
autograder.api.config.PARAM_USER_PASS, | ||
autograder.api.config.PARAM_TARGET_EMAIL, | ||
] | ||
|
||
DESCRIPTION = 'Get information for an LMS user.' | ||
|
||
def send(arguments, **kwargs): | ||
return autograder.api.common.handle_api_request(arguments, API_PARAMS, API_ENDPOINT, **kwargs) | ||
|
||
def _get_parser(): | ||
parser = autograder.api.config.get_argument_parser( | ||
description = DESCRIPTION, | ||
params = API_PARAMS) | ||
|
||
return parser |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
HEADERS = ['email', 'name', 'role', 'lms-id'] | ||
SYNC_HEADERS = HEADERS + ['operation'] | ||
|
||
SYNC_USERS_KEYS = [ | ||
('add-users', 'Added', 'add'), | ||
('mod-users', 'Modified', 'mod'), | ||
('del-users', 'Deleted', 'delete'), | ||
('skip-users', 'Skipped', 'skip'), | ||
] | ||
|
||
def list_users(users, table = False): | ||
if (table): | ||
_list_users_table(users) | ||
else: | ||
_list_users(users) | ||
|
||
def _list_users(users, indent = ''): | ||
for user in users: | ||
print(indent + "Email:", user['email']) | ||
print(indent + "Name:", user['name']) | ||
print(indent + "Role:", user['role']) | ||
print(indent + "LMS ID:", user['lms-id']) | ||
print() | ||
|
||
def _list_users_table(users, header = True, keys = HEADERS): | ||
if (header): | ||
print("\t".join(keys)) | ||
|
||
for user in users: | ||
row = [user[key] for key in keys] | ||
print("\t".join([str(value) for value in row])) | ||
|
||
def list_sync_users(sync_users, table = False): | ||
if (table): | ||
_list_sync_users_table(sync_users) | ||
else: | ||
_list_sync_users(sync_users) | ||
|
||
def _list_sync_users(sync_users): | ||
count = (len(sync_users['add-users']) | ||
+ len(sync_users['mod-users']) | ||
+ len(sync_users['del-users'])) | ||
print("Synced %d users." % (count)) | ||
|
||
for (key, label, _) in SYNC_USERS_KEYS: | ||
users = sync_users[key] | ||
if (len(users) == 0): | ||
continue | ||
|
||
print("%s Users:" % (label)) | ||
_list_users(users, indent = ' ') | ||
|
||
def _list_sync_users_table(sync_users): | ||
print("\t".join(SYNC_HEADERS)) | ||
|
||
for (key, _, op) in SYNC_USERS_KEYS: | ||
users = sync_users[key] | ||
for user in users: | ||
user['operation'] = op | ||
|
||
_list_users_table(users, header = False, keys = SYNC_HEADERS) |
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sys | ||
|
||
import autograder.api.lms.userget | ||
import autograder.cli.common | ||
|
||
def run(arguments): | ||
result = autograder.api.lms.userget.send(arguments, exit_on_error = True) | ||
|
||
if (not result['found-autograder-user']): | ||
print("No matching autograder user found.") | ||
return 0 | ||
|
||
if (not result['found-lms-user']): | ||
print("No matching lms user found.") | ||
return 0 | ||
|
||
autograder.cli.common.list_users([result['user']], table = arguments.table) | ||
return 0 | ||
|
||
def main(): | ||
return run(_get_parser().parse_args()) | ||
|
||
def _get_parser(): | ||
parser = autograder.api.lms.userget._get_parser() | ||
|
||
parser.add_argument('--table', dest = 'table', | ||
action = 'store_true', default = False, | ||
help = 'Output the results as a TSV table with a header (default: %(default)s).') | ||
|
||
return parser | ||
|
||
if (__name__ == '__main__'): | ||
sys.exit(main()) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sys | ||
|
||
import autograder.api.lms.syncusers | ||
import autograder.cli.common | ||
|
||
def run(arguments): | ||
result = autograder.api.lms.syncusers.send(arguments, exit_on_error = True) | ||
autograder.cli.common.list_sync_users(result, table = arguments.table) | ||
return 0 | ||
|
||
def main(): | ||
return run(_get_parser().parse_args()) | ||
|
||
def _get_parser(): | ||
parser = autograder.api.lms.syncusers._get_parser() | ||
|
||
parser.add_argument('--table', dest = 'table', | ||
action = 'store_true', default = False, | ||
help = 'Output the results as a TSV table with a header (default: %(default)s).') | ||
|
||
return parser | ||
|
||
if (__name__ == '__main__'): | ||
sys.exit(main()) |
Oops, something went wrong.