/// <summary>
        /// Gets a SuccessMap for the given Program.
        /// </summary>
        /// <param name="program">The Program to retrieve a SuccessMap for.</param>
        public Task <SuccessMap> getSuccessMapAsync(Program program)
        {
            //Can't retrieve success map without knowing the program to retrieve from (eventually)
            if (program == null)
            {
                return(null);
            }

            //Return program success map if already retrieved
            //Don't refresh due to low frequency of change
            if (program.successMap != null)
            {
                return(Task.FromResult(program.successMap));
            }

            DatabaseSelect dbSelect        = new DatabaseSelect();
            DataTable      successMapTable = dbSelect.SelectSuccessMap(program.ID);

            //Make sure a success map was retrieved
            if (successMapTable != null && successMapTable.Rows.Count > 0)
            {
                SuccessMap successMap = DataInterpreter.getSuccessMap(successMapTable.Rows[0]);
                program.successMap = successMap;
                return(Task.FromResult(successMap));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static StudentSuccessMap getStudentSuccessMap(DataRow studentSuccessPlanData)
        {
            string starID    = studentSuccessPlanData["StarID"].ToString();
            int    programID = (int)studentSuccessPlanData["PrgmID"];

            DatabaseSelect dbSelect        = new DatabaseSelect();
            DataTable      successMapTable = dbSelect.SelectSuccessMap(programID);

            //Make sure a success map was retrieved
            if (successMapTable != null && successMapTable.Rows.Count > 0)
            {
                DataRow successMapData = successMapTable.Rows[0];

                int    ID   = (int)successMapData["SMID"];
                string name = successMapData["SMName"].ToString();

                //Create student success map
                SuccessMap successMap = new StudentSuccessMap(ID, name, starID, programID);

                //Populate success map base data
                populateSuccessMap(ref successMap); //ref does not support polymorphism
                StudentSuccessMap studentSuccessMap = (StudentSuccessMap)successMap;

                //Populate Student Success Map specific data
                DataTable completedObjsTable = dbSelect.SelectCompletedObjectives(starID);
                if (completedObjsTable != null)
                {
                    //Add completed objectives to success map
                    foreach (DataRow completedObjData in completedObjsTable.Rows)
                    {
                        string objectiveID = completedObjData["ObjID"].ToString();
                        studentSuccessMap.addCompletedObjective(objectiveID);
                    }
                }

                return(studentSuccessMap);
            }
            else
            {
                return(null);
            }
        }