Skip to content

Commit 7246a1a

Browse files
Update practiceItgrader.java
1 parent 64420e0 commit 7246a1a

File tree

1 file changed

+4
-127
lines changed

1 file changed

+4
-127
lines changed

Diff for: practiceItgrader.java

+4-127
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,6 @@
33
import java.security.MessageDigest;
44
import java.time.*;
55

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-
*/
456
public class PracticeItGrader {
467
// Set to true to output diagnostic debugging info
478
static boolean ifDebug = false;
@@ -74,18 +35,6 @@ public static void main(String[] args) throws FileNotFoundException {
7435
printResults(ifClassList, problemList, studentList);
7536
}
7637

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-
*/
8938
public static void printResults(Boolean ifClassList, ArrayList<Problem> problemList, ArrayList<Student> studentList) {
9039
// Output class list
9140
int iStudent = 1;
@@ -95,9 +44,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
9544
System.out.println("printResults Begin");
9645
}
9746

98-
/////////////////////////////////////////////////////////////////////
99-
// Process each Student
100-
/////////////////////////////////////////////////////////////////////
10147
for (Student s : studentList) {
10248
// Always print out the student usernames, if no class list this is all we'll do
10349
System.out.printf("%s %s %s #%d ",
@@ -121,16 +67,9 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
12167
// This is a list of all problem submission times
12268
LinkedList<LocalDateTime> dates = new LinkedList<>();
12369

124-
/////////////////////////////////////////////////////////////
125-
// Process each problem for printing
126-
/////////////////////////////////////////////////////////////
12770
for (int iProblem = 0; iProblem<s.getProblems().size(); iProblem++) {
12871
Problem p = s.getProblems().get(iProblem);
12972

130-
//////////////////////////////////////////////////////////
131-
// Cheat Checking - transfer each student's problem info to
132-
// whole class' list of assigned problems
133-
//////////////////////////////////////////////////////////
13473
int indexAssignedProblem = problemList.indexOf(p);
13574
if (indexAssignedProblem != -1) {
13675
Problem assignedProblem = problemList.get(indexAssignedProblem);
@@ -194,14 +133,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
194133
" done before " + dtStart.toString().substring(0,10));
195134
}
196135

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-
///////////////////////////////////////////////////////////////
205136
Collections.sort(dates);
206137
LocalDateTime dtCurrent = null;
207138
if (!dates.isEmpty())
@@ -223,12 +154,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
223154

224155
} // done with all students
225156

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-
////////////////////////////////////////////////////////////////////
232157
System.out.println("******** BY PROBLEM ANALYSIS **********");
233158
for (Problem p : problemList) {
234159

@@ -240,12 +165,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
240165
// if (Problem.fInProblem(p, 9, 2))
241166
// System.out.println("Breakpoint");
242167

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-
249168
String result = "";
250169
boolean fPrintedTimes = false;
251170

@@ -301,10 +220,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
301220
if (fPrintedTimes)
302221
System.out.print(result);
303222

304-
//////////////////////////////////////////////////////////////////
305-
// Looking for abnormally low # of tries
306-
// check for < 1/2 of the median # of tries
307-
//////////////////////////////////////////////////////////////////
308223
boolean fPrintedTries = false;
309224
result = null;
310225

@@ -334,11 +249,6 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
334249
if (fPrintedTries)
335250
System.out.print(result);
336251

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-
//////////////////////////////////////////////////////////////////
342252
Map<String, Integer> hashesMap = p.getCodeHash();
343253

344254
// only look for duplicates if 3/4th are unique
@@ -374,11 +284,7 @@ public static void printResults(Boolean ifClassList, ArrayList<Problem> problemL
374284
} // looking for duplicate code hash
375285
if ((fPrintedTimes || fPrintedTries) && p.getTimes().size() != 0)
376286
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+
}
382288

383289
// Sort by cheater scores
384290
// This uses a anonymous class instead of creating a separate comparator class
@@ -422,13 +328,6 @@ public int compare(Student s1, Student s2) {
422328
}
423329
} // end PrintResults
424330

425-
/**
426-
* Flag a student for cheating
427-
*
428-
* @param studentList
429-
* @param cheaterName
430-
* @param reason - string reason for the flag
431-
*/
432331
public static void flagCheater(ArrayList<Student> studentList, String cheaterName, Problem p, String reason) {
433332
int seriousness = 0;
434333
// Increase student's cheating index
@@ -452,18 +351,8 @@ public static void flagCheater(ArrayList<Student> studentList, String cheaterNam
452351
if (!reason.equals("red flag") || !s.getFlags().contains(f))
453352
s.getFlags().add(f);
454353
}
455-
} // end flagCheater
354+
}
456355

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-
*/
467356
public static <T extends Comparable<T>> Map<T, ArrayList<String>> findCommonFlags(Map<String, T> input) {
468357
List<Map.Entry<String, T>> listNameToFlag = new ArrayList<> (input.entrySet());
469358
listNameToFlag.sort(Map.Entry.comparingByValue());
@@ -493,17 +382,6 @@ public static <T extends Comparable<T>> Map<T, ArrayList<String>> findCommonFlag
493382
return mapFlagToNames;
494383
}
495384

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-
*/
507385
public static void printStudentCheatingReport(Student s) {
508386
if (s.cheatingIndex == 0)
509387
return;
@@ -523,9 +401,8 @@ public static void printStudentCheatingReport(Student s) {
523401
System.out.printf(problemNum);
524402
System.out.println(); // new line for each reason
525403
}
526-
}
527-
528-
} // end PracticeItGrader
404+
}
405+
}
529406

530407

531408

0 commit comments

Comments
 (0)