MCPcopy Create free account
hub / github.com/OWASP/SecurityShepherd / getIncrementalModules

Method getIncrementalModules

src/main/java/dbProcs/Getter.java:626–715  ·  view source on GitHub ↗

This method prepares the incremental module menu. This is when Security Shepherd is in "Game Mode". Users are presented with one uncompleted module at a time. This method also returns a script to be executed every time the menu is chanegd. This is script defines the animation and operations to be ca

(String ApplicationRoot, String userId, String lang, String csrfToken)

Source from the content-addressed store, hash-verified

624 * @return A HTML menu of a users current module progress and a script for interaction with this menu
625 */
626 public static String getIncrementalModules (String ApplicationRoot, String userId, String lang, String csrfToken)
627 {
628 log.debug("*** Getter.getIncrementalChallenges ***");
629 String output = new String();
630 Connection conn = Database.getCoreConnection(ApplicationRoot);
631
632 Locale.setDefault(new Locale("en"));
633 Locale locale = new Locale(lang);
634 ResourceBundle bundle = ResourceBundle.getBundle("i18n.text", locale);
635 ResourceBundle levelNames = ResourceBundle.getBundle("i18n.moduleGenerics.moduleNames", locale);
636
637 try
638 {
639 CallableStatement callstmt = conn.prepareCall("call moduleIncrementalInfo(?)");
640 callstmt.setString(1, userId);
641 log.debug("Gathering moduleIncrementalInfo ResultSet");
642 ResultSet modules = callstmt.executeQuery();
643 log.debug("Opening Result Set from moduleIncrementalInfo");
644 boolean lastRow = false;
645 boolean completedModules = false;
646
647
648 //Preparing first Category header; "Completed"
649 output = "<li><a id='completedList' href='javascript:;'><div class='menuButton'>" + bundle.getString("getter.button.completed") + "</div></a>\n" +
650 "<ul id='theCompletedList' style='display: none;' class='levelList'>";
651
652 while(modules.next() && !lastRow)
653 {
654 //For each row, prepair the modules the users can select
655 if(modules.getString(4) != null) //If not Last Row
656 {
657 completedModules = true;
658 output += "<li>";
659 output += "<a class='lesson' id='"
660 + Encode.forHtmlAttribute(modules.getString(3))
661 + "' href='javascript:;'>"
662 + Encode.forHtml(levelNames.getString(modules.getString(1)))
663 + "</a>";
664 output += "</li>";
665 }
666 else
667 {
668 lastRow = true;
669 //Last Row - Highlighed Next Challenge
670 if(completedModules)
671 {
672 output += "</ul></li><li>";
673 }
674 else
675 {
676 //NO completed modules, so dont show any...
677 output = new String();
678 }
679
680 //Second category - Uncompleted
681 output += "<a class='lesson' id='"
682 + Encode.forHtmlAttribute(modules.getString(3))
683 + "' href='javascript:;'>"

Calls 2

getCoreConnectionMethod · 0.95
closeConnectionMethod · 0.95