Permalink
Browse files

Added a lot of testing, some additional methods needed to show the page

for a submission, and initial code to handle the missing page for
submissions. #6
  • Loading branch information...
1 parent 16e5b26 commit 0931930a5ece6a99ee3abaf7033193c53e18c24c morungos committed Apr 21, 2012
@@ -28,6 +28,10 @@ grails.project.dependency.resolution = {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
runtime 'mysql:mysql-connector-java:5.1.18'
+
compile 'org.apache.poi:poi:3.7'
+
+ test 'org.htmlparser:htmlparser:1.6'
+ test 'org.gmock:gmock:0.8.2'
}
}
@@ -131,6 +131,12 @@ openmentor {
bands = [
"A", "B", "C", "D"
]
+ bandLabels = [
+ "A": "Positive comments",
+ "B": "Teaching points",
+ "C": "Questions",
+ "D": "Negative comments"
+ ]
categoryBands = [
"A1": "A",
"A2": "A",
@@ -4,13 +4,14 @@ import grails.plugins.springsecurity.Secured;
import java.util.Map;
-import org.codehaus.groovy.grails.commons.ConfigurationHolder;
import org.springframework.web.multipart.MultipartFile;
import uk.org.openmentor.courseinfo.Course;
import uk.org.openmentor.data.Assignment;
import uk.org.openmentor.data.Submission;
+import uk.org.openmentor.domain.Categorization
import uk.org.openmentor.domain.DataBook;
+import uk.org.openmentor.domain.Grade;
@Secured(['ROLE_OPENMENTOR-USER'])
class SubmissionController {
@@ -37,24 +38,34 @@ class SubmissionController {
def upload = {
def courseInstance = getSelectedCourse()
- def grades = ConfigurationHolder.config.openmentor.grades;
+ def grades = Grade.getGrades()
[grades: grades, courseInstance: courseInstance]
}
+ /**
+ * The show action for the submission controller. This generates a Categorization
+ * of the comments, and then uses that to build a DataBook. The Submission, along
+ * with the DataBook and the categorization, are passed into the view. The
+ * assessmentService is used for the underlying work.
+ */
def show = {
Submission sub = Submission.get(params.id)
- Set<Submission> submissions = [sub] as Set<Submission>
- DataBook book = assessmentService.buildDataBook(submissions)
- return [book: book, submissionInstance: sub]
+ Categorization ctgz = assessmentService.getCategorization(sub)
+ DataBook book = assessmentService.buildDataBook(ctgz)
+
+ return [book: book, submissionInstance: sub, categorization: ctgz]
}
def save = { SubmissionCommand cmd ->
def courseInstance = getSelectedCourse()
- def grades = ConfigurationHolder.config.openmentor.grades;
+ if (! courseInstance) {
+ return
+ }
+ def grades = Grade.getGrades()
def model = [grades: grades, courseInstance: courseInstance]
model.cmd = cmd
@@ -63,8 +74,8 @@ class SubmissionController {
return
}
- log.error("Ready to save and start processing")
- log.error(cmd)
+ log.debug("Ready to save and start processing")
+ log.debug(cmd)
// First of all, we may have the same submission already. This is not hugely
// well-specified in the previous implementation.
@@ -9,6 +9,6 @@ class Comment {
static hasMany = [ classes: String ]
static constraints = {
- text(nullable: false)
+ text(nullable: false, , maxSize: 4*1024)
}
}
@@ -61,6 +61,13 @@ assignment.upload.label=Upload an Assignment
assignment.uploaded.label=Assignment Uploaded
assignment.show.label=Assignment {0} for {1}
+submission.show.label=Submission {0}
+
+databook.category.label=Category
+databook.actual.label=Actual
+databook.ideal.label=Ideal
+databook.commentText.label=Comment text
+
report.summary.label=Summary report for {0}
report.student.label=Student report for {0}
report.tutor.label=Tutor report for {0}
@@ -27,7 +27,21 @@ class AssessmentService {
static transactional = true
- private Categorization getCategorization(Set<Submission> submissions) {
+ /**
+ * Returns a Categorization constructed from a single submission.
+ * @param submission
+ * @return a Categorization
+ */
+ public Categorization getCategorization(Submission submission) {
+ return getCategorization([submission] as Set<Submission>)
+ }
+
+ /**
+ * Returns a Categorization constructed from a set of submissions.
+ * @param submission
+ * @return a Categorization
+ */
+ public Categorization getCategorization(Set<Submission> submissions) {
Categorization ctgz = new Categorization()
ctgz.clear()
ctgz.addComments(submissions)
@@ -58,29 +72,43 @@ class AssessmentService {
}
private aggregateComments
-
+
/**
- * Builds a DataBook for charting purposes.
+ * Builds a DataBook for charting purposes, based on a single submission.
+ * @return the DataBook instance
+ */
+ public final DataBook buildDataBook(Submission submission) {
+ return buildDataBook([submission] as Set<Submission>)
+ }
+
+ /**
+ * Builds a DataBook for charting purposes, based on a set of submissions.
* @return the DataBook instance
*/
public final DataBook buildDataBook(Set<Submission> submissions) {
-
- DataBook dataBook = new DataBook();
-
Categorization ctgz = getCategorization(submissions)
+ return buildDataBook(ctgz)
+ }
+ /**
+ * Builds a DataBook for charting purposes, based on a categorization
+ * constructed from the set of submissions.
+ * @return the DataBook instance
+ */
+ public final DataBook buildDataBook(Categorization ctgz) {
+ DataBook dataBook = new DataBook();
Map<String, Integer> actualCounts = getCommentCounts(ctgz)
Integer commentCount = getValuesTotal(actualCounts.values())
- log.error("Actual coment counts: " + actualCounts)
- log.error("Total coment count: " + commentCount)
+ log.debug("Actual coment counts: " + actualCounts)
+ log.debug("Total coment count: " + commentCount)
List<String> categories = Category.getCategories()
List<String> bands = Category.getBands()
Map<String, String> categoryBandMap = Category.getCategoryBandMap()
Map<String, List<String>> comments = new HashMap<String, List<String>>();
for (String category: categories) {
- log.error("Comment: " + category + ", " + ctgz.getComments(category))
+ log.debug("Comment: " + category + ", " + ctgz.getComments(category))
comments.put(category, ctgz.getComments(category));
}
Map<String, List<String>> aggregateComments = aggregateComments(comments);
@@ -0,0 +1,59 @@
+<%@ page import="uk.org.openmentor.data.Submission" %>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta name="layout" content="main" />
+ <g:set var="entityName" value="${message(code: 'submission.label', default: 'Submission')}" />
+ <title><g:message code="default.show.label" args="[entityName]" /></title>
+ </head>
+ <body>
+ <div id="page">
+ <div class="body">
+ <h1><g:message code="submission.show.label" args="${[submissionInstance.filename]}" /></h1>
+ <g:if test="${flash.message}">
+ <div class="message">${flash.message}</div>
+ </g:if>
+
+ <table>
+ <thead>
+ <tr>
+ <th><g:message code="databook.category.label"/></th>
+ <th><g:message code="databook.actual.label"/></th>
+ <th><g:message code="databook.ideal.label"/></th>
+ <th><g:message code="databook.commentText.label"/></th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <g:each var="band" in="${book.getDataPoints()}" status="bandIndex">
+ <tr>
+ <td>
+ <p>
+ <em>${band}</em>
+ </p>
+ </td>
+ <td class="number"><p>${book.getDataSeries("ActualCounts")[bandIndex]}</p></td>
+ <td class="number"><p>${book.getDataSeries("IdealCounts")[bandIndex]}</p></td>
+ <td>
+ <g:set var="limit" value="3"/>
+ <g:each var="comment" in="${categorization.getBandComments(band)}" status="commentIndex">
+ <p>
+ <g:if test="${commentIndex <= limit}">
+ ${comment}
+ </g:if>
+ </p>
+ </g:each>
+ <g:if test="${commentIndex > (limit + 1)}">
+ <p>
+ <i>...(and ${commentIndex - limit - 1} more)
+ </i>
+ </p>
+ </g:if></td>
+ </tr>
+ </g:each>
+ </tbody>
+ </table>
+
+ </div>
+ </div>
+</html>
@@ -71,6 +71,17 @@ class Categorization {
}
/**
+ * Returns a list of comments for a given band within this Categorization
+ * instance.
+ * @param band
+ * @return
+ */
+ public final List<String> getBandComments(String band) {
+ List<String> grades = Grade.getGrades()
+ return grades.collectMany { getBandComments(band, it) }
+ }
+
+ /**
* Describe <code>getComments</code> method here.
*
* @param category a <code>Category</code> value
@@ -79,7 +90,7 @@ class Categorization {
public final List<String> getComments(String category) {
List list = new ArrayList<String>();
for (String grade : Grade.getGrades()) {
- list.addAll(getComments(category,grade));
+ list.addAll(getComments(category, grade));
}
return list;
}
@@ -106,6 +117,24 @@ class Categorization {
}
/**
+ * Get the list of comments associated with the cell (band,
+ * grade), ensuring that an empty list is returned when
+ * appropriate.
+ *
+ * @param band
+ * @param grade
+ * @return the list of comments
+ */
+ public final List<String> getBandComments(String band, String grade) {
+ Map<Category,List<String>> categoryMap = gradeMap.get(grade);
+ if (categoryMap == null) {
+ return emptyList;
+ }
+ List<String> categories = Category.getBandCategories(band)
+ return categories.collectMany { categoryMap.get(it) ?: [] }
+ }
+
+ /**
* Go through the comments associated with the given submission,
* each of which has zero or more associated rule categries, and
* store them as items in the list associated with the cell
@@ -16,4 +16,10 @@ class Category {
static Map<String, String> getCategoryBandMap() {
return ConfigurationHolder.config.openmentor.categoryBands as Map<String, String>
}
+
+ static List<String> getBandCategories(String band) {
+ Map<String, String> map = getCategoryBandMap()
+ List<String> categories = getCategories()
+ return categories.findAll { map.getAt(it) == band }
+ }
}
Oops, something went wrong.

0 comments on commit 0931930

Please sign in to comment.