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
shrayas reddyshrayas reddy 

how to pass data type object details from apex to aura i am not able to read data sent from aura to apex in system.debug it shows empty

// Aura component


<aura:component controller="Testquestions" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="FullName" type="String"/>
    <aura:attribute name="Phone" type="INTEGER"/>
    <aura:attribute name="Email" type="String"/>
    <aura:attribute name="city" type="String"/>
    <aura:attribute name="result" type="object[]"/>
    
    <aura:attribute name="optionA" type="String"/>
    <aura:attribute name="optionB" type="String"/>
    <aura:attribute name="optionC" type="String"/>
    <aura:attribute name="optionD" type="String"/>
    <aura:attribute name="testobj" type="Question__c[]"/>
    <aura:attribute name= "answerselected" type="Map"/>
    <aura:attribute name= "opt" type="List"/>
    <div>
        <br/>
        <h1 style="font-size: 25px; text-align:center"> Test 2022 </h1>
        <br/>
        <br/>
      
        <div class="slds-align_absolute-center">
          <div class="slds-grid_horizontal max-2">
        
        <lightning:input style="margin-right: 20px"  value="{!v.FullName }" label="Enter your full name" />
        <lightning:input style="margin-right: 20px"  value="{!v.Phone }" label="Enter your Phone Number" />
          </div>
        <div class="slds-grid_horizontal max-2">
        <lightning:input  value="{!v.Email}" label="Enter your Email Id" />
        <lightning:input  value="{!v.city }" label="Enter your city" />
        
        </div>
        </div>
        <br/>
        <br/>
        <div class="slds-align_absolute-center">
            
  <lightning:button variant="brand" label="start" title="Base action" onclick="{!c.startexam}"/>
   <lightning:button variant="brand" label="submit" title="Base action" onclick="{!c.submit}" />
        <br/>
    <br/>      
        </div>
        <div class="slds-align_absolute-center">
            <div class="slds-grid_horizontal max-2">
          <aura:iteration items="{!v.testobj}" var="a">
              
             
                <lightning:card  >
        <p><ui:outputText class="result"  value="{!'Q) ' + a.QuestionFull__c}" /></p>
    <br/>
   
   <ui:inputRadio  name="{!a.Id}" text="a" label="{!'A) ' + a.Option_A__c}" change="{!c.onGroup}"/> <br/>
   <ui:inputRadio  name="{!a.Id}" text="b" label="{!'B) ' + a.Option_B__c}" change="{!c.onGroup}"/> <br/>
   <ui:inputRadio  name="{!a.Id}" text="c" label="{!'C) ' + a.Option_C__c}" change="{!c.onGroup}"/> <br/>
   <ui:inputRadio  name="{!a.Id}" text="d" label="{!'D) ' + a.Option_D__c}" change="{!c.onGroup}"/> <br/>
   <br/>
    <br/>
                   </lightning:card>
             
          
        </aura:iteration>
        </div>
            </div>
    </div>
    
   
</aura:component>



// Aura controller

({
    startexam : function(component, event, helper) {
        var action = component.get('c.getQuestions');
       // action.setParams();
              action.setCallback(this, function(response){
            var state = response.getState();

            if(state == 'SUCCESS'){
                console.log('apex call is done!', response.getReturnValue()); 
                component.set('v.testobj', response.getReturnValue());
            }
                   });
        
        $A.enqueueAction(action);
    },
    onGroup : function(component, event, helper) {
        var Answer = event.getSource().get("v.text");
        var name = event.getSource().get("v.name");
        var selected = [{'name':name},{'Answer':Answer}]; 
        //var cmp = component.get('v.result');
        //var newmap = new Map();
        //newmap.set(name, Answer);
        //newMap.forEach((name,Answer)=>cmp.set(name,Answer));
        component.set('v.result',selected);
        console.log(component.get('v.result'));
       
    },
    submit : function(component, event, helper) {
        var action = component.get('c.insertrec');
        var name = component.get('v.FullName');
        var phone = parseInt(component.get('v.Phone'));
        var email = component.get('v.Email');
        var city = component.get('v.city'); 
        var res = [component.get('v.result')];
         
        action.setParams({'name':name},{'phone':phone},{'email':email},{'city':city},{'obj':res});
              action.setCallback(this, function(response){
            var state = response.getState();

            if(state == 'SUCCESS'){
                console.log('apex call is done!', response.getReturnValue()); 
                component.set('v.testobj', response.getReturnValue());
            }
                   });
        
        $A.enqueueAction(action);
    }
})



//Apex controller

public class Testquestions {
     @AuraEnabled
    public static List<Question__c> getQuestions(){
        List<Question__c> que = new List<Question__c>();
        que = [SELECT Id,QuestionFull__c,Option_A__c,Option_B__c,Option_C__c,Option_D__c,Answer__c FROM Question__c];
        
       // system.debug(que);
       // insert stu;
        return que;
    }
    @AuraEnabled
    public static void insertrec(String name, integer phone, string email, string city, List<object> obj){
        test_taker__c stu = new test_taker__c();
        stu.Full_Name__c = name;
        stu.Phone_Number__c = phone;
        stu.Email__c = email;
        stu.City__c = city;
        
        system.debug(obj);
        system.debug(name);
     
    }
}