Skip to main content

Plan Routes

GET /api/plans/:plan_id

Gets a plan by id.

NameTypeDescription
Paramsplan_idStringplan id
OutputPlanThe plan corresponding to the id in the request params.

Sample Output

{
"majors": [
"B.S. Computer Science (NEW - 2021 & after)"
],
"distribution_ids": [],
"_id": "623659ddb8316b8b54f77815",
"name": "Unnamed Plan",
"user_id": "mockUser",
"__v": 1,
"years": [
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77817",
"name": "AP/Transfer",
"user_id": "mockUser",
"year": 0,
"__v": 0
},
{
"courses": [
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "62395837daa1f097d4062697",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Precalculus",
"term": "fall",
"year": "Freshman",
"credits": 4,
"number": "AS.110.105",
"area": "Q",
"version": "Fall 2021",
"__v": 0
},
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [
{
"Description": "Grade of C- or better in AS.110.107 OR AS.110.109 OR AS.110.113 OR AS.110.201 OR AS.110.212 OR AS.110.302, or a 5 or better on the AP BC exam.",
"Expression": "AS.110.107[C]^OR^AS.110.109[C]^OR^AS.110.113[C]^OR^AS.110.201[C]^OR^AS.110.212[C]^OR^AS.110.302[C]",
"IsNegative": "N"
}
],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "6239583cdaa1f097d40626b2",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Calculus III",
"term": "spring",
"year": "Freshman",
"credits": 4,
"number": "AS.110.202",
"area": "Q",
"version": "Spring 2022",
"__v": 0
}
],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781a",
"name": "Freshman",
"user_id": "mockUser",
"year": 2021,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781c",
"name": "Sophomore",
"user_id": "mockUser",
"year": 2022,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781e",
"name": "Junior",
"user_id": "mockUser",
"year": 2023,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77820",
"name": "Senior",
"user_id": "mockUser",
"year": 2024,
"__v": 0
}
]
}

GET /api/plansByUser/:user_id

Gets a list of all plans of a particular user filled with all year and course objects.

NameTypeDescription
Paramsuser_idStringuser id
OutputPlan[]A list of plans corresponding to the plan ids stored in the user corresponding to the user id in the request params.

Sample output

[
{
"majors": [
"B.S. Computer Science (NEW - 2021 & after)"
],
"distribution_ids": [],
"_id": "623659ddb8316b8b54f77815",
"name": "Unnamed Plan",
"user_id": "mockUser",
"__v": 1,
"years": [
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77817",
"name": "AP/Transfer",
"user_id": "mockUser",
"year": 0,
"__v": 0
},
{
"courses": [
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "62395837daa1f097d4062697",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Precalculus",
"term": "fall",
"year": "Freshman",
"credits": 4,
"number": "AS.110.105",
"area": "Q",
"version": "Fall 2021",
"__v": 0
},
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [
{
"Description": "Grade of C- or better in AS.110.107 OR AS.110.109 OR AS.110.113 OR AS.110.201 OR AS.110.212 OR AS.110.302, or a 5 or better on the AP BC exam.",
"Expression": "AS.110.107[C]^OR^AS.110.109[C]^OR^AS.110.113[C]^OR^AS.110.201[C]^OR^AS.110.212[C]^OR^AS.110.302[C]",
"IsNegative": "N"
}
],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "6239583cdaa1f097d40626b2",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Calculus III",
"term": "spring",
"year": "Freshman",
"credits": 4,
"number": "AS.110.202",
"area": "Q",
"version": "Spring 2022",
"__v": 0
}
],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781a",
"name": "Freshman",
"user_id": "mockUser",
"year": 2021,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781c",
"name": "Sophomore",
"user_id": "mockUser",
"year": 2022,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781e",
"name": "Junior",
"user_id": "mockUser",
"year": 2023,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77820",
"name": "Senior",
"user_id": "mockUser",
"year": 2024,
"__v": 0
}
]
},
{
"_id": {
"$oid": "6239587fdaa1f097d40626ba"
},
"majors": [
"B.S. Molecular and Cellular Biology"
],
"year_ids": [
{
"$oid": "6239587fdaa1f097d40626bc"
},
{
"$oid": "62395880daa1f097d40626bf"
},
{
"$oid": "62395880daa1f097d40626c1"
},
{
"$oid": "62395880daa1f097d40626c3"
},
{
"$oid": "62395880daa1f097d40626c5"
}
],
"distribution_ids": [],
"name": "Unnamed Plan",
"user_id": "mockUser",
"__v": 1
}
]

POST /api/plans/

Creates a new plan. When creating a plan, the post body can specify the number of years("numYear" field) and the backend will automatically generate years document in this order:[freshman, sophomore, junior, senior, fifth year]. For example, if the post body specified numYear: 3, then freshman, sophomore, junior year documents will be generated. The default numYear value is 4 (if you don't specify). plan_ids field of the user document is also updated.

NameTypeDescription
BodynameStringnew plan's name
user_idStringthe new plan's owner id
majorsStringthe degrees associated with the new plan
numYearsNumberNumber of years to create
expireAtDatethe time when the object is supposed to be trash-collected (note: this needs fixing)
OutputPlanNewly created plan.

Sample Output

{
"majors": [
"B.S. Computer Science (NEW - 2021 & after)"
],
"distribution_ids": [],
"_id": "623659ddb8316b8b54f77815",
"name": "Unnamed Plan",
"user_id": "mockUser",
"__v": 1,
"years": [
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77817",
"name": "AP/Transfer",
"user_id": "mockUser",
"year": 0,
"__v": 0
},
{
"courses": [
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "62395837daa1f097d4062697",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Precalculus",
"term": "fall",
"year": "Freshman",
"credits": 4,
"number": "AS.110.105",
"area": "Q",
"version": "Fall 2021",
"__v": 0
},
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [
{
"Description": "Grade of C- or better in AS.110.107 OR AS.110.109 OR AS.110.113 OR AS.110.201 OR AS.110.212 OR AS.110.302, or a 5 or better on the AP BC exam.",
"Expression": "AS.110.107[C]^OR^AS.110.109[C]^OR^AS.110.113[C]^OR^AS.110.201[C]^OR^AS.110.212[C]^OR^AS.110.302[C]",
"IsNegative": "N"
}
],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "6239583cdaa1f097d40626b2",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Calculus III",
"term": "spring",
"year": "Freshman",
"credits": 4,
"number": "AS.110.202",
"area": "Q",
"version": "Spring 2022",
"__v": 0
}
],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781a",
"name": "Freshman",
"user_id": "mockUser",
"year": 2021,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781c",
"name": "Sophomore",
"user_id": "mockUser",
"year": 2022,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781e",
"name": "Junior",
"user_id": "mockUser",
"year": 2023,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77820",
"name": "Senior",
"user_id": "mockUser",
"year": 2024,
"__v": 0
}
]
}

PATCH /api/plans/:plan_id

Updates a plan's name or degrees corresponding to a given id.

NameTypeDescription
Bodyplan_idStringid of plan to update
majorsString[]?optional array of degree ids to update the plan's degree array with
nameString?optional new name for the plan
OutputPlanUpdated plan.

Sample Output

{
"majors": [
"B.S. Computer Science (NEW - 2021 & after)"
],
"distribution_ids": [],
"_id": "623659ddb8316b8b54f77815",
"name": "Unnamed Plan",
"user_id": "mockUser",
"__v": 1,
"years": [
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77817",
"name": "AP/Transfer",
"user_id": "mockUser",
"year": 0,
"__v": 0
},
{
"courses": [
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "62395837daa1f097d4062697",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Precalculus",
"term": "fall",
"year": "Freshman",
"credits": 4,
"number": "AS.110.105",
"area": "Q",
"version": "Fall 2021",
"__v": 0
},
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [
{
"Description": "Grade of C- or better in AS.110.107 OR AS.110.109 OR AS.110.113 OR AS.110.201 OR AS.110.212 OR AS.110.302, or a 5 or better on the AP BC exam.",
"Expression": "AS.110.107[C]^OR^AS.110.109[C]^OR^AS.110.113[C]^OR^AS.110.201[C]^OR^AS.110.212[C]^OR^AS.110.302[C]",
"IsNegative": "N"
}
],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "6239583cdaa1f097d40626b2",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Calculus III",
"term": "spring",
"year": "Freshman",
"credits": 4,
"number": "AS.110.202",
"area": "Q",
"version": "Spring 2022",
"__v": 0
}
],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781a",
"name": "Freshman",
"user_id": "mockUser",
"year": 2021,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781c",
"name": "Sophomore",
"user_id": "mockUser",
"year": 2022,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781e",
"name": "Junior",
"user_id": "mockUser",
"year": 2023,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77820",
"name": "Senior",
"user_id": "mockUser",
"year": 2024,
"__v": 0
}
]
}

DELETE /api/plans/:plan_id

Deletes a plan corresponding to a given id. By deleting a plan, all associated courses and distributions are deleted from the database.

NameTypeDescription
Paramsplan_idStringid of plan to delete
OutputPlanDeleted plan.

Sample Output

{
"majors": [
"B.S. Computer Science (NEW - 2021 & after)"
],
"distribution_ids": [],
"_id": "623659ddb8316b8b54f77815",
"name": "Unnamed Plan",
"user_id": "mockUser",
"__v": 1,
"years": [
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77817",
"name": "AP/Transfer",
"user_id": "mockUser",
"year": 0,
"__v": 0
},
{
"courses": [
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "62395837daa1f097d4062697",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Precalculus",
"term": "fall",
"year": "Freshman",
"credits": 4,
"number": "AS.110.105",
"area": "Q",
"version": "Fall 2021",
"__v": 0
},
{
"termOffered": [],
"tags": [],
"wi": false,
"taken": false,
"preReq": [
{
"Description": "Grade of C- or better in AS.110.107 OR AS.110.109 OR AS.110.113 OR AS.110.201 OR AS.110.212 OR AS.110.302, or a 5 or better on the AP BC exam.",
"Expression": "AS.110.107[C]^OR^AS.110.109[C]^OR^AS.110.113[C]^OR^AS.110.201[C]^OR^AS.110.212[C]^OR^AS.110.302[C]",
"IsNegative": "N"
}
],
"isPlaceholder": false,
"isTransfer": false,
"ratings": [],
"distribution_ids": [],
"_id": "6239583cdaa1f097d40626b2",
"user_id": "mockUser",
"year_id": "623659ddb8316b8b54f7781a",
"plan_id": "623659ddb8316b8b54f77815",
"title": "Calculus III",
"term": "spring",
"year": "Freshman",
"credits": 4,
"number": "AS.110.202",
"area": "Q",
"version": "Spring 2022",
"__v": 0
}
],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781a",
"name": "Freshman",
"user_id": "mockUser",
"year": 2021,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781c",
"name": "Sophomore",
"user_id": "mockUser",
"year": 2022,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f7781e",
"name": "Junior",
"user_id": "mockUser",
"year": 2023,
"__v": 0
},
{
"courses": [],
"plan_id": [
"623659ddb8316b8b54f77815"
],
"_id": "623659ddb8316b8b54f77820",
"name": "Senior",
"user_id": "mockUser",
"year": 2024,
"__v": 0
}
]
}