3
3
import java .security .MessageDigest ;
4
4
import java .time .*;
5
5
6
- /**
7
- *
8
- * PracticeItGrader
9
- *
10
- * Usage:
11
- * Called with just "practice-it.csv" (CSV file generated by PracticeIt)
12
- * Writes list of students
13
- * Remove any unwanted students and supply next time to filter list
14
- *
15
- * Called with raw results & "Student Usernames.txt"
16
- * Writes filtered list of students and their problems
17
- * Modify desired problems and save as "Assigned problems.txt"
18
- *
19
- * Called with raw results, student usernames, "Assigned problems.txt"
20
- * Looks for header "SC" and all following problems will be assumed SC
21
- * any other header is assumed to be "Ex"
22
- * Writes filtered list of students with how they did on assigned problems
23
- *
24
- * Note Chapter 3G translated into 20, letter problems (11a) add 100
25
- *
26
- * @author George Hu
27
- *
28
- * Version 1.0 - 4/14/18 initial version
29
- * Version 1.1 - 4/26/18 fixed chapter 3G -> 20, 11a/b/c -> 111/2/3
30
- * Version 1.2 - 5/29/18 added totals to Missing/Failed/Extras
31
- * Version 1.2.1 - 10/11/18 fixed first names with a single space in them e.g "Mary Jo"
32
- * Version 1.3 - 12/30/18 Split out Problem & Student into their own files &
33
- * changed static student & problem data structures to locals passed as parameters
34
- * Version 1.3.1 - 12/30/18 added ifEncrypt to scramble student usernames
35
- * Version 1.4 - 12/30/18 added dtDeadline to count problems by deadline
36
- * Version 1.4.1 - 2/10/19 dtDeadline only counts assigned & drops "T<HH:MM:SS>"
37
- * Version 1.5 - 9/30/19 - updated comments to support Problem.java v1.5 changes
38
- * Version 1.5.1 - 4/15/20 - added a check for problems older than a week before deadline
39
- * Version 1.5.2 - 4/15/20 - determined time spent on each problem
40
- * Version 2.0 - 5/30/20 added cheat checks for tries, times, code hash, red flags
41
- * Version 2.0.1 - 5/31/20 cleanup - added Flag class, catch null pointers
42
- * Version 2.0.2 - 6/5/20 print cleanup
43
- * Version 2.0.3 - 6/6/20 removed filters for code size & uniqueness
44
- */
45
6
public class PracticeItGrader {
46
7
// Set to true to output diagnostic debugging info
47
8
static boolean ifDebug = false ;
@@ -74,18 +35,6 @@ public static void main(String[] args) throws FileNotFoundException {
74
35
printResults (ifClassList , problemList , studentList );
75
36
}
76
37
77
- /**
78
- * printResults - prints the results from class members
79
- *
80
- * @param ifClassList - if false, just print the list of students
81
- * @param problemList - list of assigned problems
82
- * @param studentList - list of students, each with an embedded list of problems attempted
83
- *
84
- * username firstname Lastname #15 Attempted 2 of 12
85
- * Missing: SC 10:16 SC 10:18 Ex 10:2 Ex 10:3 Ex 10:4 Ex 10:6 Ex 10:7 Ex 10:10 Ex 10:12 Ex 10:14 Ex 10:15
86
- * Failed: SC 10:8
87
- * Extras: SC 10:2
88
- */
89
38
public static void printResults (Boolean ifClassList , ArrayList <Problem > problemList , ArrayList <Student > studentList ) {
90
39
// Output class list
91
40
int iStudent = 1 ;
@@ -95,9 +44,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
95
44
System .out .println ("printResults Begin" );
96
45
}
97
46
98
- /////////////////////////////////////////////////////////////////////
99
- // Process each Student
100
- /////////////////////////////////////////////////////////////////////
101
47
for (Student s : studentList ) {
102
48
// Always print out the student usernames, if no class list this is all we'll do
103
49
System .out .printf ("%s %s %s #%d " ,
@@ -121,16 +67,9 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
121
67
// This is a list of all problem submission times
122
68
LinkedList <LocalDateTime > dates = new LinkedList <>();
123
69
124
- /////////////////////////////////////////////////////////////
125
- // Process each problem for printing
126
- /////////////////////////////////////////////////////////////
127
70
for (int iProblem = 0 ; iProblem <s .getProblems ().size (); iProblem ++) {
128
71
Problem p = s .getProblems ().get (iProblem );
129
72
130
- //////////////////////////////////////////////////////////
131
- // Cheat Checking - transfer each student's problem info to
132
- // whole class' list of assigned problems
133
- //////////////////////////////////////////////////////////
134
73
int indexAssignedProblem = problemList .indexOf (p );
135
74
if (indexAssignedProblem != -1 ) {
136
75
Problem assignedProblem = problemList .get (indexAssignedProblem );
@@ -194,14 +133,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
194
133
" done before " + dtStart .toString ().substring (0 ,10 ));
195
134
}
196
135
197
- ///////////////////////////////////////////////////////////////
198
- // Store problem times
199
- //
200
- // Find length of time to complete each problem for later comparison to others
201
- // We can only do this once all problems are read by sorting & subtracting
202
- // We will store a 0 second duration to mark the first problem
203
- // Problems with a long delay will be filtered out when checking for cheaters
204
- ///////////////////////////////////////////////////////////////
205
136
Collections .sort (dates );
206
137
LocalDateTime dtCurrent = null ;
207
138
if (!dates .isEmpty ())
@@ -223,12 +154,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
223
154
224
155
} // done with all students
225
156
226
- ////////////////////////////////////////////////////////////////////
227
- // Cheating Checks
228
- //
229
- // We're done processing all student problems
230
- // Do cheating checks for each problem based on student -> code hashes & times
231
- ////////////////////////////////////////////////////////////////////
232
157
System .out .println ("******** BY PROBLEM ANALYSIS **********" );
233
158
for (Problem p : problemList ) {
234
159
@@ -240,12 +165,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
240
165
// if (Problem.fInProblem(p, 9, 2))
241
166
// System.out.println("Breakpoint");
242
167
243
- ///////////////////////////////////////////////////////////////
244
- // Check for signs of cheating by abnormally low times
245
- // check for times < 1/2 of the median
246
- // exclude first problems (0 time) and > 60 min
247
- ///////////////////////////////////////////////////////////////
248
-
249
168
String result = "" ;
250
169
boolean fPrintedTimes = false ;
251
170
@@ -301,10 +220,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
301
220
if (fPrintedTimes )
302
221
System .out .print (result );
303
222
304
- //////////////////////////////////////////////////////////////////
305
- // Looking for abnormally low # of tries
306
- // check for < 1/2 of the median # of tries
307
- //////////////////////////////////////////////////////////////////
308
223
boolean fPrintedTries = false ;
309
224
result = null ;
310
225
@@ -334,11 +249,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
334
249
if (fPrintedTries )
335
250
System .out .print (result );
336
251
337
- //////////////////////////////////////////////////////////////////
338
- // Looking for duplicate code in exercises
339
- // check for exact code matches
340
- // Can't detect modified code but tries, times, red flags will add up
341
- //////////////////////////////////////////////////////////////////
342
252
Map <String , Integer > hashesMap = p .getCodeHash ();
343
253
344
254
// only look for duplicates if 3/4th are unique
@@ -374,11 +284,7 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
374
284
} // looking for duplicate code hash
375
285
if ((fPrintedTimes || fPrintedTries ) && p .getTimes ().size () != 0 )
376
286
System .out .println (); // separating line per problem if we've printed
377
- } // end of all Problems
378
-
379
- /////////////////////////////////////////////////////////////////////
380
- // print out the cheater scores
381
- /////////////////////////////////////////////////////////////////////
287
+ }
382
288
383
289
// Sort by cheater scores
384
290
// This uses a anonymous class instead of creating a separate comparator class
@@ -422,13 +328,6 @@ public int compare(Student s1, Student s2) {
422
328
}
423
329
} // end PrintResults
424
330
425
- /**
426
- * Flag a student for cheating
427
- *
428
- * @param studentList
429
- * @param cheaterName
430
- * @param reason - string reason for the flag
431
- */
432
331
public static void flagCheater (ArrayList <Student > studentList , String cheaterName , Problem p , String reason ) {
433
332
int seriousness = 0 ;
434
333
// Increase student's cheating index
@@ -452,18 +351,8 @@ public static void flagCheater(ArrayList<Student> studentList, String cheaterNam
452
351
if (!reason .equals ("red flag" ) || !s .getFlags ().contains (f ))
453
352
s .getFlags ().add (f );
454
353
}
455
- } // end flagCheater
354
+ }
456
355
457
- /**
458
- * Prepare groups of users who duplicated code from map of <UserName, CodeHash>
459
- * This was parameterized to accept other flag types but not currently used except for int
460
- *
461
- * input - [john=1, mary=2, phil=3, doug=2, jo=1, jerry=2]
462
- * output - [1=[john, jo], 2=[mary, doug], 3=phil]
463
- *
464
- * @param input - map of <UserName, flag> flag could be any type but typically int
465
- * @return output - Map of <flag, List of Username>
466
- */
467
356
public static <T extends Comparable <T >> Map <T , ArrayList <String >> findCommonFlags (Map <String , T > input ) {
468
357
List <Map .Entry <String , T >> listNameToFlag = new ArrayList <> (input .entrySet ());
469
358
listNameToFlag .sort (Map .Entry .comparingByValue ());
@@ -493,17 +382,6 @@ public static <T extends Comparable<T>> Map<T, ArrayList<String>> findCommonFlag
493
382
return mapFlagToNames ;
494
383
}
495
384
496
- /**
497
- * Print cheating report for a student
498
- *
499
- * userName index <cheating rating>
500
- * code: Ex 10:7 Ex 11:7 Ex 12:18
501
- * Times: Ex 11:19 SC 12:6 Ex 12:18
502
- * red flag: Ex 12:18
503
- * Tries: Ex 11:19 Ex 12:18
504
- *
505
- * @param s - student which contains details on cheating
506
- */
507
385
public static void printStudentCheatingReport (Student s ) {
508
386
if (s .cheatingIndex == 0 )
509
387
return ;
@@ -523,9 +401,8 @@ public static void printStudentCheatingReport(Student s) {
523
401
System .out .printf (problemNum );
524
402
System .out .println (); // new line for each reason
525
403
}
526
- }
527
-
528
- } // end PracticeItGrader
404
+ }
405
+ }
529
406
530
407
531
408
0 commit comments