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);
}
}
}
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;
}
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);
}
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);
}
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;
}
Aggregations