diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | analyze.py | 25 | ||||
-rw-r--r-- | test/integration/2students-lab-project-exam-3objectives/exclude.txt | 1 | ||||
-rw-r--r-- | test/integration/2students-lab-project-exam-3objectives/students.txt | 2 | ||||
-rw-r--r-- | test/integration/2students-lab-project-exam-3objectives/tasks.json | 14 |
5 files changed, 33 insertions, 10 deletions
@@ -1,2 +1,3 @@ grade *.xls +.DS_Store @@ -60,15 +60,16 @@ def get_task_information(fname): def get_student_information(fname):
result = []
-
+ lineno = 1
with open(fname) as f:
for line in f:
line = line.strip()
lst = line.split('\t')
- if len(lst) != 2:
- print('File %s does not have two columns.' % (fname))
- sys.exit()
- result.append((lst[0], lst[1]))
+ if len(lst) == 2:
+ result.append((lst[0], lst[1]))
+ else:
+ print('Warning: Line %d in file %s does not have two columns. Skipped!' % (lineno, fname))
+ lineno += 1
return result
@@ -240,7 +241,7 @@ STUDENT_FILE = 'students.txt' # required file containing student numbers and st check_availability(STUDENT_FILE)
EXCLUDE_FILE = 'exclude.txt'
GRADE_FILE = 'grade_file.xls' # output
-software_information = 'Course Objective Fulfillment Calculator\nCopyright (C) 2019 Hui Lan (lanhui@zjnu.edu.cn)'
+software_information = 'Course Objective Fulfillment Calculator\nCopyright (C) 2019,2020,2022 Lan Hui (lanhui@zjnu.edu.cn)'
n = max([len(s) for s in software_information.split('\n')])
banner = '%s\n%s\n%s' % ('-'*n, software_information, '-'*n)
print(banner)
@@ -274,7 +275,7 @@ if os.path.exists(EXCLUDE_FILE): if sno != '':
lst.append(sno)
for s in lst:
- print('Do not count %s' % (s))
+ print('Ignore %s' % (s))
remove_a_student(student_lst, s)
assert all_gone(student_lst, lst) == True
print('Still have %d students after excluding the undesired students specified in %s.' % (len(student_lst), EXCLUDE_FILE))
@@ -307,7 +308,7 @@ for s in student_lst: result += '\n'
result += ' ---\n Total:%4.1f\n' % (total)
file_content += '\t%4.1f\n' % (total)
- #print(result)
+
f = open(GRADE_FILE, 'w')
f.write(file_content)
@@ -320,5 +321,9 @@ num_student = len(student_lst) for x in objective_total:
co = x[0]
value = x[1]
- percentage = 100 * course_object_cumulative_score[co]/(value * num_student)
- print('Course objective %s is %.0f%% satisfied.' % (co, percentage))
+ try:
+ percentage = 100 * course_object_cumulative_score[co]/(value * num_student)
+ print('Course objective %s is %.0f%% satisfied.' % (co, percentage))
+ except:
+ print('Error: value = %4.1f, num_student = %4.1f' % (value, num_student))
+
diff --git a/test/integration/2students-lab-project-exam-3objectives/exclude.txt b/test/integration/2students-lab-project-exam-3objectives/exclude.txt new file mode 100644 index 0000000..5ed842b --- /dev/null +++ b/test/integration/2students-lab-project-exam-3objectives/exclude.txt @@ -0,0 +1 @@ +201930220320 陈辉
diff --git a/test/integration/2students-lab-project-exam-3objectives/students.txt b/test/integration/2students-lab-project-exam-3objectives/students.txt new file mode 100644 index 0000000..67f232b --- /dev/null +++ b/test/integration/2students-lab-project-exam-3objectives/students.txt @@ -0,0 +1,2 @@ +201930220235 王以冠 +201930220320 陈辉 diff --git a/test/integration/2students-lab-project-exam-3objectives/tasks.json b/test/integration/2students-lab-project-exam-3objectives/tasks.json new file mode 100644 index 0000000..9195fa6 --- /dev/null +++ b/test/integration/2students-lab-project-exam-3objectives/tasks.json @@ -0,0 +1,14 @@ +{ + "course.objectives":["co1", "co2", "co3"], + "tasks":{ + "lab":{ + "co1":30 + }, + "project":{ + "co2":20 + }, + "exam":{ + "co3":50 + } + } +} |