Ejemplo n.º 1
0
        public void AddPractice(string fileName)
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreComments = true;
            settings.IgnoreProcessingInstructions = true;
            settings.IgnoreWhitespace             = true;
            XmlReader reader = XmlReader.Create(fileName, settings);

            reader.MoveToContent();

            if (!reader.ReadToFollowing("Type"))
            {
                return;
            }

            int type = reader.ReadElementContentAsInt();

            Grid grdPage = new Grid();

            cnvMain.Children.Add(grdPage);
            grdPageList.Add(grdPage);
            iNumPage++;

            if (iCurPage == 0)
            {
                grdPage.Visibility = Visibility.Visible;
                iCurPage           = 1;
            }
            else
            {
                grdPage.Visibility = Visibility.Collapsed;
            }

            switch (type)
            {
            case 0:
            {
                SelectionPartControl control = new SelectionPartControl();
                control.LoadContentFromXml(fileName);
                control.Tag = type;
                grdPage.Children.Add(control);
                spcList.Add(control);
                break;
            }

            case 1:
            {
                FillInBlankControl control = new FillInBlankControl();
                control.LoadContentFromXML(fileName);
                control.Tag = type;
                grdPage.Children.Add(control);
                fbcList.Add(control);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        public void FixWrongSentence()
        {
            if (iCurPage == 0)
            {
                return;
            }

            SelectionPartControl control = grdPageList[iCurPage - 1].Children[0] as SelectionPartControl;

            if (control != null)
            {
                control.FixWrongSentences();
                return;
            }

            FillInBlankControl fcontrol = grdPageList[iCurPage - 1].Children[0] as FillInBlankControl;

            if (fcontrol != null)
            {
                fcontrol.FixWrongSentences();
                return;
            }
        }
Ejemplo n.º 3
0
        //Tải các Task lên ,tham so gom:
        //  streams: chứa dữ liệu xml (file xml dưới dạng binary).dùng trực tiếp xml để biết loại bài tập
        public void AddPractices(List<Stream> streams)
        {
            if (streams == null)
                return;

            ResetAll();

            
            Stream stream;
            XmlReader reader;
            int type;

            for (int i = 0; i < streams.Count; ++i)
            {
                stream = streams[i];

                //Lấy type từ xml stream
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.CloseInput = false;

                reader = XmlReader.Create(stream,settings);
                if(reader == null)continue;
                if (!reader.ReadToFollowing("Type"))
                    continue;
                type = reader.ReadElementContentAsInt();
                reader.Close();
                stream.Seek(0, SeekOrigin.Begin);

                switch (type)
                {
                        //trac nghiem
                    case 0:
                        {
                            SelectionPartControl control = new SelectionPartControl();
                            control = new SelectionPartControl();

                            control.LoadContentFromStream(stream);

                            cnvMain.Children.Add(control);
                            spcList.Add(control);
                            break;                            
                        }

                        //dien tu
                    case 1:
                        {
                            FillInBlankControl control = new FillInBlankControl();
                            control.LoadContentFromStream(stream);
                            control.Tag = type;
                            fbcList.Add(control);
                            break;
                        }
                }

                stream.Dispose();
            }            
        }
Ejemplo n.º 4
0
        public void AddPractice(string fileName)
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            settings.IgnoreProcessingInstructions = true;
            settings.IgnoreWhitespace = true;
            XmlReader reader = XmlReader.Create(fileName, settings);

            reader.MoveToContent();

            if (!reader.ReadToFollowing("Type"))
                return;

            int type = reader.ReadElementContentAsInt();

            Grid grdPage = new Grid();
            cnvMain.Children.Add(grdPage);
            grdPageList.Add(grdPage);
            iNumPage++;

            if (iCurPage == 0)
            {
                grdPage.Visibility = Visibility.Visible;
                iCurPage = 1;
            }
            else
                grdPage.Visibility = Visibility.Collapsed;

            switch (type)
            {
                case 0:
                    {
                        SelectionPartControl control = new SelectionPartControl();
                        control.LoadContentFromXml(fileName);
                        control.Tag = type;
                        grdPage.Children.Add(control);
                        spcList.Add(control);
                        break;
                    }

                case 1:
                    {
                        FillInBlankControl control = new FillInBlankControl();
                        control.LoadContentFromXML(fileName);
                        control.Tag = type;
                        grdPage.Children.Add(control);
                        fbcList.Add(control);
                        break;
                    }
            }
        }
Ejemplo n.º 5
0
        //Tải các Task lên ,tham so gom:
        //  streams: chứa dữ liệu xml (file xml dưới dạng binary).dùng trực tiếp xml để biết loại bài tập
        public void AddPractices(List <Stream> streams)
        {
            if (streams == null)
            {
                return;
            }

            ResetAll();


            Stream    stream;
            XmlReader reader;
            int       type;

            for (int i = 0; i < streams.Count; ++i)
            {
                stream = streams[i];

                //Lấy type từ xml stream
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.CloseInput = false;

                reader = XmlReader.Create(stream, settings);
                if (reader == null)
                {
                    continue;
                }
                if (!reader.ReadToFollowing("Type"))
                {
                    continue;
                }
                type = reader.ReadElementContentAsInt();
                reader.Close();
                stream.Seek(0, SeekOrigin.Begin);

                switch (type)
                {
                //trac nghiem
                case 0:
                {
                    SelectionPartControl control = new SelectionPartControl();
                    control = new SelectionPartControl();

                    control.LoadContentFromStream(stream);

                    cnvMain.Children.Add(control);
                    spcList.Add(control);
                    break;
                }

                //dien tu
                case 1:
                {
                    FillInBlankControl control = new FillInBlankControl();
                    control.LoadContentFromStream(stream);
                    control.Tag = type;
                    fbcList.Add(control);
                    break;
                }
                }

                stream.Dispose();
            }
        }