This is a migrated thread and some comments may be shown as answers.

Online quiz

6 Answers 427 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Abdulaziz
Top achievements
Rank 1
Abdulaziz asked on 13 Jan 2015, 05:30 PM
Im new to Telerik. Please help me in this regard.
We are doing online competitive Exam template. 





Total Number of Question : based on the exam (Random Questions)


Question Type : Optional, Multiple Choice, Match the following, Reordering, Fill in the blanks


Exam Duration : Based on the exam.

Please suggest us which telerik control is suitable for quiz, Match the following, Reordering.



6 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 14 Jan 2015, 09:08 AM

Hello,

I have answered your support ticket on the same matter and I am adding here my reply for anyone else with a similar question.


We do not have a control that can be used directly for creating quizes, yet what I can suggest is the below basic proof of concept that uses RadWizard. To get a better view of the control features, I advise that you examine the following demos as well:

<telerik:RadWizard runat="server" ID="RadWizard1" RenderedSteps="Active" OnNextButtonClick="RadWizard1_NextButtonClick">
       <WizardSteps>
              <telerik:RadWizardStep StepType="Start">
                     initial step. Begin quiz
                     <asp:TextBox ID="Textbox1" runat="server" />
              </telerik:RadWizardStep>
       </WizardSteps>
</telerik:RadWizard>

Protected Sub RadWizard1_NextButtonClick(sender As Object, e As WizardEventArgs)
    'here is how to access and use data from the wizard steps. You can add user controls in them for each type
    'of question and fire events in them in order to store the data, to avoid many FindControl() calls
    Dim tb As TextBox = TryCast(e.CurrentStep.FindControl("Textbox1"), TextBox)
    If tb IsNot Nothing Then
        Response.Write(tb.Text)
    End If
 
    'see what step type you need, evaluate the current step through e.CurrentStep so you know what to add next
    Dim currStep As New RadWizardStep()
    'make sure to add unique IDs to each step to avoid errors. In this sample, clicking Next the second time will cause
    'an error because there are no checks for the actual next step that is supposed to be added
    currStep.ID = "desiredID"
    currStep.Title = "the title"
    currStep.StepType = RadWizardStepType.[Step]
    'this determines what buttons are available
    currStep.Controls.Add(New LiteralControl("test"))
    'create the needed controls for your question here
    RadWizard1.WizardSteps.Add(currStep)
 
    RadWizard1.ActiveStepIndex = RadWizard1.WizardSteps(RadWizard1.WizardSteps.Count - 1).Index
End Sub

You can also look into using RadDataForm ( http://demos.telerik.com/aspnet-ajax/dataform/overview/defaultcs.aspx ) for creating each question of a certain type with it, if your data source and user experience match what the control needs and offers: http://demos.telerik.com/aspnet-ajax/dataform/functionality/layouts/defaultcs.aspx

Regards,

Marin Bratanov
Telerik
0
binny
Top achievements
Rank 1
answered on 28 Jan 2015, 03:20 AM
I am trying to create a prototype for online quiz but stuck , can someone help?
My requirement is to create a quiz which will
1) Add the questions / answers dynamically as steps
2) validate the answers and if it is wrong answer add the question back again in the step so that they can retry

And also

I did achieve most of it except that my data and steps are getting mixed, I am sure there is a better way to do it , please help

And also why RadWizard1_WizardStepCreated called everytime there is a change in step

  protected void RadButton1_Click(object sender, EventArgs e)
        {
            //if (RadNumericTextBox1.Value > 0)
            //{
            RadButton button = (RadButton)sender;
            button.Enabled = false;
            List<data> data = new List<data>();
            data = (List<data>)HttpContext.Current.Session["data"];
            for (int i = 0; i < data.Count; i++)
            {
                RadWizardStep step = new RadWizardStep();
                step.ID = "Question"+(i + 1).ToString();                              
                RadWizard1.WizardSteps.Add(step);
            }
            RadWizardStep completeStep = new RadWizardStep();
            completeStep.ID = "Complete";
            RadWizard1.WizardSteps.Add(completeStep);
            RadWizard1.ActiveStepIndex = RadWizard1.WizardSteps[1].Index;
            //}
        }
  protected void RadWizard1_WizardStepCreated(object sender, Telerik.Web.UI.WizardStepCreatedEventArgs e)
        {
            if (e.RadWizardStep.ID == "Complete")
            {
               //complete logic
            }
            else
            {
                List<Data> data = new List<Data>();
                data = (List<Data>)HttpContext.Current.Session["data"];
                Label label = new Label();
                RadioButtonList list = new RadioButtonList();
                list.AutoPostBack = true;
                list.CausesValidation = true;
                list.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged);
              
                label.Text = data[e.RadWizardStep.Index - 1].Question;                     
                list.Items.Add(data[e.RadWizardStep.Index - 1].A);
                list.Items.Add(data[e.RadWizardStep.Index - 1].B);
                list.Items.Add(data[e.RadWizardStep.Index - 1].C);
              
                e.RadWizardStep.Controls.Add(label);
                e.RadWizardStep.Controls.Add(new Literal() { Text = "<br />" });
                e.RadWizardStep.Controls.Add(list);
                }
                  
                }          
           
        }
  private void list_SelectedIndexChanged(object sender, EventArgs e)
        {
            RadioButtonList RBL = (RadioButtonList)sender;
            List<data> data = new List<data>();
            data wrongAnswer = new data();
            data = (List<data>)HttpContext.Current.Session["data"];
            string s = RBL.SelectedValue.ToString();
            string y =  data[RadWizard1.ActiveStepIndex-1].Answer;
            if(s.Trim() == y.Trim())
            {
               some logic
            }
            else
            {
                some logic  


List<data> ldata= new List<data>();
data.Add(listQuizData[RadWizard1.ActiveStepIndex - 1]);
HttpContext.Current.Session["data"] = ldata; 
         
RadWizardStep step = new RadWizardStep();
step.ID = " Repeat Question";
RadWizard1.WizardSteps.Add(step);
            }
          
          
         
        }
0
Boyan Dimitrov
Telerik team
answered on 01 Feb 2015, 08:39 PM
Hello,

I would like to say that your idea and implementation seems absolutely correct. A possible reason for mixing questions(data) and steps might be the following code:
//code behind
label.Text = data[e.RadWizardStep.Index - 1].Question;                    
list.Items.Add(data[e.RadWizardStep.Index - 1].A);
 list.Items.Add(data[e.RadWizardStep.Index - 1].B);
list.Items.Add(data[e.RadWizardStep.Index - 1].C);

Perhaps you can access the same index in the "data" collection as the step index ( not to subtract "1" from the e.WizardStep.Index). I believe such logic might lead to unexpected behavior.

As for second question - the WizardStepCreated event is fired whe a step is changed in order to persist  the controls within the steps. All dynamically created steps should be recreated on the server each time.



Regards,
Boyan Dimitrov
Telerik
0
binny
Top achievements
Rank 1
answered on 09 Feb 2015, 09:40 PM
But my list data starts from index "0" and e.RadWizardStep.Index starts from "1"

I will be getting index out of range exception because my data count would be 0,1,2 and the e.RadWizardStep.Index would be 1,2,3

That is the reason I had to do [e.RadWizardStep.Index-1]
0
Boyan Dimitrov
Telerik team
answered on 13 Feb 2015, 08:00 AM
Hello,

An easy workaround would be creating the array that holds the questions with one more element compared to the number of dynamically created steps. After all you have a start step that does not contain any questions and its index is 0.
//code
List<String> data = new List<string>();
for (int i = 0; i < RadNumericTextBox1.Value + 1; i++)
                {
                    data.Add("text for ste index" + i);
                }


I prepared a sample project that creates dynamically an array that holds string values to be printed in a text box within each step.  The example shows how to show/print the text that corresponds to the current step and avoid any mixing.


Regards,
Boyan Dimitrov
Telerik
0
binny
Top achievements
Rank 1
answered on 06 May 2016, 07:58 PM

Hello Boyan - I am really sorry that I am posting after a long gap but this project got delayed and I never got this working.

I am not able to use the demo you put in your previous post for this case.

Now I have a similar requirement but not able to get it working.Any direction on this would be greatly appreciated

 

 

Tags
Wizard
Asked by
Abdulaziz
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
binny
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or