ajout de la moyenne

This commit is contained in:
Jialin Wang
2008-02-25 15:28:38 +00:00
parent 037df2140d
commit 7bc52a789e
2 changed files with 116 additions and 69 deletions

View File

@@ -7,13 +7,12 @@
<h4 class="title"><fmt:message key="report.headPage" /></h4> <h4 class="title"><fmt:message key="report.headPage" /></h4>
<c:choose> <c:choose>
<c:when test="${(empty listReport) and ( empty rpt) }"> <c:when test="${(empty listReport) and ( empty rpt) }">
<div class="warningBox"> <div class="warningBox">There is no report for this article at
There is no report for this article at the moment. the moment.</div>
</div> </c:when>
</c:when>
<c:otherwise> <c:otherwise>
<c:choose> <c:choose>
<c:when test="${not empty listReport }"> <c:when test="${not empty listReport }">
<c:forEach items="${listReport}" var="report" varStatus="current"> <c:forEach items="${listReport}" var="report" varStatus="current">
@@ -44,6 +43,21 @@
</div> </div>
</c:forEach> </c:forEach>
<authz:authorize ifAllGranted="ROLE_CHAIRMAN">
<table>
<c:set var="OneRatings" value="${container[0]}" />
<c:forEach items="${OneRatings}" var="rating" varStatus="i">
<tr>
<td>The average for ${rating.criterion.name} is
${listMoyenne[i.index]}</td>
</tr>
</c:forEach>
</table>
</authz:authorize>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
@@ -73,15 +87,16 @@
</div> </div>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<br /> <br />
<a class="back_link" href="<c:url value="${whereIcome}"/>"><fmt:message key="form.link.back" /></a> <a class="back_link" href="<c:url value="${whereIcome}"/>"><fmt:message
key="form.link.back" /></a>
</body> </body>
</html> </html>

View File

@@ -86,11 +86,38 @@ public class ListReportController extends SimpleFormController {
List<List<Rating>> container = new ArrayList<List<Rating>>(); List<List<Rating>> container = new ArrayList<List<Rating>>();
List<Double> listMoyenne = new ArrayList<Double>();
List<Rating> ratings = new ArrayList<Rating>();
for (int i = 0; i <= listReport.size() - 1; i++) { for (int i = 0; i <= listReport.size() - 1; i++) {
List<Rating> ratings = evaluationManager.getRatingForReport(listReport.get(i).getId()); ratings = evaluationManager.getRatingForReport(listReport.get(i).getId());
container.add(ratings); container.add(ratings);
} }
//init liste moyenne
for (int j=0; j < ratings.size(); j++)
listMoyenne.add(new Double(0));
double sum = 0;
int i = 0;
for (List<Rating> listRt : container) {
for (Rating r : listRt) {
sum = listMoyenne.get(i);
sum += r.getValue();
listMoyenne.set(i, sum);
i++;
}
i=0;
}
for (int j=0; j < ratings.size(); j++) {
listMoyenne.set(j, listMoyenne.get(j) / new Double(listReport.size()));
}
model.put("container", container); model.put("container", container);
model.put("listMoyenne", listMoyenne);
} }
} }
@@ -136,13 +163,18 @@ public class ListReportController extends SimpleFormController {
model.put("whereIcome", request.getHeader("REFERER")); model.put("whereIcome", request.getHeader("REFERER"));
/* double[] moyennes=new double[listReport.size()];
for (Rating rt : ratings)
{
}*/ listReport = evaluationManager.getReportsForArticle(id);
return new ModelAndView("listReport", model); return new ModelAndView("listReport", model);
} }