function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Niharika GoudNiharika Goud 

How to Display Online Examination Question Paper Using Lightning


Iam New To SFDC Plz help me
NagendraNagendra (Salesforce Developers) 
Hi Niharika,

Please find the sample code below and tweak it as per your requirement which might help you.
public class examcontroller {
	public examcontroller() {
		question__c[] options = [select id,name,question__c,(select id,name,answer__c from answers__r) from question__c where active__c = true limit 1,000];
		examitems = new examitem[0];
		while(!options.isempty() && examitems.size() < 60) {
			examitems.add(new examitem(options.remove(math.mod(crypo.getrandominteger(),options.size()))));
	public examitem[] examitems { get; set; }
	public class examitem {
		public question__c question { get; set; }
		public id selectedanswer { get; set; }
		public selectoption[] getansweroptions {
			selectoption[] options = new selectoption[] { new selectoption('','-- Choose --') };
			for(answer__c answer:question.answers__r) {
				options.add(new selectoption(string.valueof(,answer.answer__c));
			return options;
		public examitem(question__c question) {
			this.question = question;
	public PageReference saveExam() {
		// I leave this as an exercise to the reader.
		return null;
You see, I query all available questions (using a flag to show only active questions), then I pick 60 of them by a random number, removing them from the list so I guarantee they will be unique. The answers are generated as picklist options on the fly. If you allow multiple exams per participant, you can further filter the query with an anti-join so they will not receive questions they have saved answers to before.

Hope this helps.

HarshaVardhan Gorantla 1HarshaVardhan Gorantla 1
Hello Niharika ,
if u have done that Online Exam Question paper,if u dont mind could u please share me the code. 
Manoj Kumar J 6Manoj Kumar J 6
Hello Niharika ,
if u have done that Online Exam Question paper,if u dont mind could u please share me the code.
Ava WilsonAva Wilson
Hello student! How do we ensure anonymity? You can communicate with support representatives or your assignment pro without disclosing your name. As a big fan of procrastination, I was constantly late with my assignments. But ever since I found my trusted expert here, I am now the first to hand in homework. Grades are good. Thanks a lot!