Ejemplo n.º 1
0
    protected void GrdServicesCourses_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int RowIndex = e.CommandArgument._ToInt32();

        CoursesInfo Info = new CoursesInfo();

        Info.ServicesCoursesID      = GrdServicesCourses.DataKeys[RowIndex]["ID"]._ToInt32();
        Info.OrganizationsID        = GrdServicesCourses.DataKeys[RowIndex]["OrganizationsID"]._ToInt32();
        Info.ServicesID             = GrdServicesCourses.DataKeys[RowIndex]["ServicesID"]._ToInt32();
        Info.ServicesCoursesTypesID = GrdServicesCourses.DataKeys[RowIndex]["ServicesCoursesTypesID"]._ToInt32();
        ViewState["CoursesInfo"]    = Info;

        if (e.CommandName == "editcourses")
        {
            LnkEditCourses_Click(null, null);
        }
        else if (e.CommandName == "addplans")
        {
            LnkAddPlans_Click(null, null);
        }
        else if (e.CommandName == "addpersons")
        {
            LnkAddPersons_Click(null, null);
        }
    }
Ejemplo n.º 2
0
        public virtual int AddCourseInfo(IudicoCourseInfo courseInfo)
        {
            var db = this.GetDbContext();

            CoursesInfo ci = new CoursesInfo
            {
                CourseId        = courseInfo.Id,
                OverallMaxScore = (float)courseInfo.OverallMaxScore
            };

            db.CoursesInfo.InsertOnSubmit(ci);
            db.SubmitChanges();

            foreach (IudicoNodeInfo nodeInfo in courseInfo.NodesInfo)
            {
                NodesInfo ni = new NodesInfo
                {
                    CourseId = courseInfo.Id,
                    NodeId   = nodeInfo.Id,
                    MaxScore = (float)nodeInfo.MaxScore
                };

                db.NodesInfo.InsertOnSubmit(ni);
                db.SubmitChanges();

                foreach (IudicoQuestionInfo questionInfo in nodeInfo.QuestionsInfo)
                {
                    QuestionsInfo qi = new QuestionsInfo
                    {
                        NodeId   = nodeInfo.Id,
                        Text     = questionInfo.QuestionText,
                        MaxScore = (float)questionInfo.MaxScore
                    };

                    switch (questionInfo.Type)
                    {
                    case IudicoQuestionType.IudicoSimple:
                        qi.Type = 1;
                        break;

                    case IudicoQuestionType.IudicoChoice:
                        qi.Type = 2;
                        break;

                    case IudicoQuestionType.IudicoCompile:
                        qi.Type = 3;
                        break;
                    }

                    db.QuestionsInfo.InsertOnSubmit(qi);
                    db.SubmitChanges();

                    switch (questionInfo.Type)
                    {
                    case IudicoQuestionType.IudicoSimple:
                        SimpleQuestion sq = new SimpleQuestion
                        {
                            QuestionId    = qi.Id,
                            CorrectAnswer = (questionInfo as IudicoSimpleQuestion).CorrectAnswer
                        };

                        db.SimpleQuestions.InsertOnSubmit(sq);
                        db.SubmitChanges();
                        break;

                    case IudicoQuestionType.IudicoChoice:
                        ChoiceQuestionsCorrectChoice cqcc = new ChoiceQuestionsCorrectChoice
                        {
                            QuestionId    = qi.Id,
                            CorrectChoice = (questionInfo as IudicoChoiceQuestion).CorrectChoice
                        };

                        db.ChoiceQuestionsCorrectChoices.InsertOnSubmit(cqcc);
                        db.SubmitChanges();

                        foreach (var option in (questionInfo as IudicoChoiceQuestion).Options)
                        {
                            ChoiceQuestionsOption cqo = new ChoiceQuestionsOption
                            {
                                QuestionId  = qi.Id,
                                Option      = option.Item1,
                                Description = option.Item2
                            };

                            db.ChoiceQuestionsOptions.InsertOnSubmit(cqo);
                            db.SubmitChanges();
                        }
                        break;

                    case IudicoQuestionType.IudicoCompile:
                        for (int i = 0; i < (questionInfo as IudicoCompiledTest).NumberOfTests; ++i)
                        {
                            CompiledTestQuestion ctq = new CompiledTestQuestion
                            {
                                QuestionId = qi.Id,
                                TestNumber = i,
                                TestInput  = (questionInfo as IudicoCompiledTest).TestInputs[i].Item2,
                                TestOutput = (questionInfo as IudicoCompiledTest).TestOutputs[i].Item2
                            };


                            db.CompiledTestQuestions.InsertOnSubmit(ctq);
                            db.SubmitChanges();
                        }
                        break;
                    }
                }
            }

            return(courseInfo.Id);
        }