Skip to content

Commit

Permalink
Merge pull request #376 from nus-mtp/development
Browse files Browse the repository at this point in the history
Launch version changes
  • Loading branch information
NatashaKSS authored Apr 14, 2017
2 parents 473bc14 + 6cf5505 commit 43b2c11
Show file tree
Hide file tree
Showing 69 changed files with 1,938 additions and 138 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ session
mrt:cheerio
anonyfox:scrape
force-ssl
dispatch:mocha-browser
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ deps@1.0.12
diff-sequence@1.0.7
digilord:sugarjs@1.4.1
dispatch:mocha@0.2.0
dispatch:mocha-browser@0.0.4
ecmascript@0.6.3
ecmascript-runtime@0.3.15
ejson@1.0.13
Expand Down
6 changes: 6 additions & 0 deletions imports/api/database-controller/academic-cohort/acadCohort.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
/**
Academic Cohort stores the information relevant to the student's cohort, including suggested planner IDs, focus Areas IDs, and
Graduation Requirement IDs,
Because of this, it is expected that all these informations are already present, or created at the same time the cohort document
is created. For example, take a look at the cohortDataBaseParser.js under database-conversion folder
*/
class AcadCohortCollection extends Mongo.Collection{
insert(acadCohortData, callBack){
const cohortDocument = acadCohortData;
Expand Down
59 changes: 53 additions & 6 deletions imports/api/database-controller/academic-cohort/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ import {AcademicCohort} from './acadCohort';
import {Planner} from '../../student-logic-controller/crud-controller/planner/planner';
import {GraduationRequirements} from '../graduation-requirement/graduationRequirement';
import {Match} from 'meteor/check';

//change this as you see fit when you want to populate the database
//make sure that this name is consistent throughout your json file
const CS_FOUNDATION_PLANNER_NAME = "CS Foundation"

/** Call this method to create a new cohort document with only cohortName information required. DO NOT USE MongoDB Insert method
since this method includes steps to check the document adherent to the agreed Schema
@param {String} cohortName: name of the new Cohort Document that is going to be put. As written in acadCohort.js,
the name should follow the following format 'AY XXXX/XXXX' where XXXX is the year relevant to the cohort
@return String containing the new cohort ID or empty object if the insertion failed or the cohortName is not A string.
*/
export const createNewCohort = function createCohort(cohortName) {
const newCohortDocument = {
cohortName: cohortName,
Expand All @@ -25,7 +32,15 @@ export const createNewCohort = function createCohort(cohortName) {

return {};
}

/** Call this method to remove a new cohort document with only cohortName information required. DO NOT USE MongoDB remove method
since this method includes steps to check the document integrity. Things to take note:
- Graduation Requirement and Default Planner document IDs relevance heavily relies on the Academic Cohort.
- If not removed properly, there will not be any default planner reference and the default planner will take up important space in the DB.
- Graduation Requirement has similar case, although graduation requirement can be referenced by more than one Academic Cohort, so we need
to check if there are still any reference to the graduation requirement document in other academic cohort document.
@param {String} cohortName: name of the Cohort that is going to be removed.
@return {int} number of cohort document removed or return nothing if removed process failed.
*/
export const removeCohort = function removeCohort(cohortName) {
// check if cohortName is a string
if (typeof cohortName != 'string') {
Expand Down Expand Up @@ -61,14 +76,18 @@ export const removeCohort = function removeCohort(cohortName) {
//delete all default planner related to the academic cohort.
//all this planner is unique to the academic cohort.
cohortDefaultPlanners = cohortDocument.cohortDefaultPlannerID;
for(var i = 0; i < cohortDefaultPlanners.length; i++){
Planner.remove({_id: cohortDefaultPlanners[i]});

if(cohortDefaultPlanners){
for(var i = 0; i < cohortDefaultPlanners.length; i++){
Planner.remove({_id: cohortDefaultPlanners[i]});
}
}

// finally, remove cohort
return AcademicCohort.remove({cohortName: cohortName});
}

/** call this method to clean the academic cohort collection properly.
*/
export const removeAllCohort = function removeAllCohort(){
//obtain all cohort
allCohort = AcademicCohort.find({}).fetch();
Expand All @@ -82,6 +101,10 @@ export const removeAllCohort = function removeAllCohort(){
}
}

/** Insert New graduationRequirement ID into the cohortGradRequirementID's array inside the specified academic cohort parameter.
* @param: {String} cohortName: name of the cohort to be updated
* @param: {String} newGradRequirementID: graduation requirement id to be stored in the document
*/
export const insertGradRequirementToCohort = function insertOneGradRequirementIDToCohort(cohortName, newGradRequirementID) {
const targetCohort = AcademicCohort.findOne({cohortName: cohortName});
const gradRequirementArray = targetCohort.cohortGradRequirementID;
Expand All @@ -97,6 +120,10 @@ export const insertGradRequirementToCohort = function insertOneGradRequirementID
});
}

/** Remove graduationRequirement ID from the cohortGradRequirementID's array inside the specified academic cohort parameter.
* @param: {String} cohortName: name of the cohort to be updated
* @param: {String} newGradRequirementID: graduation requirement id to be removed from the document
*/
export const removeGradRequirementFromCohort = function removeOneGraduationRequirementByID(cohortName, gradRequirementIDToRemove) {
const targetCohort = AcademicCohort.findOne({cohortName: cohortName});
const gradRequirementArray = targetCohort.cohortGradRequirementID;
Expand All @@ -116,7 +143,10 @@ export const removeGradRequirementFromCohort = function removeOneGraduationRequi
}
});
}

/** Updated the cohortGradRequirementID's array of the specified cohort with the new graduationRequirementID array.
* @param: {String} cohortName: name of the cohort to be updated
* @param: {String} newGradRequirementID: Array of graduation requirement IDs to replace the current existing one in the document.
*/
export const updateCohortGradRequirementIDs = function updateEntireCohortGraduationRequirementIDs(cohortName, newGradRequirementIDs) {
const targetCohort = AcademicCohort.find({cohortName: cohortName});
if (targetCohort.count() == 0) {
Expand All @@ -136,6 +166,10 @@ export const updateCohortGradRequirementIDs = function updateEntireCohortGraduat
});
}

/** Update the cohortDefaultPlannerID's array of the specified cohort with the new cohortDefaultPlannerID array.
* @param: {String} cohortName: name of the cohort to be updated
* @param: {String} newCohortDefaultPlannerIDs: Array of DefaulPlanner IDs to replace the current existing one in the document.
*/
export const updateCohortDefaultPlannerID = function updateCohortDefaultPlannerID(cohortName, newCohortDefaultPlannerIDs) {
const targetCohort = AcademicCohort.find({cohortName: cohortName});

Expand All @@ -157,6 +191,10 @@ export const updateCohortDefaultPlannerID = function updateCohortDefaultPlannerI
});
}

/** Insert New Focus Area ID into the focusAreaID's array inside the specified academic cohort parameter.
* @param: {String} cohortName: name of the cohort to be updated
* @param: {String} newFocusAreaID: new focus area id to be included in the document
*/
export const insertFocusAreaToCohort = function insertOneFocusAreaIDToAcadCohort(cohortName, newFocusAreaID) {

const targetCohort = AcademicCohort.findOne({cohortName: cohortName});
Expand All @@ -174,6 +212,10 @@ export const insertFocusAreaToCohort = function insertOneFocusAreaIDToAcadCohort
});
}

/** Remove a Focus Area ID from the focusAreaID's array inside the specified academic cohort parameter.
* @param: {String} cohortName: name of the cohort to be updated
* @param: {String} focusAreaIDToRemove: focus area id to be removed from the document
*/
export const removeFocusAreaFromCohort = function removeOneFocusAreaIDFromAcadCohort(cohortName, focusAreaIDToRemove) {
const targetCohort = AcademicCohort.findOne({cohortName: cohortName});
const focusAreaArray = targetCohort.cohortFocusAreaID;
Expand All @@ -193,7 +235,10 @@ export const removeFocusAreaFromCohort = function removeOneFocusAreaIDFromAcadCo
}
});
}

/** Update the cohortFocusAreaID's array of the specified cohort with the new cohortFocusAreaID array.
* @param: {String} cohortName: name of the cohort to be updated
* @param: {String} newCohortFocusAreaIDs: Array of FocusArea IDs to replace the current existing one in the document.
*/
export const updateCohortFocusAreaIDs = function(cohortName, newFocusAreaIDs) {
const targetCohort = AcademicCohort.find({cohortName: cohortName});
console.log("matchingDocument: " + targetCohort.count());
Expand Down Expand Up @@ -231,6 +276,7 @@ export const getCohortByID = function getCohortByID(cohortID) {
return AcademicCohort.findOne({_id: cohortID});
}

// obtain acadCohortDefeaultPlannerIDs of the requested cohortName
export const getAcadCohortDefaultPlannerIDs = function getAcadCohortDefaultPlannerID(cohortName) {
let resultCursor = AcademicCohort.find({cohortName: cohortName});
if (resultCursor.count() != 1) {
Expand All @@ -246,6 +292,7 @@ export const getAcadCohortDefaultPlannerIDs = function getAcadCohortDefaultPlann
return defaultPlanner.cohortDefaultPlannerID;
}

// obtain a repackaged version of acadCohortDefeaultPlannerIDs of the requested cohortName for UI
export const getRepackagedDefaultPlannerIDs = function getRepackagedDefaultPlannerIDs(cohortName) {
let result = getAcadCohortDefaultPlannerIDs(cohortName);
// result is an array
Expand Down
2 changes: 0 additions & 2 deletions imports/api/database-controller/focus-area/focusArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { SimpleSchema } from 'meteor/aldeed:simple-schema';
class FocusAreaCollection extends Mongo.Collection {
insert(focusAreaData, callBack){
const gradDocument = focusAreaData;
let result;
//validate document
return super.insert( gradDocument, callBack);
};
update(selector, modifier){
Expand Down
33 changes: 31 additions & 2 deletions imports/api/database-controller/focus-area/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const DEFAULT_MODULE_STATE = false;
* exists in the database. If not, the module will be removed from the lists.
*/
export const createNewFocusArea = function createNewFocusArea(name, listOfPrimary, listOfPrimaryFourThousands, listOfFourThousands, listOfNonPrimary){
// Uncomment the following lines to do module existence check
//checkedListPrimary = consolidateModuleArrayValidity(listOfPrimary);
//checkedListFourThousands = consolidateModuleArrayValidity(listOfFourThousands);
//checkedListNonPrimary = consolidateModuleArrayValidity(listOfNonPrimary);
Expand Down Expand Up @@ -67,6 +68,11 @@ export const consolidateModuleArrayValidity = function CheckValidityForListOfMod
return checkedModuleArray;
}

/** This method handles the creation of object list that is going to be stored in the Focus Area Document
* The module that is stored in the graduation requirement need to be present in the module database
* @param {[String]} moduleList: list of module that is going to be stored
* @return{object} object that is going to be stored under Focus Area Document
*/
export const createModuleListObject = function createNewListOfModuleObject(moduleList) {
// TO-DO: Check for module validity
const moduleToBeStored = {};
Expand All @@ -78,7 +84,10 @@ export const createModuleListObject = function createNewListOfModuleObject(modul

return moduleToBeStored;
}

/** This method return all the focus area requirements from array of focus area ID that is supplied to the method
* @param {[String]} focusRequirementIDArray: array of focus area ID
* @return {object} object containing all focus area requirements from the supplied focus Area ID arrays.
*/
export const getFocusAreaRequirement = function getFocusAreaRequirement(getFocusRequirementIDArray) {
const allfocusAreaRequirements = {
focusAreaPrimaryModules: {},
Expand All @@ -99,6 +108,12 @@ export const getFocusAreaRequirement = function getFocusAreaRequirement(getFocus
return allfocusAreaRequirements;
}

/** This method return all the focus area primary modules requirements information from array of focus area ID that is supplied to the method
* @param {[String]} focusRequirementIDArray: array of focus area ID
* @return {object} object containing all focus area primary requirements from the supplied focus Area ID arrays.
*
* Note: primary requirement does not involve 4k requirement.
*/
export const getFocusAreaPrimaryRequirement = function getFocusAreaPrimaryRequirement(getFocusRequirementIDArray) {
const focusAreaPrimaryRequirements = {};
let tempFocusAreaPrimaryDoc = {};
Expand All @@ -111,6 +126,11 @@ export const getFocusAreaPrimaryRequirement = function getFocusAreaPrimaryRequir
return focusAreaPrimaryRequirements;
}

/** This method return all level 4000 and above modules that are listed in the focus area from array of focus area ID that is supplied to the method
* @param {[String]} focusRequirementIDArray: array of focus area ID
* @return {object} object containing all level 4000 modules and above from the supplied focus Area ID arrays.
*
*/
export const getFocusArea4KRequirement = function getFocusArea4KRequirement(getFocusRequirementIDArray) {
const focusArea4KRequirements = {};
let tempFocusArea4KDoc = {};
Expand All @@ -123,6 +143,11 @@ export const getFocusArea4KRequirement = function getFocusArea4KRequirement(getF
return focusArea4KRequirements;
}

/** This method return level 4000 and above primary modules that are listed in the focus area from array of focus area ID that is supplied to the method
* @param {[String]} focusRequirementIDArray: array of focus area ID
* @return {object} object containing all level 4000 primary modules and above from the supplied focus Area ID arrays.
*
*/
export const getFocusAreaPrimary4KRequirement = function getFocusAreaPrimary4KRequirement(getFocusRequirementIDArray) {
const focusAreaPrimary4KRequirements = {};
let tempFocusPrimaryArea4KDoc = {};
Expand All @@ -134,7 +159,11 @@ export const getFocusAreaPrimary4KRequirement = function getFocusAreaPrimary4KRe
}
return focusAreaPrimary4KRequirements;
}

/** This method return all electives modules that are listed in the focus area from array of focus area ID that is supplied to the method
* @param {[String]} focusRequirementIDArray: array of focus area ID
* @return {object} object containing all electives module from focus areas which ids are supplied as parameter.
*
*/
export const getFocusAreaNonPrimaryRequirement = function getFocusAreaNonPrimaryRequirement(getFocusRequirementIDArray) {
const focusAreaNonPrimaryRequirements = {};
let tempFocusAreaNonPrimaryDoc = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const insertNewGradRequirementModuleData = function insertNewGraduationRe
/** This method handles the creation of object list that is going to be stored in the graduation Requirement Document
* The module that is stored in the graduation requirement need to be present in the module database
* @param {[String]} moduleList: list of module that is going to be stored
* @return{object} object that is going to be stored under requirementModules attributes in the GraduationRequirement Document
*/
export const createModuleListObject = function createModuleListObject(moduleList) {
// TO-DO: Check for module validity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

/**
Module Fulfilments collection contains Document that supports the graduation checker logic.
It contains information of Module replacement for the Module that is listed under the graduation requirement.
Module Fulfilments require Module Collection to not be empty. While currently it may not be checked.
In future development, the module listed under the Module Fulfilments collections are supposed to exist in the module Collection DB
**/

class ModuleFulfilmentCollection extends Mongo.Collection {
insert(fulfilmentData, callBack){
const fulfilmentDoc = fulfilmentData;
Expand Down
23 changes: 23 additions & 0 deletions imports/api/database-controller/module/module.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

/**
As the name suggested, Module Collection store information about the module that is offered in NUS.
Module Document should contain the following:
- moduleCode
- moduleName
- moduleDescription
- modulePrerequisite
- moduleCorequisite
- modulePreclusion
- moduleMC
- termOffered
Other than the termOffered which stored the information regarding when the module is being offered in form of json object,
other information is still stored in string. However this may not be the case in the future.
Prerequisite, corequisite and Preclusion of the module should be stored in format that support the module validity logic
that is yet to be implemented. Known issues in parsing the string of information containing these three information are:
- No standardized format of storing these information. Some immediately stored in logical way such as XXXX,YYYY, and ZZZZ.
However, some wrote it in sentences that obscure the connection between modules (XXXX AND YYYY or XXXX or YYYY,etc.)
- Some of the requirement might not be a module.
**/

class ModuleCollection extends Mongo.Collection{

insert(moduleData, callBack){
Expand Down
Loading

0 comments on commit 43b2c11

Please sign in to comment.