You need to sign in to do that
Don't have an account?
Sachin Bhalerao 17
Objective type question test Project in Lightning Component?
Dear Team ,
Thank you for your continous support!!!
I have to create one project on lightning component in which i have to create Objective type test in which there are 4 options for single questions and user have to select one right answers . And data get stored in Custom object and i need to display result also when user click on submit button . (For Eg 6 answer correct out of 10)
Please provide me any link or overview how can i start this project .
Thanks & Regards
Sachin Bhalerao
Thank you for your continous support!!!
I have to create one project on lightning component in which i have to create Objective type test in which there are 4 options for single questions and user have to select one right answers . And data get stored in Custom object and i need to display result also when user click on submit button . (For Eg 6 answer correct out of 10)
Please provide me any link or overview how can i start this project .
Thanks & Regards
Sachin Bhalerao
You can use below lines of code:
All Answers
You can start with this approach -
Create a custom object with custom fields of type picklist with the default value as the correct answer.
On lightning component, show the values in lightning:radiogroup.
On Submit button, send the data to save the record and check the values selected with those of default (correct) values, if it matches add 1 else add 0, and show the result on Save on a pop-up (modal) window.
Thank you for your reply !!!
You mentioned show the values in lightning:radiogroup , i have to bind that values from database or i have to code on component . Would you plz give me small example for this.
Thanks & Regards
Sachin Bhalerao
I wrote following code . Would you plz help me to achieve this functionality. Please have a look on attached image of my custom object
Component :
<aura:component controller="BISPController">
<aura:attribute name="NewCon"
type="Contact"
default="{ 'sobjectType': 'Questions__c',
'Does_Lightning_Component_uses_Javascript__c ' : '',
'Which_file_not_part_of_lightning_comp__c' : '',}" />
<form>
<div class="slds-form-element">
<div class="slds-form-element__control">
<label class="slds-form-element__label" for="form-element-01">Does Lightning Component uses Javascript</label>
<div style="background-color:white; height:33px; border:solid; border-color:rgb(217,219,221); border-radius:4px;">
<force:inputField value="{!v.NewCon.Does_Lightning_Component_uses_Javascript__c }" class="form-control" />
</div>
</div>
</div>
<div class="slds-form-element">
<div class="slds-form-element__control">
<label class="slds-form-element__label" for="form-element-01">Which file not part of lightning comp</label>
<div style="background-color:white; height:33px; border:solid; border-color:rgb(217,219,221); border-radius:4px;">
<force:inputField value="{!v.NewCon.Which_file_not_part_of_lightning_comp__c}" class="form-control" />
</div>
</div>
</div>
</form>
</aura:component>
APEX class
public with sharing class BISPController {
@AuraEnabled
public static Questions__c Submitans (Questions__c con) {
upsert con;
return con;
}
}
Lightning APP
<aura:application extends="force:slds">
<c:Questions/>
</aura:application>
Visual force page
<apex:page controller="BISPController">
<apex:includeLightning />
<apex:pageBlock >
<apex:pageBlockSection >
<div id="Con" />
</apex:pageBlockSection>
</apex:pageBlock>
<script>
$Lightning.use("c:submitAns", function() {
$Lightning.createComponent(
"c:Questions",
{},
"Con",
function(cmp) {
console.log("Component is created!");
console.log(cmp);
});
});
</script>
</apex:page>
Please use type="Questions__c" in aura:attribute
I mentioned type="Questions__c" but no changes . One more thing plz let me know how can i use <Lightning:radiobutton > . Right now m using Lightning input . M using this component on my Visual force page.
M still unable to understand how can i match value of radio button with the default value of picklist (Correct Answer) . I attached image of output of my component .
My Domain is not yet deployed
You will not be able to fetch picklist values as radio group in lightning, what you can do is :
<aura:attribute name="ques" type="Question__c" access="global" default="{'sobjectType' : 'Question__c'}" />
<aura:attribute name="options" type="List" default="[
{'label': 'Yes', 'value': 'Yes'},
{'label': 'No', 'value': 'No'},
{'label': 'No Idea', 'value': 'No Idea'}
]"/>
<div class="displayInline">
<lightning:radioGroup name="radioGroup"
label="Question 1"
options="{!v.options }"
value="{!v.soft.Does_Lightning_Component_uses_Javascript__c }"
type="radio"/>
</div>
You can use below lines of code:
Thank you for your continous support !!!
Still m facing problem in matching radiobutton with picklist default value . I created one more column in table (Match__c) . It value of radiobutton matches with default value of picklist Match__c should be 1 else 0 . Please have a look on my code and suggest some solutions .
Thanks & Regards
Sachin Bhalerao