#277 Re-institute admin functionality for WebGoat 8
- Report card functionality is back
This commit is contained in:
@ -89,5 +89,14 @@ public class Course {
|
||||
this.lessons = lessons;
|
||||
}
|
||||
|
||||
public int getTotalOfLessons() {
|
||||
return this.lessons.size();
|
||||
}
|
||||
|
||||
public int getTotalOfAssignments() {
|
||||
final int[] total = {0};
|
||||
this.lessons.stream().forEach(l -> total[0] = total[0] + l.getAssignments().size());
|
||||
return total[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,12 +4,14 @@ package org.owasp.webgoat.session;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.SneakyThrows;
|
||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||
import org.owasp.webgoat.lessons.Assignment;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@ -104,4 +106,23 @@ public class UserTracker {
|
||||
getLessonTracker(al).reset();
|
||||
save();
|
||||
}
|
||||
|
||||
public int numberOfLessonsSolved() {
|
||||
int numberOfLessonsSolved = 0;
|
||||
for(LessonTracker lessonTracker : storage.values()) {
|
||||
if (lessonTracker.isLessonSolved()) {
|
||||
numberOfLessonsSolved = numberOfLessonsSolved + 1;
|
||||
}
|
||||
}
|
||||
return numberOfLessonsSolved;
|
||||
}
|
||||
|
||||
public int numberOfAssignmentsSolved() {
|
||||
int numberOfAssignmentsSolved = 0;
|
||||
for (LessonTracker lessonTracker : storage.values()) {
|
||||
Map<Assignment, Boolean> lessonOverview = lessonTracker.getLessonOverview();
|
||||
numberOfAssignmentsSolved = lessonOverview.values().stream().filter(b -> b).collect(Collectors.counting()).intValue();
|
||||
}
|
||||
return numberOfAssignmentsSolved;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user