Ejemplo n.º 1
0
        public static string getSql(string sql, DMClient dmc)
        {
            string retValue = null;

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, dmc.origUrl, dmc.token, true);
            DataTable     dt             = rr.execute();
            StringBuilder sb             = new StringBuilder();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    sb.Append(dc.ColumnName + "\t");
                }
                sb.Append(Environment.NewLine);
                foreach (DataRow dr in dt.Rows)
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        sb.Append(dr[dc].ToString() + "\t");
                    }
                    sb.Append(Environment.NewLine);
                }
            }
            retValue = sb.ToString() + Environment.NewLine;
            return(retValue);
        }
Ejemplo n.º 2
0
        private void btnLogNB_Click(object sender, EventArgs e)
        {
            DMClient dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);

            BbQuery.cc          = new System.Net.CookieContainer();
            BbQuery.cc.Capacity = 1000;
            BbQuery.BbUrl       = dmc.origUrl;
            if (BbQuery.isMoodle(BbQuery.BbUrl))
            {
                MoodleLogin lg = new MoodleLogin();
                lg.ShowDialog();
                lg.Dispose();
                lg = null;
            }
            else
            {
                // Login lg = new Login();
                BbQuery.getBbParams();
                LoginXPXB lg = new LoginXPXB();

                lg.ShowDialog();
                lg.Dispose();
                lg = null;
            }
            GC.Collect();
        }
Ejemplo n.º 3
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            DMClient   dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);
            UpdateFile uf  = new UpdateFile();

            uf.dmc = dmc;
            uf.ShowDialog();
        }
Ejemplo n.º 4
0
        private void btnProperties_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            DMClient dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);

            tbMemo.AppendText(dmc.listProperties()); //t(dmc.getToken() + Environment.NewLine);
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 5
0
        public DataTable getSqldt(string sql, DMClient dmc)
        {
            DataTable retValue;

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, dmc.origUrl, dmc.token, true);
            retValue = rr.execute();
            return(retValue);
        }
Ejemplo n.º 6
0
        private void managePreceptorsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Preceptors pr  = new Preceptors();
            DMClient   dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);

            // pr.Text = dmc.pluginUrl;
            pr.Tag = dmc;
            pr.Show();
        }
Ejemplo n.º 7
0
        private void gradebookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Gradebook gr  = new Gradebook();
            DMClient  dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);

            gr.Text = dmc.pluginUrl;
            gr.Tag  = dmc;
            gr.Show();
        }
Ejemplo n.º 8
0
        private void button2_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            DMClient dmc  = new DMClient(((myListItem)cbClients.SelectedItem).id, c);
            string   html = dmc.listFiles();

            tbMemo.AppendText(html);
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 9
0
        private void bntStudents_Click(object sender, EventArgs e)
        {
            StudentSurveys sf  = new StudentSurveys();
            DMClient       dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);

            sf.Text = dmc.pluginUrl;
            sf.Tag  = dmc;
            sf.Show();
        }
Ejemplo n.º 10
0
        private void mnSql_Click(object sender, EventArgs e)
        {
            SqlFormWeb sf  = new SqlFormWeb();
            DMClient   dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);

            sf.Text = dmc.pluginUrl;
            sf.Tag  = dmc;
            //  sf.ShowDialog();
            sf.Show();
        }
Ejemplo n.º 11
0
        private void Attempts_Load(object sender, EventArgs e)
        {
            dmc = (DMClient)this.Tag;
            DataTable dt = BbQuery.getAttempts(course_pk, dmc.origUrl, dmc.token);

            //  atGrid.AutoGenerateColumns = false;
            atGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
            atGrid.DataSource = dt;
            atGrid.Columns["attempt_date"].DefaultCellStyle.Format = "d";
            atGrid.Columns["score"].DefaultCellStyle.Format        = "N2";
            atGrid.Columns["score"].ValueType = typeof(Single);
        }
Ejemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            // get selected index and the id
            Cursor.Current = Cursors.WaitCursor;
            DMClient dmc   = new DMClient(((myListItem)cbClients.SelectedItem).id, c);
            string   token = dmc.getToken();

            if (token != null && (c.DMClients.Single(t => t.id == dmc.id).token == null || !c.DMClients.Single(t => t.id == dmc.id).token.Equals(token)))
            {
                c.DMClients.Single(t => t.id == dmc.id).token = token;
                Save();
            }
            tbMemo.AppendText(token); //t(dmc.getToken() + Environment.NewLine);
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 13
0
        private void btnExec_Click(object sender, EventArgs e)
        {
            dmc = (DMClient)this.Tag;
            string token = dmc.token;

            if (!tbSql.Text.Equals(String.Empty))
            {
                if (token == null || token.Equals(""))
                {
                    dmc.token = dmc.getToken();
                }
            }
            tbResult.AppendText(DMClient.getSql(tbSql.Text, dmc));
            // MessageBox.Show(dmc.name);
        }
Ejemplo n.º 14
0
        private void btnExec_Click(object sender, EventArgs e)
        {
            dmc = (DMClient)this.Tag;
            string token = dmc.token;

            if (!tbSql.Text.Equals(String.Empty))
            {
                if (token == null || token.Equals(""))
                {
                    dmc.token = dmc.getToken();
                }
            }
            QTIUtility.Logger.__SpecialLogger("SQL: " + dmc.name + Environment.NewLine + tbSql.Text + Environment.NewLine + "-- end --" + Environment.NewLine);
            tbResults.DocumentText += DMClient.getSqlHTML(tbSql.Text, dmc);
        }
Ejemplo n.º 15
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            dmc = (DMClient)this.Tag;
            string token = dmc.token;
            string tbSql = null;
            // sql goes here
            StringBuilder sb = new StringBuilder();

            sb.Append("select c.pk1 as cpk1,c.course_name,c.course_id,c.dtmodified as cmod,cnt.pk1 as cntpk1, cnt.title,cnt.start_date,cnt.end_date, ca.pk1 as capk1 ");
            sb.Append("  ,(case  when cnt.end_date is null then {d '" + ft + "'}  else cnt.end_date  end) as sort_date");
            // sb.Append(" ,(select pk1 from course_main where pk1 = replace(c.course_id,'" + BbShadowCoursePrefix + "','')) as underlyingPk1 ");

            sb.Append("  ,(case when (select count(pk1) from course_main ");
            sb.Append(" where pk1 = replace(c.course_id,'" + BbShadowCoursePrefix + "','')) > 0 then  ");
            sb.Append(" (select pk1 from course_main where pk1 = replace(c.course_id,'" + BbShadowCoursePrefix + "','')) ");
            sb.Append(" else c.pk1  end) as underlyingpk1  ");
            sb.Append(" ,ca.multiple_attempts_ind as m_ind ");
            sb.Append(" ,(select count(a.pk1) from attempt a inner join gradebook_grade gb on a.gradebook_grade_pk1 = gb.pk1 where gb.gradebook_main_pk1 = gm.pk1 and gb.course_users_pk1 = cu.pk1) as acount ");

            sb.Append(" ,(select min(a.status) from attempt a inner join gradebook_grade gb on a.gradebook_grade_pk1 = gb.pk1 where gb.gradebook_main_pk1 = gm.pk1 and gb.course_users_pk1 = cu.pk1 ) as status ");
            sb.Append(" ,cu.available_ind,cu.row_status ");
            sb.Append(" from course_main c inner join course_contents cnt on cnt.crsmain_pk1 = c.pk1 ");
            sb.Append("  inner join course_assessment ca on ca.pk1 = (select link_source_pk1 from link where course_contents_pk1 = cnt.pk1)  ");
            sb.Append(" inner join course_users cu on cu.crsmain_pk1 = c.pk1 ");
            sb.Append(" inner join users u on u.pk1 = cu.users_pk1 ");
            sb.Append(" inner join gradebook_main gm on gm.qti_asi_data_pk1 = ca.qti_asi_data_pk1 and gm.crsmain_pk1 = c.pk1");
            sb.Append(" where u.user_id = '" + tbUsername.Text.Trim() + "' and cnt.CNTHNDLR_HANDLE  = 'resource/x-bb-asmt-survey-link' ");
            sb.Append(" and cnt.AVAILABLE_IND = 'Y' and cu.role = 'S' ");
            //  sb.Append(" and cu.available_ind = 'Y' and cu.row_status = 0 ");
            sb.Append("and (c.course_id like '" + BbShadowCourseId + "%' escape '!') "); // for only shadow courses
            //  sb.Append(" and ((cnt.end_date is null) or (not cnt.end_date is null and cnt.end_date >= {ts '" + mt + "'})) ");
            //  sb.Append(" and ((cnt.start_date is null) or (not cnt.start_date is null and cnt.start_date <= {ts '" + mt + "'})) ");
            sb.Append(" order by sort_date,cnt.title,c.course_name,c.course_id");
            tbSql = sb.ToString();

            tbMemo.AppendText(tbSql + Environment.NewLine);

            if (!String.IsNullOrEmpty(tbSql))
            {
                if (token == null || token.Equals(""))
                {
                    dmc.token = dmc.getToken();
                }
            }
            //   QTIUtility.Logger.__SpecialLogger("SQL: " + dmc.name + Environment.NewLine + tbSql.Text + Environment.NewLine + "-- end --" + Environment.NewLine);
            tbMemo.AppendText(DMClient.getSql(tbSql, dmc));
        }
Ejemplo n.º 16
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string theUrl  = "";
            string baseurl = tbUrl.Text;

            if (!baseurl.Contains("moodle"))
            {
                if (baseurl.IndexOf("webapps") > 0)
                {
                    // already is full address
                    if (baseurl.EndsWith(".jsp"))
                    {
                        int l = baseurl.LastIndexOf("/");
                        baseurl = baseurl.Substring(0, l + 1);
                    }
                }
                else
                {
                    if (baseurl.EndsWith(".php"))
                    {
                        int l = baseurl.LastIndexOf("/");
                        baseurl = baseurl.Substring(0, l + 1);
                    }
                    else
                    {
                        baseurl += DMClient.pluginStem;
                    }
                }
                if (tbUrl.Text.EndsWith(".php"))
                {
                    theUrl = baseurl + "auth_1.php";
                }
                else
                {
                    theUrl = baseurl + "auth_1.jsp";
                }
            }
            else
            {
                theUrl = baseurl;
            }
            MessageBox.Show(DMClient.testConnection(theUrl), "Connection Test");
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 17
0
        private void btnUser_Click(object sender, EventArgs e)
        {
            UserForm     uf        = new UserForm();
            string       firstname = "PPPPPPPPPPPPPPPPP";
            string       lastname  = "PPPPPPPPPPPPPPPPPPPP";
            DialogResult dr        = uf.ShowDialog();

            if (dr == DialogResult.OK)
            {
                firstname = uf.tbFirstName.Text;
                lastname  = uf.tbLastName.Text;
            }
            uf.Dispose();
            if (dr == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                DMClient dmc = new DMClient(((myListItem)cbClients.SelectedItem).id, c);
                tbMemo.AppendText(dmc.getUser(firstname, lastname)); //t(dmc.getToken() + Environment.NewLine);
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 18
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddEdit  ae      = new AddEdit();
            DMClient dmc     = new DMClient();
            string   btnName = (sender as Button).Name;

            if (btnName.Equals("btnAdd"))
            {
                ae.Text         = "Add Record";
                ae.button1.Text = "Add";
            }
            else
            {
                ae.Text         = "Edit Record";
                ae.button1.Text = "Save";
                dmc             = new DMClient(((myListItem)cbClients.SelectedItem).id, c);
                ae.tbName.Text  = dmc.name;
                ae.tbUrl.Text   = dmc.origUrl;
            }
            DialogResult dr = ae.ShowDialog();

            if (dr == DialogResult.OK)
            {
                // save or create

                if (btnName.Equals("btnEdit"))
                {
                    bool dirty = false;
                    if (!dmc.name.Equals(ae.tbName.Text.Trim()))
                    {
                        dmc.name = ae.tbName.Text.Trim();
                        c.DMClients.Single(t => t.id == dmc.id).Name = dmc.name;
                        myListItem nItem = new myListItem(dmc.id, dmc.name);
                        cbClients.Items[cbClients.SelectedIndex] = nItem;
                        cbClients.Update();
                        Application.DoEvents();
                        dirty = true;
                    }
                    if (!dmc.origUrl.Equals(ae.tbUrl.Text.Trim()))
                    {
                        string baseUrl = ae.tbUrl.Text.Trim();
                        // check if only base
                        if (!(baseUrl.Contains("moodle") || baseUrl.EndsWith("php")))
                        {
                            if (!(baseUrl.Contains("webapp") || baseUrl.EndsWith(".aspx")))
                            {
                                baseUrl    += DMClient.pluginStem + DMClient.xgetFile;
                                dmc.origUrl = baseUrl;
                            }
                        }
                        dmc.origUrl = baseUrl;
                        c.DMClients.Single(t => t.id == dmc.id).Url = dmc.origUrl;
                        dirty = true;
                    }

                    if (dirty)
                    {
                        dmc.modified = DateTime.Now;
                        c.DMClients.Single(t => t.id == dmc.id).modified = dmc.modified;
                        Save();
                    }
                }
                else // add
                {
                    dmc.name = ae.tbName.Text.Trim();
                    string baseUrl = ae.tbUrl.Text.Trim();
                    // check if only base
                    if (!baseUrl.Contains("moodle"))
                    {
                        if (!(baseUrl.Contains("webapp") || baseUrl.EndsWith(".aspx")))
                        {
                            baseUrl    += DMClient.pluginStem + DMClient.xgetFile;
                            dmc.origUrl = baseUrl;
                        }
                    }
                    dmc.origUrl  = baseUrl;
                    dmc.created  = DateTime.Now;
                    dmc.modified = dmc.created;
                    int id = c.DMClients.Max(t => t.id);
                    dmc.id = id + 1;
                    Clients.DMClientsLocalType newClient = new Clients.DMClientsLocalType();
                    newClient.id       = dmc.id;
                    newClient.Name     = dmc.name;
                    newClient.created  = dmc.created;
                    newClient.modified = dmc.modified;
                    newClient.Url      = dmc.origUrl;
                    c.DMClients.Add(newClient);
                    Save();
                    PopulateComboBox();
                    foreach (myListItem o in cbClients.Items)
                    {
                        if (o.name.Equals(dmc.name))
                        {
                            cbClients.SelectedItem = o;
                        }
                    }
                    cbClients.Update();
                }
            }
        }
Ejemplo n.º 19
0
 private void CatsForm_Load(object sender, EventArgs e)
 {
     dmc = (DMClient)this.Tag;
 }
Ejemplo n.º 20
0
        public static string getSqlHTML(string sql, DMClient dmc)
        {
            string retValue   = null;
            bool   compressed = ((dmc.origUrl.Contains(".php") && dmc.origUrl.Contains("cc1")) || dmc.origUrl.ToLower().Contains("postgres")) ? false : true;

            QTIUtility.RequesterAsync rr = new QTIUtility.RequesterAsync(sql, dmc.origUrl, dmc.token, compressed);
            DataTable dt = rr.execute();

            if (dt.Columns.Contains("qdecode") || dt.Columns.Contains("QDECODE"))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string data = QTIUtility.BbQuery.getStringFromData(dr["qdecode"].ToString());
                    System.Xml.Linq.XElement qd = System.Xml.Linq.XElement.Parse(data);
                    var qs = qd.Descendants(XName.Get("mat_formattedtext"));
                    if (qs.Count() > 0)
                    {
                        dr["qdecode"] = QTIUtility.Utilities.StripTags(qs.FirstOrDefault().Value);
                    }
                }
            }
            if (dt.Columns.Contains("qrscore") || dt.Columns.Contains("QRSCORE"))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string data = QTIUtility.BbQuery.getStringFromData(dr["qrscore"].ToString());
                    System.Xml.Linq.XElement qd = System.Xml.Linq.XElement.Parse(data);
                    string sc = "";
                    var    qs = qd.Descendants(XName.Get("score_value"));
                    if (qs.Count() > 0)
                    {
                        foreach (string v in qs)
                        {
                            sc += ":" + v;
                        }
                    }
                    qs = qd.Descendants(XName.Get("score_maximum"));
                    if (qs.Count() > 0)
                    {
                        foreach (string v in qs)
                        {
                            sc += ":" + v;
                        }
                    }
                    dr["qrscore"] = sc.Substring(1);
                }
            }

            StringBuilder sb = new StringBuilder("<table style=\"font-family: Tahoma, Arial, sans-serif;font-size:12px\" >");

            sb.Append("<tr>");
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    sb.Append("<th>" + dc.ColumnName + "</th>");
                }
                sb.Append("</tr>");
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("<tr>");
                    foreach (DataColumn dc in dt.Columns)
                    {
                        sb.Append("<td>" + dr[dc].ToString() + "</td>");
                    }
                    sb.Append("</tr>");
                }
                sb.Append("</table>");
            }
            retValue = sb.ToString();
            return(retValue);
        }
Ejemplo n.º 21
0
 private void Gradebook_Load(object sender, EventArgs e)
 {
     dmc = (DMClient)this.Tag;
 }
Ejemplo n.º 22
0
 private void CatsForm_Load(object sender, EventArgs e)
 {
     dmc          = (DMClient)this.Tag;
     dmc.isOracle = dmc.getOracle();
 }
Ejemplo n.º 23
0
 // Dsn=Excel Files;dbq=C:\utility\EACDMUtiliy\EACDM Utility\EACDMLinqUtiliy\WorkingData\preceptors.xls;defaultdir=C:\utility\EACDMUtiliy\EACDM Utility\EACDMLinqUtiliy\WorkingData;driverid=1046;maxbuffersize=2048;pagetimeout=5
 private void Preceptors_Load(object sender, EventArgs e)
 {
     dmc = (DMClient)this.Tag;
 }