/// <summary>
        /// Gets a StudentSuccessMap for the student with the given star ID and Program.
        /// </summary>
        /// /// <param name="starID">The Star ID of the student to retrieve a StudentSuccessMap for.</param>
        /// <param name="program">The Program to retrieve a SuccessMap for.</param>
        public Task <StudentSuccessMap> getStudentSuccessMapAsync(string starID, 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 && program.successMap is StudentSuccessMap)
            {
                return(Task.FromResult((StudentSuccessMap)program.successMap));
            }

            DatabaseSelect dbSelect = new DatabaseSelect();
            DataTable      studentSuccessMapTable = dbSelect.SelectStudentSuccessMap(starID, program.ID);

            //Make sure a student success map was retrieved
            if (studentSuccessMapTable != null && studentSuccessMapTable.Rows.Count > 0)
            {
                StudentSuccessMap successMap = DataInterpreter.getStudentSuccessMap(studentSuccessMapTable.Rows[0]);
                program.successMap = successMap;
                return(Task.FromResult(successMap));
            }
            else
            {
                return(null);
            }
        }
Beispiel #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);
            }
        }