Saturday 15 August 2015

c# - How to populate a RadioButton List with 4 answer choices in random order for a Quiz? -


I am trying to create a quiz widget based on SharePoint List Data (Questions and 4 Answer Options). I am able to find 10 ways to draw random rows and read the questions and answers. However, whatever I can not do, it is logical to populate the radio button list with answer options (for that specific line item) in a random order, even by removing this code. Please suggest strategies / codes.

Please {SPWeb thisWeb = SPContext.Current.Web; // current subsonplan funded SPList OSPList = this web list [reach corroding code in the list] ["question and answer"]; // Use a query if a tofilter is required by the subOnID SPQuery oSPQuery = new SPQuery (); OSPQuery.RowLimit = 10; SPListItemCollection oSPListItemCollection = oSPList.GetItems (oSPQuery); Random rand = new random (); List & lt; Int & gt; TempStore = new list & lt; Int & gt; (); List & lt; Int & gt; TempStore2 = new list & lt; Int & gt; (); Int tempValue = 0; // integer tempValue2 = 0; Intactount = 0; Int iMax = oSPListItemCollection.Count; // int iqount2 = 0; // int iMax2 = oSPListItemCollection.Count; SPListItem thisItem; Label this question; Label this correct answer; Radio button list this answer; While (Icons & lt; 10) {tempValue = rand.Next (1, iMax); If (tempStore.Exists (value = & gt; value == tempValue)) continue; Other {tempStore.Add (tempValue); This question = (label) update panilamester.fund control ("question" + import.Toastring ()); ThisItem = oSPListItemCollection [tempValue]; This question Text = this item ["question"]. ToString (); // To handle the random answer system, this answer = (radio button list) inside the loop updated panel master. FontControl ("Radiobutton List" + Icon.ToString ()); // The following 4 lines of code populate the radio button list in order to run only every line item // How to randomize the order? (This incorrect ["wrong answer"]. To record (); Add this archive. Item (Adding it to ["Wrong Answers1"]. ToString (); It Answers.Items.Add (this item ["Wrong Answers2"]. ToString () ;;;); Add this item (this item ["wrong answers3"]. ToString (); This correct answer = (label) Update panel, master. Fontcontrol ("right answer" + IQand.tostring ( );) This correct answer. Text = this item ["correct answer"].}} TempValue = 0; iccount ++;}} / end uncontrolled question handling grip (exception pre) {east;}}

this item [s]. Ostring ()) // Sort by a random number (i.e. alteration) orderbird (s => rand.Next () ) // Change in a list (for forEach method) .toList () // Strings in the list for each answer, this adders.Items To add. Small (S = & gt; ThisAnswers.Items.Add (s));

No comments:

Post a Comment