Search in sources :

Example 1 with RubricCriterionRating

use of com.instructure.canvasapi.model.RubricCriterionRating in project instructure-android by instructure.

the class AssignmentUnitTest method testRubricCriterion.

public static void testRubricCriterion(RubricCriterion rubricCriterion) {
    assertNotNull(rubricCriterion);
    assertNotNull(rubricCriterion.getId());
    assertNotNull(rubricCriterion.getCriterionDescription());
    assertNotNull(rubricCriterion.getLongDescription());
    assertTrue(rubricCriterion.getPoints() >= 0);
    if (rubricCriterion.getRatings() != null) {
        for (RubricCriterionRating rubricCriterionRating : rubricCriterion.getRatings()) {
            testRubricCriterionRating(rubricCriterionRating);
        }
    }
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating)

Example 2 with RubricCriterionRating

use of com.instructure.canvasapi.model.RubricCriterionRating in project instructure-android by instructure.

the class RubricRecyclerAdapter method saveCommentsCacheToRubricAssessment.

private void saveCommentsCacheToRubricAssessment() {
    for (Map.Entry<String, RubricCriterionRating> entry : mCommentRowItems.entrySet()) {
        // It's possible to save a submission comment, without marking a grade, in which case the submission
        // rubric assessment will not contain a key for that criterion id. In this case,
        // we need to create a new rubric rating and save that.
        RubricCriterionRating rating = entry.getValue();
        if (rating == null) {
            return;
        }
        String newComment = rating.getComments();
        if (mRubricAssessment.containsKey(entry.getKey())) {
            RubricCriterionRating oldRating = mRubricAssessment.get(entry.getKey());
            if (!Const.NO_COMMENT.equals(rating.getComments())) {
                // If there is a new comment entered. Use that, otherwise save the original comment
                oldRating.setComments(newComment);
            }
            if (mAssignment.isFreeFormCriterionComments()) {
                oldRating.setPoints(rating.getPoints());
            }
        } else {
            if (Const.NO_COMMENT.equals(newComment)) {
                // If no prior comment and no new comment, save an empty string
                rating.setComments("");
            }
            mRubricAssessment.put(entry.getKey(), rating);
        }
    }
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with RubricCriterionRating

use of com.instructure.canvasapi.model.RubricCriterionRating in project instructure-android by instructure.

the class RubricRecyclerAdapter method populateRatingItems.

// endregion
// region populate adapters
/**
 * Populates the adapter with RubricCriterionRatings from the ASSIGNMENT rubric. RubricCriterionRatings from
 * the Submission RubricAssessment should not be used here.
 * @param rubric
 */
private void populateRatingItems(List<RubricCriterion> rubric) {
    int insertCount = 0;
    for (RubricCriterion rubricCriterion : rubric) {
        final List<RubricCriterionRating> rubricCriterionRatings = rubricCriterion.getRatingsWithCriterionIds();
        for (RubricCriterionRating rating : rubricCriterionRatings) {
            mInsertedOrderHash.put(rubricCriterion.getId(), ++insertCount);
            addOrUpdateItem(rubricCriterion, rating);
        }
        // Add an additional row to each rubric criterion for comments
        RubricCriterionRating comment = createCommentItem(rubricCriterion);
        mCommentRowItems.put(rubricCriterion.getId(), comment);
        mInsertedOrderHash.put(rubricCriterion.getId(), ++insertCount);
        addOrUpdateItem(rubricCriterion, comment);
    }
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) RubricCriterion(com.instructure.canvasapi.model.RubricCriterion)

Example 4 with RubricCriterionRating

use of com.instructure.canvasapi.model.RubricCriterionRating in project instructure-android by instructure.

the class RubricRecyclerAdapter method createCommentItem.

private static RubricCriterionRating createCommentItem(RubricCriterion rubricCriterion) {
    RubricCriterionRating commentItem = new RubricCriterionRating();
    commentItem.setComments(Const.NO_COMMENT);
    commentItem.setCriterionId(rubricCriterion.getId());
    commentItem.setId(String.valueOf(App.getUniqueId()));
    return commentItem;
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating)

Example 5 with RubricCriterionRating

use of com.instructure.canvasapi.model.RubricCriterionRating in project instructure-android by instructure.

the class RubricRecyclerAdapter method createFreeFormCommentItem.

private static RubricCriterionRating createFreeFormCommentItem(RubricCriterion rubricCriterion) {
    RubricCriterionRating commentItem = new RubricCriterionRating();
    commentItem.setIsFreeFormComment(true);
    commentItem.setMaxPoints(rubricCriterion.getPoints());
    commentItem.setComments(Const.NO_COMMENT);
    commentItem.setPoints(Integer.MIN_VALUE);
    commentItem.setCriterionId(rubricCriterion.getId());
    commentItem.setId(String.valueOf(App.getUniqueId()));
    return commentItem;
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating)

Aggregations

RubricCriterionRating (com.instructure.canvasapi.model.RubricCriterionRating)15 RubricCriterion (com.instructure.canvasapi.model.RubricCriterion)4 HashMap (java.util.HashMap)4 Map (java.util.Map)3 Gson (com.google.gson.Gson)1 PandaRecyclerView (com.instructure.pandarecycler.PandaRecyclerView)1 RubricRecyclerAdapter (com.instructure.speedgrader.adapters.RubricRecyclerAdapter)1 RubricDecorator (com.instructure.speedgrader.decorations.RubricDecorator)1 RubricCommentDialog (com.instructure.speedgrader.dialogs.RubricCommentDialog)1 RubricAdapterToFragmentCallback (com.instructure.speedgrader.interfaces.RubricAdapterToFragmentCallback)1 LinkedHashMap (java.util.LinkedHashMap)1 Test (org.junit.Test)1 PartMap (retrofit.http.PartMap)1 QueryMap (retrofit.http.QueryMap)1