How can I create quiz question

It is not possible to create quiz questions using LMS API.
You can use SharePoint API for this purpose, please see piece of code below.

 

Question question = (Question)fields.CreateNewField("Question", QuestionName.Text);

                if (QuestionType.Value != Quiz.QuestionType.Pool)
                {
                    question.Description = this.Question.Text;
                    question.Points = int.Parse(Points.Text);
                    if (quiz.AdvancedScore) question.MinPoints = int.Parse(MinPoints.Text);
                    question.PositiveFeedback = String.IsNullOrEmpty(Utility.ParseInputFormText(PositiveFeedback.Text)) ? String.Empty : PositiveFeedback.Text;
                    question.NegativeFeedback = String.IsNullOrEmpty(Utility.ParseInputFormText(NegativeFeedback.Text)) ? String.Empty : NegativeFeedback.Text; 
                    question.SemiPositiveFeedback = String.IsNullOrEmpty(Utility.ParseInputFormText(SemiPositiveFeedback.Text)) ? String.Empty : SemiPositiveFeedback.Text;
                }
                question.Configuration = questionControl.Configuration;
                question.QuestionType = QuestionType.Value;
                question.Branching = questionControl.Branching;
                question.Hint = String.IsNullOrEmpty(Utility.ParseInputFormText(Hint.Text)) ? String.Empty : Hint.Text;
                question.HintCost = !string.IsNullOrEmpty(HintCost.Text) ? int.Parse(HintCost.Text) : 0;
                question.IsMandatory = MandatoryOption.Checked;

                var questionName = fields.AddFieldAsXml(question.SchemaXml, true, SPAddFieldOptions.AddFieldToDefaultView | SPAddFieldOptions.AddToDefaultContentType);
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.