From e27aaccb45cb9afc5f9f024633833714c9f5991f Mon Sep 17 00:00:00 2001 From: "rogan.dawes" Date: Wed, 18 Jul 2007 13:29:53 +0000 Subject: [PATCH] Make multi-stage lessons show the individual stages in the menu While we are about it, make AbstractLesson.getLink() include the category (i.e. menu), so that the menu selection script will still work. git-svn-id: http://webgoat.googlecode.com/svn/trunk@183 4033779f-a91e-0410-96ef-6bf7bf53c507 --- .../owasp/webgoat/lessons/AbstractLesson.java | 5 +- webgoat/main/project/WebContent/main.jsp | 71 ++++++------------- 2 files changed, 25 insertions(+), 51 deletions(-) diff --git a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/AbstractLesson.java b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/AbstractLesson.java index be8b5c94f..531dcf367 100644 --- a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/AbstractLesson.java +++ b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/AbstractLesson.java @@ -575,7 +575,10 @@ public abstract class AbstractLesson extends Screen implements Comparable link.append(WebSession.SCREEN); link.append("="); link.append(getScreenId()); - + link.append("&"); + link.append(WebSession.MENU); + link.append("="); + link.append(getCategory().getRanking()); return link.toString(); } diff --git a/ webgoat/main/project/WebContent/main.jsp b/ webgoat/main/project/WebContent/main.jsp index 3d336f463..4a10ce30c 100644 --- a/ webgoat/main/project/WebContent/main.jsp +++ b/ webgoat/main/project/WebContent/main.jsp @@ -8,7 +8,6 @@ AbstractLesson currentLesson = webSession.getCurrentLesson(); %> -<%@page import="org.owasp.webgoat.lessons.SequentialLessonAdapter"%> <%@page import="org.owasp.webgoat.lessons.RandomLessonAdapter"%> @@ -25,15 +24,13 @@ AbstractLesson currentLesson = webSession.getCurrentLesson(); <% -final String menuPrefix = "menu"; +final String menuPrefix = WebSession.MENU; final String submenuPrefix = "submenu"; final String mbutPrefix = "mbut"; String printHint = ""; String printParameters = ""; String printCookies = ""; String lessonComplete = ""; -String m = "menu"; -String menu = request.getParameter(m); List categories = course.getCategories(); @@ -58,7 +55,7 @@ StringBuffer buildList = new StringBuffer(); if (iter1.hasNext()) buildList.append(","); }%> - +
<% @@ -96,8 +93,20 @@ StringBuffer buildList = new StringBuffer(); AbstractLesson lesson = (AbstractLesson)iter4.next(); %> - <%=(lesson.isCompleted(webSession) ? lessonComplete : "")%><%=lesson.getTitle()%> - <% + <%=(lesson.isCompleted(webSession) ? lessonComplete : "")%><%=lesson.getTitle()%> + + <% if (lesson instanceof RandomLessonAdapter) { + RandomLessonAdapter rla = (RandomLessonAdapter) lesson; + String[] stages = rla.getStages(); + for (int i=0; i + <%=stages[i] %> + + <% + } + } + %> +<% } %> @@ -113,28 +122,28 @@ StringBuffer buildList = new StringBuffer(); if (webSession.isAuthorizedInLesson(webSession.getRole(), WebSession.SHOWHINTS)) { %> - Previous Hint - Hints - Next Hint <%}%> - Show Params - Show Cookies @@ -198,44 +207,6 @@ StringBuffer buildList = new StringBuffer();
Close this Window
- <% - AbstractLesson al = webSession.getCurrentLesson(); - if (!al.isCompleted(webSession)) - { - if (al instanceof SequentialLessonAdapter) - { - SequentialLessonAdapter sla = (SequentialLessonAdapter) al; - if (webSession.isDebug()&& sla.getStageCount() > 1) { - %>
-
<% - } - } - else if (al instanceof RandomLessonAdapter) - { - RandomLessonAdapter rla = (RandomLessonAdapter) al; - String[] stages = rla.getStages(); - if (stages != null && stages.length > 0) { - %>
-
<% - } - } - } - %>
<%=webSession.getInstructions()%>
<%=webSession.getMessage()%>