Commit d179c812 authored by Alan Marchiori's avatar Alan Marchiori
Browse files

fixed report on ungraded and no courses configured

parent 0f5b9e2d
......@@ -199,42 +199,42 @@ def student_report(coursename, coursepath, labname, clone):
with open(feedbackfile, 'r') as f:
for line in f:
echo(line.rstrip())
elif os.path.exists(labpath):
with History(location=labpath,save=False) as h:
if 'grade' in h:
r = h['grade']
# recompute total due to possible bug in grade...
# eventually this can go away. (ie after 2020 spring)
h['grade']['TOTAL'] = {
'grade': sum(
[h['grade'][pt]['grade'] for pt in rub['parts'].keys() if pt in h['grade']]),
#'total': sum([h['grade'][pt]['total'] for pt in rub['parts'].keys() if pt in h['grade']]),
'total': sum([x['points'] for x in rub['parts'].values()]),
'who': h['grade']['TOTAL']['who'],
'at': utils.timestamp().isoformat()
}
parts = sorted([(k, r[k]['at']) for k in r.keys()],
key=lambda x: x[1])
for p in parts:
echo()
part, at = p
if part == 'TOTAL':
pstr = '{} TOTAL'.format(labname)
else:
pstr = part
echo("{}:{}{:3} / {:3}".format(
pstr,
" ".rjust(width-15-len(pstr)),
r[part]['grade'],
r[part]['total']
))
if 'comment' in r[part]:
echo ("\tComments: {}".format(r[part]['comment']))
else:
echo (f"Check your email for a message from {config.feedback_email_from}.")
#r[part]['who'].split("@")[0])
else:
warn(f'No grade report for {labname}. Check with your ta/instructor.')
#elif os.path.exists(labpath):
# with History(location=labpath,save=False) as h:
# if 'grade' in h:
# r = h['grade']
# # recompute total due to possible bug in grade...
# # eventually this can go away. (ie after 2020 spring)
# h['grade']['TOTAL'] = {
# 'grade': sum(
# [h['grade'][pt]['grade'] for pt in rub['parts'].keys() if pt in h['grade']]),
# #'total': sum([h['grade'][pt]['total'] for pt in rub['parts'].keys() if pt in h['grade']]),
# 'total': sum([x['points'] for x in rub['parts'].values()]),
# 'who': h['grade']['TOTAL']['who'],
# 'at': utils.timestamp().isoformat()
# }
# parts = sorted([(k, r[k]['at']) for k in r.keys()],
# key=lambda x: x[1])
# for p in parts:
# echo()
# part, at = p
# if part == 'TOTAL':
# pstr = '{} TOTAL'.format(labname)
# else:
# pstr = part
# echo("{}:{}{:3} / {:3}".format(
# pstr,
# " ".rjust(width-15-len(pstr)),
# r[part]['grade'],
# r[part]['total']
# ))
# if 'comment' in r[part]:
# echo ("\tComments: {}".format(r[part]['comment']))
# else:
# echo (f"Check your email for a message from {config.feedback_email_from}.")
# #r[part]['who'].split("@")[0])
echo ("-"*max(10,width-5))
@click.command(short_help="Show the grade report.")
......
......@@ -75,8 +75,11 @@ if __name__ =="__main__":
try:
# expose labtool version through config module
config.labtool_version = labtool_version
with config.UserConfig() as uc:
main()
with config.UserConfig() as uc:
if 'courses' not in uc.cfg or len(uc.cfg['courses']) == 0:
error("No courses configured for labtool, use lt init!")
else:
main()
except Exception as x:
error("Oops--Something went wrong in labtool ({}).".format(str(x)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment