Used to present a modules feedback, including averages and raw results. @param applicationRoot The current running context of the application. @param moduleId The module identifier @return A HTML table of the feedback for a specific module
(String applicationRoot, String moduleId)
| 555 | * @return A HTML table of the feedback for a specific module |
| 556 | */ |
| 557 | public static String getFeedback(String applicationRoot, String moduleId) |
| 558 | { |
| 559 | log.debug("*** Getter.getFeedback ***"); |
| 560 | |
| 561 | String result = new String(); |
| 562 | Connection conn = Database.getCoreConnection(applicationRoot); |
| 563 | try |
| 564 | { |
| 565 | log.debug("Preparing userUpdateResult call"); |
| 566 | CallableStatement callstmnt = conn.prepareCall("call moduleFeedback(?)"); |
| 567 | callstmnt.setString(1, moduleId); |
| 568 | log.debug("Executing moduleFeedback"); |
| 569 | ResultSet resultSet = callstmnt.executeQuery(); |
| 570 | int resultAmount = 0; |
| 571 | int before = 0; |
| 572 | int after = 0; |
| 573 | int difficulty = 0; |
| 574 | boolean color = true; |
| 575 | while(resultSet.next()) |
| 576 | { |
| 577 | if(resultSet.getString(1) != null) |
| 578 | { |
| 579 | resultAmount++; |
| 580 | difficulty += resultSet.getInt(3); |
| 581 | before += resultSet.getInt(4); |
| 582 | after += resultSet.getInt(5); |
| 583 | result += "<tr "; |
| 584 | if(color) //Alternate row color |
| 585 | { |
| 586 | color = !color; |
| 587 | result += "BGCOLOR='A878EF'"; |
| 588 | } |
| 589 | else |
| 590 | { |
| 591 | color = !color; |
| 592 | result += "BGCOLOR='D4BCF7'"; |
| 593 | } |
| 594 | //A row off information |
| 595 | result += "><td>" + Encode.forHtml(resultSet.getString(1)) + "</td><td>" + Encode.forHtml(resultSet.getString(2)) + "</td><td>" + |
| 596 | resultSet.getInt(3) + "</td><td>" + resultSet.getInt(4) + "</td><td>" + |
| 597 | resultSet.getInt(5) + "</td><td>" + Encode.forHtml(resultSet.getString(6)) + "</td></tr>"; |
| 598 | } |
| 599 | } |
| 600 | if(resultAmount > 0)//Table header |
| 601 | result = "<table><tr><th>Player</th><th>Time</th><th>Difficulty</th><th>Before</th><th>After</th><th>Comments</th></tr>" + |
| 602 | "<tr><td>Average</td><td></td><td>" + difficulty/resultAmount + "</td><td>" + |
| 603 | before/resultAmount + "</td><td>" + after/resultAmount + "</td><td></td></tr>" + result + "<table>"; |
| 604 | else // If empty, Blank output |
| 605 | result = new String(); |
| 606 | } |
| 607 | catch(SQLException e) |
| 608 | { |
| 609 | log.error("moduleFeedback Failure: " + e.toString()); |
| 610 | result = null; |
| 611 | } |
| 612 | Database.closeConnection(conn); |
| 613 | log.debug("*** END getFeedback ***"); |
| 614 | return result; |