Search in sources :

Example 1 with NeedsGradingCount

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

the class NeedsGradingCountUnitTest method testNeedsGradingCount.

@Test
public void testNeedsGradingCount() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    NeedsGradingCount needsGradingCount = gson.fromJson(needsGradingCountJSON, NeedsGradingCount.class);
    assertNotNull(needsGradingCount);
    assertTrue(needsGradingCount.getSectionId() > 0);
    assertTrue(needsGradingCount.getNeedsGradingCount() > 0);
}
Also used : NeedsGradingCount(com.instructure.canvasapi.model.NeedsGradingCount) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 2 with NeedsGradingCount

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

the class AssignmentBinder method bind.

public static void bind(Context context, AssignmentViewHolder holder, final Assignment assignment, final AssignmentAdapterToFragmentCallback callback) {
    holder.title.setText(assignment.getName());
    // get course color
    int color = CanvasContextColor.getCachedColor(context, CanvasContext.makeContextId(CanvasContext.Type.COURSE, assignment.getCourseId()));
    // Create the assignment icon and set it to the course color
    int drawable = 0;
    if (assignment.getSubmissionTypes().contains(Assignment.SUBMISSION_TYPE.ONLINE_QUIZ)) {
        drawable = R.drawable.ic_cv_quizzes;
    } else if (assignment.getSubmissionTypes().contains(Assignment.SUBMISSION_TYPE.DISCUSSION_TOPIC)) {
        drawable = R.drawable.ic_cv_discussions;
    } else {
        drawable = R.drawable.ic_cv_assignments;
    }
    Drawable d = CanvasContextColor.getColoredDrawable(context, drawable, color);
    holder.icon.setImageDrawable(d);
    // Get the needs grading count, default to the assignment's total needs grading count
    long needsGrading = assignment.getNeedsGradingCount();
    Section section = callback.getCurrentSection();
    // If we're filtering by a section other than All Sections
    if (assignment.getNeedsGradingCountBySection() != null && section.getId() != Integer.MIN_VALUE) {
        // The needs_grading_count_per_section api does not return a value for
        needsGrading = 0;
        // sections with 0 submissions needing grading, set the default to 0
        for (NeedsGradingCount needsGradingCount : assignment.getNeedsGradingCountBySection()) {
            if (needsGradingCount.getSectionId() == section.getId()) {
                needsGrading = needsGradingCount.getNeedsGradingCount();
            }
        }
    }
    if (needsGrading > 0) {
        holder.badge.setVisibility(View.VISIBLE);
        if (needsGrading > 99) {
            holder.badge.setText(context.getResources().getString(R.string.ninetyNinePlus));
        } else {
            holder.badge.setText(String.valueOf(needsGrading));
        }
    } else {
        holder.badge.setVisibility(View.INVISIBLE);
    }
    // Get the date
    String dateString = getDueDateString(context, assignment);
    holder.description.setText(dateString);
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            callback.onRowClicked(assignment);
        }
    });
}
Also used : NeedsGradingCount(com.instructure.canvasapi.model.NeedsGradingCount) Drawable(android.graphics.drawable.Drawable) Section(com.instructure.canvasapi.model.Section) View(android.view.View)

Aggregations

NeedsGradingCount (com.instructure.canvasapi.model.NeedsGradingCount)2 Drawable (android.graphics.drawable.Drawable)1 View (android.view.View)1 Gson (com.google.gson.Gson)1 Section (com.instructure.canvasapi.model.Section)1 Test (org.junit.Test)1