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

Method getProgress

src/main/java/dbProcs/Getter.java:1532–1574  ·  view source on GitHub ↗

Used to present the progress of a class in a series of loading bars @param applicationRoot The current running context of the application @param classId The identifier of the class to use in lookup @return A HTML representation of a class's progress in the application

(String applicationRoot, String classId)

Source from the content-addressed store, hash-verified

1530 * @return A HTML representation of a class's progress in the application
1531 */
1532 public static String getProgress(String applicationRoot, String classId)
1533 {
1534 log.debug("*** Getter.getProgress ***");
1535
1536 String result = new String();
1537 Connection conn = Database.getCoreConnection(applicationRoot);
1538 try
1539 {
1540 log.debug("Preparing userProgress call");
1541 CallableStatement callstmnt = conn.prepareCall("call userProgress(?)");
1542 callstmnt.setString(1, classId);
1543 log.debug("Executing userProgress");
1544 ResultSet resultSet = callstmnt.executeQuery();
1545 int resultAmount = 0;
1546 while(resultSet.next()) //For each user in a class
1547 {
1548 resultAmount++;
1549 if(resultSet.getString(1) != null)
1550 {
1551 result += "<tr><td>" + Encode.forHtml(resultSet.getString(1)) + //Output their progress
1552 "</td><td><div style='background-color: #A878EF; heigth: 25px; width: " + widthOfUnitBar*resultSet.getInt(2) + "px;'>" +
1553 "<font color='white'><strong>" +
1554 resultSet.getInt(2);
1555 if(resultSet.getInt(2) > 6)
1556 result += " Modules";
1557 result += "</strong></font></div></td></tr>";
1558 }
1559 }
1560 if(resultAmount > 0)
1561 result = "<table><tr><th>Player</th><th>Progress</th></tr>" +
1562 result + "</table>";
1563 else
1564 result = new String();
1565 }
1566 catch(SQLException e)
1567 {
1568 log.error("getProgress Failure: " + e.toString());
1569 result = null;
1570 }
1571 Database.closeConnection(conn);
1572 log.debug("*** END getProgress ***");
1573 return result;
1574 }
1575 /**
1576 * Use to return the current progress of a class in JSON format with information like user name, score and completed modules
1577 * @param applicationRoot The current running context of the application

Callers 2

testGetProgressMethod · 0.95
doPostMethod · 0.95

Calls 2

getCoreConnectionMethod · 0.95
closeConnectionMethod · 0.95

Tested by 1

testGetProgressMethod · 0.76