Example #1
0
        private void dgCanned_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            int            canID = Convert.ToInt32(dgCanned.DataKeys[e.Item.ItemIndex]);
            CannedResponse can   = new CannedResponse();

            can.ID      = canID; can.RubricID = GetCurrentID();
            can.Comment = (e.Item.FindControl("txtGridComment") as TextBox).Text;
            string strpoints = (e.Item.FindControl("txtGridPoints") as TextBox).Text;
            double points;

            try {
                points = Convert.ToDouble(strpoints);
            } catch (Exception) { points = 0; }
            can.Points = points;
            can.Type   = Convert.ToInt32((e.Item.FindControl("ddlTypes") as DropDownList).SelectedValue);

            try {
                new Rubrics(Globals.CurrentIdentity).UpdateCannedResponse(can);
            } catch (DataAccessException er) {
                PageCanError(er.Message);
            }

            dgCanned.EditItemIndex = -1;
            BindCannedResponses(can.RubricID);
        }
Example #2
0
        private void dgCanned_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            System.Web.UI.WebControls.Image imgType;
            DropDownList ddlTypes;
            Label        lblType;

            if (null != (imgType = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgType")))
            {
                lblType = (Label)e.Item.FindControl("lblType");
                CannedResponse can = e.Item.DataItem as CannedResponse;
                switch (can.Type)
                {
                case Rubric.ERROR:
                    imgType.ImageUrl = "../../attributes/error.gif";
                    lblType.Text     = "Error";
                    break;

                case Rubric.WARNING:
                    imgType.ImageUrl = "../../attributes/warning.gif";
                    lblType.Text     = "Warning";
                    break;

                case Rubric.GOOD:
                    imgType.ImageUrl = "../../attributes/good.gif";
                    lblType.Text     = "Good";
                    break;
                }
                ;
            }
            if (null != (ddlTypes = (DropDownList)e.Item.FindControl("ddlTypes")))
            {
                CannedResponse can      = e.Item.DataItem as CannedResponse;
                ListItem       gooditem = new ListItem("Good", Rubric.GOOD.ToString());
                ListItem       warnitem = new ListItem("Warning", Rubric.WARNING.ToString());
                ListItem       eritem   = new ListItem("Error", Rubric.ERROR.ToString());

                switch (can.Type)
                {
                case Rubric.ERROR:
                    eritem.Selected = true;
                    break;

                case Rubric.WARNING:
                    warnitem.Selected = true;
                    break;

                case Rubric.GOOD:
                    gooditem.Selected = true;
                    break;
                }
                ;

                ddlTypes.Items.Add(gooditem);
                ddlTypes.Items.Add(warnitem);
                ddlTypes.Items.Add(eritem);
            }
        }
Example #3
0
        /// <summary>
        /// Update a canned response
        /// </summary>
        public bool UpdateCannedResponse(CannedResponse can)
        {
            //check permission
            Rubric     rub  = GetInfo(can.RubricID);
            Assignment asst = new Assignments(m_ident).GetInfo(rub.AsstID);

            Authorize(asst.CourseID, "updaterubric", asst.ID, null);

            return(m_dp.UpdateCannedResponse(can));
        }
Example #4
0
        private void cmdCreate_Click(object sender, System.EventArgs e)
        {
            string         comment;
            double         points;
            IFileViewer    fileViewer = GetCurrentViewer();
            int            fileID = fileViewer.FileID, type;
            int            rubID = ucRubric.GetCurrentRubricID();
            CannedResponse can   = GetCannedResponse();
            ArrayList      lines;
            string         parserrmsg = "";

            //Try to parse line string
            try {
                lines = ParseLinesAffected(txtLines.Text);
            } catch (Exception er) {
                lines      = null;
                parserrmsg = er.Message;
            }

            if (lines == null)
            {
                PageCommentError(parserrmsg);
            }
            else if (lines.Count == 0)
            {
                PageCommentError("Must enter at least one line affected");
            }
            else
            {
                if (can == null)
                {
                    comment = txtCustom.Text;
                    type    = Convert.ToInt32(ddlType.SelectedValue);
                    points  = Convert.ToDouble(txtPoints.Text);
                }
                else
                {
                    comment = can.Comment;
                    type    = can.Type;
                    points  = can.Points;
                }
                try {
                    new Results(Globals.CurrentIdentity).CreateSubj(GetSubID(), rubID, comment,
                                                                    fileID, (int)lines[0], points, lines, type);
                } catch (DataAccessException er) {
                    PageCommentError(er.Message);
                } catch (LineParseException er) {
                    PageCommentError(er.Message);
                }
            }

            ucRubric.UpdateRubric();
            BindData(GetWindow());
        }
Example #5
0
        private void lnkCreate_Click(object sender, System.EventArgs e)
        {
            int            rubID = Convert.ToInt32(lblRubID.Text);
            CannedResponse can   = GetCannedResponse();

            try {
                new Results(Globals.CurrentIdentity).CreateSubj(GetSubID(), rubID, can.Comment,
                                                                -1, -1, can.Points, new ArrayList(), can.Type);
            } catch (DataAccessException er) {
                PageError(er.Message);
            }

            BindSubj(new Rubrics(Globals.CurrentIdentity).GetInfo(rubID));
            ucRubric.UpdateRubric();
        }
Example #6
0
        private CannedResponse GetCannedResponse()
        {
            int canID = Convert.ToInt32(ddlCanned.SelectedItem.Value);

            if (canID < 0)
            {
                CannedResponse can = new CannedResponse();
                can.Comment = "Custom Comment";
                can.Points  = 0.0;
                can.Type    = Rubric.WARNING;
                return(can);
            }
            else
            {
                return(new Rubrics(Globals.CurrentIdentity).GetCannedInfo(canID));
            }
        }
Example #7
0
            private static HttpResponseMessage CreateResponse(CannedResponse response)
            {
                var message = new HttpResponseMessage(response.Code)
                {
                    Content = string.IsNullOrEmpty(response.Content) ? null : new StringContent(response.Content)
                    {
                        Headers =
                        {
                            ContentType = new MediaTypeHeaderValue(response.ContentType),
                        },
                    },
                };

                foreach (KeyValuePair <string, string> header in response.Headers)
                {
                    message.Headers.TryAddWithoutValidation(header.Key, header.Value);
                }

                return(message);
            }