Merge pull request #98 from misfir3/master
#97, Hint controls for CHALLENGE Category lessons
This commit is contained in:
commit
e13c959990
@ -1,6 +1,7 @@
|
||||
package org.owasp.webgoat.lessons.model;
|
||||
|
||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||
import org.owasp.webgoat.lessons.Category;
|
||||
import org.owasp.webgoat.session.WebSession;
|
||||
|
||||
/**
|
||||
@ -20,20 +21,15 @@ public class LessonInfoModel {
|
||||
public LessonInfoModel(WebSession webSession) {
|
||||
AbstractLesson lesson = webSession.getCurrentLesson();
|
||||
//TODO make these first class citizens of the lesson itself; and stop passing the session all over
|
||||
// this.source = (lesson.getSource(webSession));
|
||||
// this.plan = (lesson.getPage(webSession));
|
||||
// this.solution = (lesson.getSolution(webSession));
|
||||
|
||||
this.hasSource = !lesson.getSource(webSession).contains("Could not find the source file or source file does not exist");
|
||||
this.hasPlan = !lesson.getSource(webSession).contains("Could not find lesson plan");
|
||||
this.hasSolution = !lesson.getSolution(webSession).contains("Could not find the solution file or solution file does not exist");
|
||||
this.lessonTitle = lesson.getTitle();
|
||||
|
||||
this.numberHints = lesson.getHintCount(webSession);
|
||||
|
||||
if (this.numberHints == 1 && lesson.getHint(webSession,0).equals("Hint: There are no hints defined.")){
|
||||
if (lesson.getCategory().equals(Category.CHALLENGE) || this.numberHints < 1 || lesson.getHint(webSession,0).equals("Hint: There are no hints defined.")) {
|
||||
this.numberHints = 0;
|
||||
}
|
||||
System.out.println("*** numHints = " + this.numberHints);
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
|
@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||
import org.owasp.webgoat.lessons.Category;
|
||||
import org.owasp.webgoat.lessons.model.Hint;
|
||||
import org.owasp.webgoat.session.WebSession;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -40,11 +41,12 @@ public class HintService extends BaseService {
|
||||
if (l == null) {
|
||||
return listHints;
|
||||
}
|
||||
List<String> hints;
|
||||
hints = l.getHintsPublic(ws);
|
||||
List<String> hints = (l.getCategory().equals(Category.CHALLENGE)) ? null : l.getHintsPublic(ws);
|
||||
|
||||
if (hints == null) {
|
||||
return listHints;
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
for (String h : hints) {
|
||||
Hint hint = new Hint();
|
||||
|
Loading…
x
Reference in New Issue
Block a user