Search in sources :

Example 6 with RubricCriterionRating

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

the class RubricRecyclerAdapter method populateFreeFormRatingItems.

private void populateFreeFormRatingItems(List<RubricCriterion> rubric) {
    int insertCount = 0;
    for (RubricCriterion rubricCriterion : rubric) {
        RubricCriterionRating freeformItem = createFreeFormCommentItem(rubricCriterion);
        mInsertedOrderHash.put(rubricCriterion.getId(), ++insertCount);
        mCommentRowItems.put(rubricCriterion.getId(), freeformItem);
        addOrUpdateItem(rubricCriterion, freeformItem);
    }
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) RubricCriterion(com.instructure.canvasapi.model.RubricCriterion)

Example 7 with RubricCriterionRating

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

the class RubricRecyclerAdapter method updateRubricAssessment.

/**
 * Called by our RubricFragment's RubricAdapterToFragmentCallback method when a new rubric rating is selected
 * @param newRating
 */
public void updateRubricAssessment(RubricCriterionRating newRating) {
    RubricCriterionRating oldRating = getSubmissionRatingForCriterionId(newRating.getCriterionId());
    RubricCriterion group = getCriterionById(newRating.getCriterionId());
    if (hasRatingChanged(oldRating, newRating)) {
        mRubricAssessment.put(newRating.getCriterionId(), newRating);
    }
    addOrUpdateItem(group, newRating);
    updateOriginalRating(newRating.getCriterionId());
    handleSaveButton();
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) RubricCriterion(com.instructure.canvasapi.model.RubricCriterion)

Example 8 with RubricCriterionRating

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

the class RubricFragment method updateRubric.

/**
 * Called by our SubmissionWebView for updating quiz results
 * @param submission
 */
public void updateRubric(Submission submission) {
    Toast.makeText(getActivity(), getString(R.string.gradeSaved), Toast.LENGTH_SHORT).show();
    // Update our rubric assessment to reflect any new comment data
    HashMap<String, RubricCriterionRating> rubric_assessment = new HashMap<String, RubricCriterionRating>();
    for (RubricCriterionRating rating : mSubmission.getRubricAssessment().getRatings()) {
        rubric_assessment.put(rating.getCriterionId(), rating);
    }
    mSubmissionListener.onSubmissionRubricAssessmentUpdated(rubric_assessment, submission.getScore(), submission.getGrade());
    // Enable paging on viewpager
    mSubmissionListener.setPagingEnabled(true);
    mRecyclerAdapter.clear();
    mAssignment = mOriginalAssignment;
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) HashMap(java.util.HashMap)

Example 9 with RubricCriterionRating

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

the class RubricCriterionUnitTest method testRubricCriterionRating.

@Test
public void testRubricCriterionRating() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    RubricCriterion[] rubricCriterions = gson.fromJson(rubricCriterionJSON, RubricCriterion[].class);
    for (RubricCriterion rubricCriterion : rubricCriterions) {
        if (rubricCriterion.getGradedCriterionRating() != null) {
            List<RubricCriterionRating> ratings = rubricCriterion.getRatings();
            for (RubricCriterionRating rubricCriterionRating : ratings) {
                assertNotNull(rubricCriterionRating.getId());
                assertNotNull(rubricCriterionRating.getRatingDescription());
            }
        }
    }
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) RubricCriterion(com.instructure.canvasapi.model.RubricCriterion) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 10 with RubricCriterionRating

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

the class SubmissionAPI method generateRubricAssessmentQueryMap.

private static Map<String, String> generateRubricAssessmentQueryMap(HashMap<String, RubricCriterionRating> rubricAssessment) {
    Map<String, String> map = new HashMap<>();
    for (Map.Entry<String, RubricCriterionRating> entry : rubricAssessment.entrySet()) {
        RubricCriterionRating rating = entry.getValue();
        map.put(assessmentPrefix + rating.getCriterionId() + pointsPostFix, String.valueOf(rating.getPoints()));
        if (rating.getComments() != null && !TextUtils.isEmpty(rating.getComments())) {
            map.put(assessmentPrefix + rating.getCriterionId() + commentsPostFix, rating.getComments());
        }
    }
    return map;
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) QueryMap(retrofit.http.QueryMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) PartMap(retrofit.http.PartMap)

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