-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_admin.cpp
943 lines (837 loc) · 23.8 KB
/
manage_admin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
/**
* **************************************************
*
* @coding UTF-8
*
* @file manage_admin.cpp
*
* @author HDM
*
* @copyright HDM
*
* @date 2021/01/23 22:31:42
*
* @version 1.0
*
* **************************************************
*/
#include "manage_admin.h"
/**
* **************************************************
*
* @brief print menu of admin
*
* @param menus (menu&) self-define menu
*
* @retval None
*
* **************************************************
*/
void print_menu_admin(menu& menus)
{
while (true)
{
CLEAN;
std::cout << "Welcome, Administrator\n" << std::endl;
print_menu(false, 1, menus.vector_admin_main, "Please select an option: ");
switch (input_option(static_cast<int>(menus.vector_admin_main.size())))
{
case 0:
std::cout << "Bye" << std::endl;
Sleep(800);
return;
case 1:
print_menu_admin_account_create(menus);
break;
case 2:
print_menu_admin_account_delete();
break;
case 3:
print_menu_admin_create_class();
break;
case 4:
print_menu_admin_delete_class();
break;
case 5:
print_menu_admin_exam_create(menus);
break;
case 6:
print_menu_admin_exam_update(menus);
break;
default:
print_wait("Please select an option!");
break;
}
}
}
/**
* **************************************************
*
* @brief print menu of create account
*
* @param menus (menu&) self-define menu
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_account_create(menu& menus)
{
while (true)
{
CLEAN;
// ---------- Start ----------
switch (input_judgment(true, true, "Do you want to create an account? (Y/N): "))
{
case -1:
continue;
case 0:
return;
case 1:
default:
break;
}
// ---------- Print Menu & Select Privilege ----------
print_menu(true, 1, menus.vector_menu_create_account, "Please set a privilege or back: ");
const int option = input_option(static_cast<int>(menus.vector_menu_create_account.size()));
switch (option)
{
case 0:
break;
case 1:
case 2:
{
auto* student = new student_info();
// ---------- Select ----------
student->user_id = input(MAXSIZE_INPUT_USER_ID, true, "Please set account(user) name: ");
if (user_select(student->user_id)->info_flag)
{
print_wait("Cancelled because the user already exists!");
break;
}
// ---------- Input Information ----------
student->user_password = input(MAXSIZE_INPUT_USER_PASSWORD, true, "Please set account(user) password: ");
student->user_privilege = option;
student->name = input(MAXSIZE_STUDENT_NAME, true, "Please set administrator/student true name: ");
while (true)
{
student->id = input(MAXSIZE_STUDENT_ID, true, "Please set it administrator/student id: ");
if (is_positive_integer(student->id))
{
if (!user_select(student->id, 2)->info_flag)
{
break;
}
print_wait("Cancelled because the user already exists!");
free_ptr(student->id, true);
continue;
}
free_ptr(student->id, true);
print_wait("Please input integer.");
}
while (true)
{
student->class_id = input(MAXSIZE_CLASS_ID, true, "Please set it administrator/student class id: ");
if (is_positive_integer(student->class_id))
{
break;
}
free_ptr(student->class_id, true);
print_wait("Please input integer.");
}
while (true)
{
std::cout << "Please set administrator/student gender (0:Female, 1:Male): ";
student->gender = input_option(2);
if (0 == student->gender || 1 == student->gender)
{
break;
}
print_wait("Please input integer.");
}
// ---------- Reconfirm ----------
switch (input_judgment(true, true, "Are you sure you've filled in the information? (Y/N): "))
{
case -1:
free_ptr(student);
continue;
case 0:
print_wait("Canceled.");
free_ptr(student);
return;
case 1:
default:
break;
}
// ---------- Store Information ----------
if (!user_store(student))
{
print_wait("Canceled because save errors!");
free_ptr(student);
return;
}
// ---------- Print Information ----------
student->print_information();
print_wait("Created Successfully! Press any key to back...\n", false);
print_log("Create User.", severity_code_info, g_vector_login_info[0]);
// ---------- Finish ----------
free_ptr(student);
return;
}
default:
print_wait("Please input a correct option! ");
break;
}
}
}
/**
* **************************************************
*
* @brief print menu of delete account
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_account_delete()
{
while (true)
{
CLEAN;
// ---------- Start ----------
switch (input_judgment(true, true, "Do you want to delete user? (Y/N) "))
{
case -1:
continue;
case 0:
return;
case 1:
default:
break;
}
const char* user_id = input(MAXSIZE_INPUT_USER_ID, true, "Please input the User ID to be deleted: ");
// ---------- Reconfirm ----------
std::cout << "Are you sure you want to delete \"" << user_id << "\"? (Y/N)" << std::endl;
switch (input_judgment())
{
case 0:
print_wait("Cancel.");
case -1:
free_ptr(user_id, true);
continue;
case 1:
default:
break;
}
// ---------- Select ----------
auto* operation = user_select(user_id);
if (!operation->info_flag)
{
print_wait("Cancel, the user id not exists!");
free_ptr(operation);
break;
}
// ---------- Delete ----------
operation = user_delete(operation);
if (!operation->info_flag)
{
print_log("Failed to delete user.", severity_code_error);
print_wait("Failed to delete user.");
break;
}
// ---------- Finish ----------
std::cout << "Delete user id: " << user_id << std::endl;
print_wait("Delete user account Successfully!");
free_ptr(operation);
free_ptr(user_id, true);
}
}
/**
* **************************************************
*
* @brief print menu of creating administrative class
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_create_class()
{
while (true)
{
CLEAN;
// ---------- Start ----------
switch (input_judgment(true, true, "Do you want to create class? (Y/N) "))
{
case -1:
continue;
case 0:
return;
case 1:
default:
break;
}
auto* operation = new operation_info<class_info>;
// ---------- Input Administrative Class Id ----------
while (true)
{
operation->info_class->class_id = input(MAXSIZE_CLASS_ID, true, "Please input the id of administrative class (Digital Type): ");
if (is_positive_integer(operation->info_class->class_id))
{
// ---------- Select Class Id ----------
if (!class_select(operation->info_class->class_id)->info_flag)
{
break;
}
print_wait("Found uniform class id, please try again. ");
free_ptr(operation->info_class->class_id, true);
continue;
}
print_wait("Please input a correct option!");
free_ptr(operation->info_class->class_id, true);
}
// ---------- Input Administrator ----------
while (true)
{
operation->info_class->class_admin = input(MAXSIZE_INPUT_USER_ID, true, "Please select an administrator to manage administrative class: ");
// ---------- Select User ----------
auto* student = user_select(operation->info_class->class_admin);
if (student->info_flag)
{
if (1 == student->info_class->user_privilege)
{
free_ptr(student);
break;
}
print_wait("Select user not standard privilege, please try again. ");
free_ptr(student);
free_ptr(operation->info_class->class_admin, true);
continue;
}
print_wait("Not found user, please try again. ");
free_ptr(operation->info_class->class_admin, true);
}
// ---------- Reconfirm Administrator ----------
std::cout << "Are you sure you want to create class and make \"" << operation->info_class->class_admin << "\" to manage class \"" << operation->info_class->class_id << "\"? (Y/N) ";
switch (input_judgment())
{
case 0:
print_wait("Cancel.");
case -1:
free_ptr(operation);
continue;
case 1:
default:
break;
}
// ---------- Input Grade ----------
while (true)
{
char* tmp = input(4, true, "Please input the grade: ");
if (is_positive_integer(tmp))
{
operation->info_class->class_grade = strtol(tmp, nullptr, 0L);
free_ptr(tmp);
break;
}
free_ptr(tmp);
print_wait("Invalid scanning, please input again. ");
}
// ---------- Input Major ----------
operation->info_class->class_major = input(MAXSIZE_CLASS_MAJOR, true, "Please input the major name: ");
// ---------- Input Serial Class Id ----------
while (true)
{
char* tmp = input(2, true, "Please serial class number: ");
if (is_positive_integer(tmp))
{
operation->info_class->class_number = strtol(tmp, nullptr, 0L);
free_ptr(tmp);
break;
}
free_ptr(tmp);
print_wait("Invalid scanning, please input again. ");
}
// ---------- Reconfirm ----------
switch (input_judgment(true, true, "Are you sure you've finished? (Y/N) "))
{
case 0:
print_wait("Cancel.");
case -1:
free_ptr(operation);
continue;
case 1:
default:
break;
}
// ---------- Store Information ----------
class_store(operation->info_class);
// ---------- Print Information ----------
operation->info_class->print_info();
print_wait("Created class Successfully!");
// ---------- Finish ----------
print_log("Create class.", severity_code_info);
free_ptr(operation);
}
}
/**
* **************************************************
*
* @brief print menu of deleting administrative class
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_delete_class()
{
while (true)
{
CLEAN;
// ---------- Start ----------
switch (input_judgment(true, true, "Do you want to delete class? (Y/N) "))
{
case -1:
continue;
case 0:
return;
case 1:
default:
break;
}
auto* operation = class_select(input(MAXSIZE_CLASS_ID, true, "Please input the id of administrative class (Digital Type): "));
// ---------- Select ----------
if (!operation->info_flag)
{
print_wait("Cancel, the class id not exists!");
free_ptr(operation);
continue;
}
// ---------- Reconfirm ----------
std::cout << "Are you sure you want to delete class \"" << operation->info_class->class_id << "\"? (Y/N) " << std::endl;
switch (input_judgment())
{
case 0:
print_wait("Cancelled.");
case -1:
free_ptr(operation);
continue;
case 1:
default:
break;
}
// ---------- Delete ----------
operation = class_delete(operation);
if (!operation->info_flag)
{
print_log("Failed to delete class.", severity_code_error);
print_wait("Failed to delete class.");
free_ptr(operation);
continue;
}
// ---------- Finish ----------
print_wait("Deleted class Successfully!");
free_ptr(operation);
}
}
/**
* **************************************************
*
* @brief according magnitude to sorted exam record of student (sort from biggest to smallest)
*
* @param front_info (exam_record_info*) front class object
*
* @param rear_info (exam_record_info*) rear class object
*
* @return bool rear < front ?
*
* @retval true front > rear
*
* @retval false front < rear
*
* **************************************************
*/
bool sort_student_exam_record(exam_record_info* front_info, exam_record_info* rear_info)
{
return 0 <= front_info->score_average - rear_info->score_average;
}
/**
* **************************************************
*
* @brief create a comprehensive examination
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_exam_create_comprehensive_examination()
{
while (true)
{
CLEAN;
// ---------- Start ----------
switch (input_judgment(true, true, "Do you want to create comprehensive examination? (Y/N) "))
{
case -1:
continue;
case 0:
return;
case 1:
default:
break;
}
auto* operation = new operation_info<exam_info>;
// 日期时间 (Date-time)
operation->info_class->date_time = input_datetime();
// 自动添加创建者 (Creator or administrator)
char* tmp_admin = new char[strlen(g_vector_login_info[0]) + 1];
strcpy_s(tmp_admin, strlen(g_vector_login_info[0]) + 1, g_vector_login_info[0]);
operation->info_class->admin = tmp_admin;
// 考生人数 (Count Students)
while (true)
{
std::string tmp = input(3, true, "Please input amount of students: ");
if (is_positive_integer(tmp.c_str()))
{
operation->info_class->count_student = strtol(tmp.c_str(), nullptr, 0L);
break;
}
print_wait("Please input correctly.");
}
// 应考科目数 (Count majors)
while (true)
{
std::string tmp = input(2, true, "Please input amounts of subject: ");
if (is_positive_integer(tmp.c_str()))
{
operation->info_class->count_subject = strtol(tmp.c_str(), nullptr, 0L);
break;
}
print_wait("Please input amounts of major.");
}
// 科目编号 (Major serial number)
for (int i = 0; i < operation->info_class->count_subject; i++)
{
std::cout << "Please set the " << i + 1 << " serial id/name of subject: ";
operation->info_class->vector_subject_serial_number.emplace_back(input(4));
}
// 考生记录 (Examination records of student)
for (int i = 0; i < operation->info_class->count_student; i++)
{
auto* tmp_student_exam_record = new exam_record_info;
while (true)
{
std::cout << "Please input the " << i + 1 << " student id: ";
char* input_student_id = input(MAXSIZE_STUDENT_ID);
auto* tmp_operation = user_select(input_student_id, 2);
if (tmp_operation->info_flag)
{
tmp_student_exam_record->student_name = new char[strlen(tmp_operation->info_class->name) + 1];
strcpy_s(tmp_student_exam_record->student_name, strlen(tmp_operation->info_class->name) + 1, tmp_operation->info_class->name);
tmp_student_exam_record->student_id = input_student_id;
tmp_student_exam_record->class_id = new char[strlen(tmp_operation->info_class->class_id) + 1];
strcpy_s(tmp_student_exam_record->class_id, strlen(tmp_operation->info_class->class_id) + 1, tmp_operation->info_class->class_id);
free_ptr(tmp_operation);
break;
}
print_wait("Not found user. Please try input again.");
}
// 循环录入每科成绩 (Recycle entry of each subject score)
for (int j = 0; j < operation->info_class->count_subject; j++)
{
std::cout << "Please input the score of \"" << operation->info_class->vector_subject_serial_number[j] << "\": ";
double tmp_score = 0;
while (true)
{
char* tmp = input(MAXSIZE_BUFF);
if (std::regex_match(tmp, std::regex("^([1-9][0-9]*)+(\\.[0-9]{1,2})?$")))
{
tmp_score = strtod(tmp, nullptr);
free_ptr(tmp, true);
break;
}
print_wait("Please input correct number!");
}
tmp_student_exam_record->score_average += tmp_score;
tmp_student_exam_record->vector_score_subject.emplace_back(tmp_score);
if (0 == i)
{
operation->info_class->vector_subject_average_score.emplace_back(tmp_score);
}
else
{
operation->info_class->vector_subject_average_score[j] += tmp_score;
}
}
if (0 != operation->info_class->count_student && 0 != operation->info_class->count_subject)
{
// 自动统计单个学生平均总分 (Calculate the average total score of each student)
tmp_student_exam_record->score_average /= operation->info_class->count_subject;
// 自动累加全部学生总分 (Add up the total score of all students)
operation->info_class->average_score += tmp_student_exam_record->score_average;
}
// 存入考试记录对象 (Save the test record object)
operation->info_class->vector_student_exam_record.emplace_back(tmp_student_exam_record);
}
// 自动计算全部考生总平均成绩 (Calculate the average score of all candidates)
operation->info_class->average_score /= operation->info_class->count_student;
// 自动计算每科平均成绩 (Calculate the average grade of each subject)
for (int i = 0; i < operation->info_class->count_subject; i++)
{
operation->info_class->vector_subject_average_score[i] /= operation->info_class->count_student;
}
// 自动排名 (Rankings)
std::sort(operation->info_class->vector_student_exam_record.begin(), operation->info_class->vector_student_exam_record.end(), sort_student_exam_record);
for (int i = 0; i < operation->info_class->count_student; i++)
{
if (!operation->info_class->vector_student_exam_record.empty())
{
operation->info_class->vector_student_exam_record[i]->rankings = i + 1;
}
}
// ---------- Reconfirm ----------
switch (input_judgment(true, true, "Are you confirm finish? (Y/N) "))
{
case 0:
print_wait("Cancelled.");
case -1:
return;
case 1:
default:
break;
}
// ---------- Store ----------
if (!exam_store(operation->info_class))
{
free_ptr(operation);
print_wait("Save exam record failed.");
print_log("Failed to create exam. ", severity_code_error);
continue;
}
// ---------- Finish ----------
CLEAN;
operation->info_class->print_exam();
free_ptr(operation);
print_wait("Create examination successfully!");
print_log("Create comprehensive examination successfully.", severity_code_info);
}
}
/**
* **************************************************
*
* @brief Single subject examination, including detailed examination conditions
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_exam_create_selective_examination()
{
// TODO 选择性考试类型(还没实现,其实就是单科考试的意思,涵盖了考试每个人的大题得分情况)
print_wait("Nothing.");
}
/**
* **************************************************
*
* @brief create an exam
*
* @param menus (menu&) menu
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_exam_create(menu& menus)
{
while (true)
{
CLEAN;
print_menu(true, 1, menus.vector_menu_exam_type, "Please select a type of exam: ");
switch (input_option(static_cast<int>(menus.vector_menu_exam_type.size())))
{
case 0:
return;
case 1:
print_menu_admin_exam_create_comprehensive_examination();
return;
case 2:
print_menu_admin_exam_create_selective_examination();
return;
default:
print_wait("Please select an option!");
break;
}
}
}
/**
* **************************************************
*
* @brief alert student scores
*
* @param menus (menu&) menu
*
* @retval None
*
* **************************************************
*/
void print_menu_admin_exam_update(menu& menus)
{
while (true)
{
CLEAN;
// ---------- Start ----------
switch (input_judgment(true, true, "Do you want to update scores of student? (Y/N)"))
{
case -1:
continue;
case 0:
return;
case 1:
default:
break;
}
char* student_id;
char* datetime_start;
char* datetime_end;
operation_info<exam_info*>* operation;
while (true)
{
// ---------- Input Student Id ----------
while (true)
{
student_id = input(MAXSIZE_STUDENT_ID, true, "Please input Student Id: ");
if (std::regex_match(student_id, std::regex("^[0-9]\\d*$")))
{
break;
}
print_wait("Illegally student id input!");
free_ptr(student_id, true);
}
// ---------- Input start datetime of exam ----------
while (true)
{
datetime_start = input(MAXSIZE_DATETIME_LENGTH, true, "Please input start datetime: ");
if (0 == strcmp(trim(datetime_start).c_str(), "all"))
{
break;
}
if (MAXSIZE_DATETIME_LENGTH == strlen(datetime_start) && std::regex_match(datetime_start, std::regex("^[1-9]\\d*$")))
{
break;
}
print_wait("Illegally start datetime input!");
free_ptr(datetime_start, true);
}
// ---------- Input end datetime of exam ----------
while (true)
{
datetime_end = input(MAXSIZE_DATETIME_LENGTH, true, "Please input end datetime: ");
if (0 == strcmp(trim(datetime_end).c_str(), "all"))
{
break;
}
if (MAXSIZE_DATETIME_LENGTH == strlen(datetime_end) && std::regex_match(datetime_end, std::regex("^[1-9]\\d*$")))
{
break;
}
print_wait("Illegally end datetime input!");
free_ptr(datetime_end, true);
}
// ---------- Select ----------
operation = exam_select(const_cast<const char*>(student_id), datetime_start, datetime_end);
if (!operation->info_vector_class.empty())
{
break;
}
free_ptr(datetime_end, true);
free_ptr(datetime_start, true);
free_ptr(student_id, true);
free_ptr(operation);
std::cout << "Not found user." << std::endl;
switch (input_judgment(true, true, "Do you want to try again? (Y/N)"))
{
case -1:
print_wait("Illegally input, cancelled.");
return;
case 0:
print_wait("Cancelled.");
return;
case 1:
default:
break;
}
}
// ---------- Print Old Exam ----------
if (1 == input_judgment(true, true, "Print out all exam? (Y/N)"))
{
for (const auto& tmp : operation->info_vector_class)
{
tmp->print_exam();
printf_s("\n\n");
}
}
char* subject_serial_id;
char* student_new_score;
while (true)
{
// ---------- Input Subject Name ----------
subject_serial_id = input(6, true, "Please input subject serial id: ");
// ---------- Input New Score ----------
while (true)
{
student_new_score = input(6, true, "Please input new score: ");
if (std::regex_match(student_new_score, std::regex("^[0-9]+(\\.[0-9]{2})?$")))
{
break;
}
print_wait("Illegally input!");
free_ptr(student_new_score, true);
}
operation = exam_update(operation, student_id, subject_serial_id, strtod(student_new_score, nullptr));
if (operation->info_flag)
{
break;
}
print_wait("Not found or Cannot update score.");
free_ptr(student_new_score, true);
free_ptr(subject_serial_id, true);
}
int count_alter_success_file = 0;
// ---------- Store ----------
for (unsigned int i = 0; i < operation->info_vector_class.size(); i++)
{
try
{
if (exam_store(operation->info_vector_class[i], operation->info_vector_path[i]))
{
count_alter_success_file++;
}
}
catch (...)
{
print_log("Error to save alter file.");
}
}
// ---------- Print New Exam ----------
if (1 == input_judgment(true, true, "Print out all exam? (Y/N)"))
{
for (const auto& tmp : operation->info_vector_class)
{
tmp->print_exam();
printf_s("\n\n");
}
}
std::cout << "Student ID: " << student_id << std::endl;
std::cout << "Subject: " << subject_serial_id << std::endl;
std::cout << "New Score: " << student_new_score << std::endl;
std::cout << "All files: " << operation->info_vector_class.size() << std::endl;
std::cout << "Success: " << count_alter_success_file << "\t" << "Failed: " << operation->info_vector_class.size() - count_alter_success_file << std::endl;
print_wait("Operation success!");
free_ptr(student_id, true);
free_ptr(student_new_score, true);
free_ptr(subject_serial_id, true);
free_ptr(datetime_start, true);
free_ptr(datetime_end, true);
free_ptr(operation);
}
}