public List<KnowledgePoint> GetKnowledgePointList(string courseCode, string CourseNumber)
        {
            List<KnowledgePoint> list = new List<KnowledgePoint>();
            KnowledgePointTableAdapter kpAdapter = new KnowledgePointTableAdapter();
            KnowledgePointParentChildRelationTableAdapter kpRelationAdatper = new KnowledgePointParentChildRelationTableAdapter();
            KnowledgePointAssetRelationTableAdapter kpAssetAdapter = new KnowledgePointAssetRelationTableAdapter();
            CourseTableAdapter courseAdapter = new CourseTableAdapter();
            var courseIdList = courseAdapter.GetIdByCourseDetails(courseCode, Convert.ToInt32(CourseNumber));
            int courseId = courseIdList[0].Id;
            PriorityTableAdapter priorityAdapter = new PriorityTableAdapter();
            AssetTableAdapter assetAdapter = new AssetTableAdapter();
            AssetTypeTableAdapter assetTypeAdapter = new AssetTypeTableAdapter();

            foreach (var row in kpAdapter.GetKnowledgePointByCourseId(courseId))
            {
                KnowledgePoint kp = new KnowledgePoint(row.Id, courseCode + CourseNumber, row.Name, row.xPos, row.yPos);
                kp.priority = (Priority)Enum.Parse(typeof(Priority), priorityAdapter.GetPriorityById(row.Priority)[0].Priority);
                kp.createDate = row.CreatedTime.ToString("G");
                kp.modifiedDate = row.LastModifiedTime.ToString("G");
                foreach (var relation in kpRelationAdatper.GetParentIdByChildId(row.Id))
                {
                    kp.addParent(relation.ParentKnowledgePointId);
                }

                foreach (var relatedAsset in kpAssetAdapter.GetAssetListByKnowledgePointId(row.Id))
                {
                    foreach (var assetPointer in assetAdapter.GetAssetDetailById(relatedAsset.AssetId))
                    {
                        AssetType type = (AssetType)Enum.Parse(typeof(AssetType), assetTypeAdapter.GetDataById(assetPointer.AssetType)[0].AssetType);
                        if (type == AssetType.PDF | type == AssetType.PPT | type == AssetType.Audio | type == AssetType.Video)
                        {
                            AssetPointer pointer = new AssetPointer(assetPointer.Id, assetPointer.Path + assetPointer.AssetName, type, relatedAsset.Start, relatedAsset.End);
                            kp.addAsset(pointer);
                        }
                        else if (type == AssetType.SelfTest)
                        {
                            int selftestId = Convert.ToInt32(assetPointer.AssetName);
                            SelfTestTableAdapter stAdapter = new SelfTestTableAdapter();
                            var st = stAdapter.GetSelfTestDataById(Convert.ToInt32(assetPointer.AssetName))[0];
                            SelfTestQuesion stQuestion = new SelfTestQuesion(st.Question, st.AnswerKey);
                            kp.addTestQuestion(stQuestion);
                        }
                        else if (type == AssetType.QandA)
                        {
                            int messageId = Convert.ToInt32(assetPointer.AssetName);
                            QandATableAdapter qaAdapter = new QandATableAdapter();
                            var qa = qaAdapter.GetQAsById(messageId)[0];
                            Message message = new Message(qa.Id, "user Id: " + qa.AskedBy, qa.Question);
                            try
                            {
                                string answerTypeString = (new AnswerTypeTableAdapter()).GetDataById(qa.AnswerType)[0].AnswerType;
                                Answer answer = new Answer(answerTypeString, qa.Answer);

                            }
                            catch
                            {

                            }
                            finally {
                                message.addAnswer(new Answer(AnswerType.NoAnswer, ""));
                            }

                            message.createTime = qa.CreatedTime.ToString("G");
                            kp.messageBox.lastModifiedDate = qa.CreatedTime.ToString("G");
                            kp.addMessage(message);
                        }
                    }
                }
                kp.createDate = row.CreatedTime.ToString("G");
                kp.modifiedDate = row.LastModifiedTime.ToString("G");
                list.Add(kp);
            }
            return list;
        }
 public void addTestQuestion(SelfTestQuesion question)
 {
     this.testSet.Add(question);
 }
        public List<KnowledgePoint> GetKnowledgePoints(string courseId, string section)
        {
            KnowledgePoint p1 = new KnowledgePoint(1, courseId + " " + section, "binary system", 0, 0);
            AssetPointer ap1 = new AssetPointer(1001, "/L1/introduction.pdf", AssetType.PDF, 3, 8);
            p1.addAsset(ap1);
            AssetPointer ap2 = new AssetPointer(1002, "/L1/introduction.ppt", AssetType.PPT, 1, 2);
            p1.addAsset(ap2);
            AssetPointer ap3 = new AssetPointer(1003, "/Asset/COMP_2611/Lecture_1/sample.wav", AssetType.Audio, 0, 2);
            p1.addAsset(ap3);
            AssetPointer ap4 = new AssetPointer(1004, "/Asset/COMP_2611/Lecture_1/COMP2611.mp4", AssetType.Video, 0, 50);
            p1.addAsset(ap4);

            //create messages for KP

            Message q1 = new Message("ypy", "Is this the question 1?");
            Message q2 = new Message("rv", "Is this the question 2?");
            Message answeredQ1 = new Message("wsf", "Is this answered question 3?");
            answeredQ1.addAnswer(new Answer(AnswerType.Audio, "\\path\\" + answeredQ1.messageId + "\\Q3\\answer.acc"));
            Message answeredQ2 = new Message("tmy", "Is this answered question 4?");
            answeredQ2.addAnswer(new Answer(AnswerType.Text, "This is the answer of Q4"));
            p1.addMessage(q1);
            p1.addMessage(q2);
            p1.addMessage(answeredQ1);
            p1.addMessage(answeredQ2);

            SelfTestQuesion stq1 = new SelfTestQuesion("This is self test question Q1 with answer", "This is answer key");
            SelfTestQuesion stq2 = new SelfTestQuesion("This is self test question Q2 without answer (might be drawing answer)");
            p1.addTestQuestion(stq1);
            p1.addTestQuestion(stq2);
            p1.setPriority(Priority.High);

            KnowledgePoint p2 = new KnowledgePoint(2, courseId + "_" + section, "binary addition", 0, 200);
            p2.addParent(p1.id);
            AssetPointer ap7 = new AssetPointer(1007, "/L1/introduction.ppt", AssetType.PPT, 5, 6);
            p2.addAsset(ap7);
            p2.setPriority(Priority.Medium);

            KnowledgePoint p3 = new KnowledgePoint(3, courseId + "_" + section, "binary substraction", 400, 200);
            p3.addParent(p1.id);
            AssetPointer ap8 = new AssetPointer(1008, "/L1/introduction.ppt", AssetType.PPT, 7, 9);
            p3.addAsset(ap8);
            p3.setPriority(Priority.Medium);

            KnowledgePoint p4 = new KnowledgePoint(4, courseId + "_" + section, "binary operation", 0, 400);
            p4.addParent(p2.id);
            p4.addParent(p3.id);
            AssetPointer ap9 = new AssetPointer(1009, "/L1/introduction.ppt", AssetType.PPT, 10, 10);
            p4.addAsset(ap9);
            p4.setPriority(Priority.Low);

            List<KnowledgePoint> points = new List<KnowledgePoint>();
            points.Add(p1);
            points.Add(p2);
            points.Add(p3);
            points.Add(p4);

            return points;
        }