Skip to content

Commit

Permalink
[MBL-6563] Model classes for CYOE (#347)
Browse files Browse the repository at this point in the history
Also includes unit tests.

fixes MBL-6563

Change-Id: Ide630d384c45f3b7b68c26f61dbff5298c27a143
  • Loading branch information
bradylarson authored Aug 25, 2016
1 parent 29fbb38 commit 65f1c64
Show file tree
Hide file tree
Showing 8 changed files with 696 additions and 0 deletions.
123 changes: 123 additions & 0 deletions src/main/java/com/instructure/canvasapi/model/AssignmentSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.instructure.canvasapi.model;

import android.os.Parcel;

import com.google.gson.annotations.SerializedName;

import java.util.Date;

/**
* Copyright (c) 2016 Instructure. All rights reserved.
*/
public class AssignmentSet extends CanvasModel<AssignmentSet> {

private long id;
@SerializedName("scoring_range_id")
private long scoringRangeId;
@SerializedName("created_at")
private String createdAt;
@SerializedName("updated_at")
private String updatedAt;
private int position;
private MasteryPathAssignment[] assignments;


public void setId(long id) {
this.id = id;
}

public long getScoringRangeId() {
return scoringRangeId;
}

public void setScoringRangeId(long scoringRangeId) {
this.scoringRangeId = scoringRangeId;
}

public String getCreatedAt() {
return createdAt;
}

public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}

public String getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}

public int getPosition() {
return position;
}

public void setPosition(int position) {
this.position = position;
}

public MasteryPathAssignment[] getAssignments() {
return assignments;
}

public void setAssignments(MasteryPathAssignment[] assignments) {
this.assignments = assignments;
}

@Override
public String getComparisonString() {
return null;
}

@Override
public Date getComparisonDate() {
return null;
}

@Override
public long getId() {
return id;
}


@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(this.id);
dest.writeLong(this.scoringRangeId);
dest.writeString(this.createdAt);
dest.writeString(this.updatedAt);
dest.writeInt(this.position);
dest.writeTypedArray(this.assignments, flags);
}

public AssignmentSet() {
}

protected AssignmentSet(Parcel in) {
this.id = in.readLong();
this.scoringRangeId = in.readLong();
this.createdAt = in.readString();
this.updatedAt = in.readString();
this.position = in.readInt();
this.assignments = in.createTypedArray(MasteryPathAssignment.CREATOR);
}

public static final Creator<AssignmentSet> CREATOR = new Creator<AssignmentSet>() {
@Override
public AssignmentSet createFromParcel(Parcel source) {
return new AssignmentSet(source);
}

@Override
public AssignmentSet[] newArray(int size) {
return new AssignmentSet[size];
}
};
}
81 changes: 81 additions & 0 deletions src/main/java/com/instructure/canvasapi/model/MasteryPath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.instructure.canvasapi.model;

import android.os.Parcel;

import com.google.gson.annotations.SerializedName;

import java.util.Date;

/**
* Copyright (c) 2016 Instructure. All rights reserved.
*/
public class MasteryPath extends CanvasModel<MasteryPath> {

private boolean locked;

@SerializedName("assignment_sets")
private AssignmentSet[] assignmentSets;

public boolean isLocked() {
return locked;
}

public void setLocked(boolean locked) {
this.locked = locked;
}

public AssignmentSet[] getAssignmentSets() {
return assignmentSets;
}

public void setAssignmentSets(AssignmentSet[] assignmentSets) {
this.assignmentSets = assignmentSets;
}

@Override
public String getComparisonString() {
return null;
}

@Override
public Date getComparisonDate() {
return null;
}

@Override
public long getId() {
return 0;
}


@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeByte(this.locked ? (byte) 1 : (byte) 0);
dest.writeTypedArray(this.assignmentSets, flags);
}

public MasteryPath() {
}

protected MasteryPath(Parcel in) {
this.locked = in.readByte() != 0;
this.assignmentSets = in.createTypedArray(AssignmentSet.CREATOR);
}

public static final Creator<MasteryPath> CREATOR = new Creator<MasteryPath>() {
@Override
public MasteryPath createFromParcel(Parcel source) {
return new MasteryPath(source);
}

@Override
public MasteryPath[] newArray(int size) {
return new MasteryPath[size];
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package com.instructure.canvasapi.model;

import android.os.Parcel;

import com.google.gson.annotations.SerializedName;

import java.util.Date;

/**
* Copyright (c) 2016 Instructure. All rights reserved.
*/
public class MasteryPathAssignment extends CanvasModel<MasteryPathAssignment> {

private long id;
@SerializedName("assignment_id")
private long assignmentId;
@SerializedName("created_at")
private String createdAt;
@SerializedName("updated_at")
private String updatedAt;
@SerializedName("override_id")
private long overrideId;
@SerializedName("assignment_set_id")
private long assignmentSetId;
private int position;
private Assignment model;


public void setId(long id) {
this.id = id;
}

public long getAssignmentId() {
return assignmentId;
}

public void setAssignmentId(long assignmentId) {
this.assignmentId = assignmentId;
}

public String getCreatedAt() {
return createdAt;
}

public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}

public String getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}

public long getOverrideId() {
return overrideId;
}

public void setOverrideId(long overrideId) {
this.overrideId = overrideId;
}

public long getAssignmentSetId() {
return assignmentSetId;
}

public void setAssignmentSetId(long assignmentSetId) {
this.assignmentSetId = assignmentSetId;
}

public int getPosition() {
return position;
}

public void setPosition(int position) {
this.position = position;
}

public Assignment getModel() {
return model;
}

public void setModel(Assignment model) {
this.model = model;
}

//Additional getter for assignment
public Assignment getAssignment() {
return model;
}

@Override
public String getComparisonString() {
return null;
}

@Override
public Date getComparisonDate() {
return null;
}

@Override
public long getId() {
return id;
}


@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(this.id);
dest.writeLong(this.assignmentId);
dest.writeString(this.createdAt);
dest.writeString(this.updatedAt);
dest.writeLong(this.overrideId);
dest.writeLong(this.assignmentSetId);
dest.writeInt(this.position);
dest.writeParcelable(this.model, flags);
}

public MasteryPathAssignment() {
}

protected MasteryPathAssignment(Parcel in) {
this.id = in.readLong();
this.assignmentId = in.readLong();
this.createdAt = in.readString();
this.updatedAt = in.readString();
this.overrideId = in.readLong();
this.assignmentSetId = in.readLong();
this.position = in.readInt();
this.model = in.readParcelable(Assignment.class.getClassLoader());
}

public static final Creator<MasteryPathAssignment> CREATOR = new Creator<MasteryPathAssignment>() {
@Override
public MasteryPathAssignment createFromParcel(Parcel source) {
return new MasteryPathAssignment(source);
}

@Override
public MasteryPathAssignment[] newArray(int size) {
return new MasteryPathAssignment[size];
}
};
}
Loading

0 comments on commit 65f1c64

Please sign in to comment.