示例#1
0
        private void LectionForm_Load(object sender, EventArgs e)
        {
            lection lec = (lection)((LectionForm)sender).Tag;

            if (userProgress.lections.Count > 0)
            {
                if (userProgress.getLectionProgress(lec.id))
                {
                    MessageBox.Show("Лекция прочитана");
                }
                else
                {
                    MessageBox.Show("Лекция не прочитана");
                    userProgress.setLectionProgress(lec.id);
                }
            }
            else
            {
                MessageBox.Show("Лекция не прочитана");
                userProgress.setLectionProgress(lec.id);
            }


            this.mainText.Width = 900;
            this.title.Text     = lec.name;
            this.mainText.Text  = lec.text;
            int i = 1;

            if (lec.photos != null)
            {
                foreach (photo img in lec.photos)
                {
                    PictureBox pictureBox = new PictureBox();

                    pictureBox.ImageLocation = @img.filepath;

                    pictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
                    pictureBox.Dock     = DockStyle.Bottom;

                    Label label = new Label();
                    label.Dock = DockStyle.Bottom;
                    label.Font = new Font(FontFamily.GenericMonospace, 16, FontStyle.Bold);


                    label.Text = "Рисунок " + i;
                    i++;


                    this.Controls.Add(label);
                    this.Controls.Add(pictureBox);
                }
            }
        }
示例#2
0
        private void SeminarForm_Load(object sender, EventArgs e)
        {
            lec = (lection)((SeminarForm)sender).Tag;

            ans[] answer   = lec.ans;
            int[] rightAns = new int[5];
            int   o        = 0;

            foreach (ans a in answer)
            {
                rightAns[o] = a.num;
                o++;
            }

            //answer a = lec.answers;
            ans = rightAns;


            String[]         substrings = lec.text.Split('\n');
            HashSet <String> options    = new HashSet <string>();

            int i = 0;
            int t = 1;
            int q = 0;

            foreach (String ans in substrings)
            {
                opt      opt    = lec.opt[q];
                String[] subOpt = opt.text.Split(',');

                Label label = new Label();
                label.Text     = ans;
                label.Location = new Point(0, i);
                label.AutoSize = true;
                this.Controls.Add(label);
                int j = i + 10;

                GroupBox group = new GroupBox();
                group.Location = new Point(0, i + 10);
                group.Size     = new Size(150, 70);
                group.Name     = "opt";
                int start = 0;
                foreach (String optO in subOpt)
                {
                    RadioButton radio = new RadioButton();
                    radio.Text     = optO;
                    radio.Location = new Point(0, start);
                    radio.Name     = "radio";
                    group.Controls.Add(radio);

                    this.Controls.Add(group);
                    start += 20;
                }

                t++;
                i += 100;
                q++;
            }

            Button button = new Button();

            button.Text     = "Finish test";
            button.Name     = "finTest";
            button.AutoSize = true;
            button.Tag      = rightAns;

            button.Location = new Point(250, i + 10);
            button.Click   += new EventHandler(this.Btn_Click);
            this.Controls.Add(button);

            if (userProgress.getSeminarProgress(lec.id) == 1 || userProgress.getSeminarProgress(lec.id) == 2)
            {
                Control[] b = this.Controls.Find("finTest", false);
                b[0].Visible = false;
                List <Answer> list  = userProgress.getSeminarAnswers(lec.id);
                bool[]        wrong = getWrong(list);


                int[] right = ans;
                int   count = 0;

                int[] choosed = new int[list.Count];
                int   p       = 0;
                foreach (Answer an in list)
                {
                    choosed[p] = an.num;
                    p++;
                }

                for (int a = 0; a < 5; a++)
                {
                    if (right[a] == choosed[a])
                    {
                        wrong[a] = true;
                        count++;
                    }
                }

                isDone(count);

                Control[] groupBox  = this.Controls.Find("opt", false);
                int       countList = 0;
                foreach (Control con in groupBox)
                {
                    int       qwe   = 0;
                    Control[] radio = con.Controls.Find("radio", false);
                    foreach (Control rad in radio)
                    {
                        if (qwe + 1 == choosed[countList])
                        {
                            ((RadioButton)rad).Checked = true;

                            break;
                        }
                        else
                        {
                            qwe++;
                            continue;
                        }
                    }

                    countList++;
                }

                setOptColor(list, wrong);
            }
        }