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 string insertAnswerToMessage(string courseCode, string courseNumber, string messageId, string answer, string answerTypeId)
 {
     QandATableAdapter qaAdapter = new QandATableAdapter();
     CourseTableAdapter courseAdapter = new CourseTableAdapter();
     var table = courseAdapter.GetIdByCourseDetails(courseCode, Convert.ToInt32(courseNumber));
     if (table.Count > 0)
     {
         if (qaAdapter.GetQAsById(Convert.ToInt32(messageId)).Count > 0)
         {
             qaAdapter.AddAnswerToQuestion(answer, Convert.ToInt32(answerTypeId), DateTime.Now, Convert.ToInt32(messageId));
             return "success";
         }
     }
     return "failed";
 }