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