Search in sources :

Example 11 with RubricCriterionRating

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

the class RubricFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 123) {
        RubricCriterionRating rating = data.getExtras().getParcelable(Const.rubricCriterionRating);
        if (rating != null) {
            int position = data.getIntExtra(Const.currentPosition, 0);
            mRecyclerAdapter.updateCommentCache(rating, position);
        }
    }
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating)

Example 12 with RubricCriterionRating

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

the class RubricFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    if (savedInstanceState != null) {
        getBundleDataWithCache(savedInstanceState);
    }
    this.currentAttempt = this.mSubmission.getAttempt();
    mRecyclerAdapter = new RubricRecyclerAdapter(getContext(), getCanvasContext(), mAssignment, mSubmission, mSubmissionListener, new RubricAdapterToFragmentCallback() {

        @Override
        public void onFreeFormRowClicked(RubricCriterionRating rating, int position) {
        }

        @Override
        public void onRowClicked(RubricCriterionRating rubricCriterionRating) {
        }

        @Override
        public void onRowClicked(RubricCriterionRating rubricCriterionRating, int position) {
            if (mAssignment.isFreeFormCriterionComments()) {
                return;
            }
            mRecyclerAdapter.updateRubricAssessment(rubricCriterionRating);
        }

        @Override
        public void onCommentRowClicked(RubricCriterionRating rating, int position) {
            commentDialog = new RubricCommentDialog();
            commentDialog.setArguments(RubricCommentDialog.createBundle(mRecyclerAdapter.getGroup((long) rating.getCriterionId().hashCode()), rating, position, mAssignment.isFreeFormCriterionComments()));
            commentDialog.setTargetFragment(RubricFragment.this, 123);
            commentDialog.show(getChildFragmentManager(), EditAssignmentDialog.TAG);
        }

        @Override
        public void onRefreshFinished() {
            setRefreshing(false);
        }
    });
    configureRecyclerView(mRootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
    PandaRecyclerView pandaRecyclerView = (PandaRecyclerView) mRootView.findViewById(R.id.listView);
    pandaRecyclerView.addItemDecoration(new RubricDecorator(getContext()));
    return mRootView;
}
Also used : RubricCommentDialog(com.instructure.speedgrader.dialogs.RubricCommentDialog) RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) PandaRecyclerView(com.instructure.pandarecycler.PandaRecyclerView) RubricDecorator(com.instructure.speedgrader.decorations.RubricDecorator) RubricAdapterToFragmentCallback(com.instructure.speedgrader.interfaces.RubricAdapterToFragmentCallback) RubricRecyclerAdapter(com.instructure.speedgrader.adapters.RubricRecyclerAdapter)

Example 13 with RubricCriterionRating

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

the class RubricRecyclerAdapter method updateCommentCache.

/**
 * Called by RubricFragment's onActivityResult method when a user saves a new comment in the
 * RubricCommentDialog
 * @param position
 */
public void updateCommentCache(RubricCriterionRating rating, int position) {
    RubricCriterionRating commentRating = mCommentRowItems.get(rating.getCriterionId());
    commentRating.setComments(rating.getComments());
    commentRating.setPoints(rating.getPoints());
    handleSaveButton();
    notifyItemChanged(position);
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating)

Example 14 with RubricCriterionRating

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

the class RubricRecyclerAdapter method onBindChildHolder.

@Override
public void onBindChildHolder(RecyclerView.ViewHolder holder, RubricCriterion rubricCriterion, RubricCriterionRating rubricRating) {
    // It's important to differentiate between the RubricCriterionRatings from an Assignment Rubric and the RubricCriterionRatings
    // returned from a submission's RubricAssessment. RubricAssessment ratings will contain meta data such as isComment isRating,
    // where as an Assignment Rubric does not. Displaying comments needs a comment cache as well as the submission assessment
    // rating in order to differentiate between no comment, comment, and unsaved comments.
    RubricCriterionRating assessmentRating = mRubricAssessment.get(rubricRating.getCriterionId());
    final boolean isGrade = assessmentRating != null && (assessmentRating.getPoints() == rubricRating.getPoints());
    RubricBinder.bind(getContext(), (BaseRubricViewHolder) holder, rubricRating, assessmentRating, mCommentRowItems.get(rubricCriterion.getId()), isGrade, mAdapterToFragment);
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating)

Example 15 with RubricCriterionRating

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

the class RubricRecyclerAdapter method getRubricAssessmentScore.

/**
 * Returns the total value of items inside of mRubricAssessment. This method is  called when
 * useRubricForGrading is true in order to automatically update the assessment score.
 * @return
 */
private long getRubricAssessmentScore() {
    if (mRubricAssessment == null) {
        return 0;
    }
    long score = 0;
    for (Map.Entry<String, RubricCriterionRating> entry : mRubricAssessment.entrySet()) {
        RubricCriterionRating assessmentRating = entry.getValue();
        score += assessmentRating.getPoints();
    }
    return score;
}
Also used : RubricCriterionRating(com.instructure.canvasapi.model.RubricCriterionRating) HashMap(java.util.HashMap) Map(java.util.Map)

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