• Alena Semenova 14
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
testItemList = [SELECT Id, Right__c, Percent_correct_answers__c FROM Session__c WHERE Id =:SessionId];
        //update field Answer for Session
        if (newItem[0].Answer__c == answer) {
            answerCount++;
            testItemList[0].Right__c=answerCount;
            update testItemList;
            
        }

 
Clicking on a button and moving to a new page with questions:

public PageReference runTest () {
        insert newSession; 
        PageReference ref = new PageReference ('/apex/LaunchTests');
        return ref;
        
    }


Controller:

public class LaunchTestsController {
    public List <Test_item__c> newItem { get; set;} 
    
    public LaunchTestsController () {
        
        string str = 'SELECT Id, Question__c, Response__c, Response1__c, Responce2__c, Answer__c FROM Test_item__c';
        this.newItem = Database.query(str);
    }
    
    
}
VF Page:
<apex:page controller="LaunchTestsController" >
    
    <apex:form >
    <apex:pageBlock title="Questions">
        <apex:pageBlockTable value="{!newItem}" var="item">
        <apex:column value="{!item.Question__c}"/>
           
        </apex:pageBlockTable>

        </apex:pageBlock>
        
    </apex:form>
</apex:page>

 
Clicking on a button and moving to a new page with questions:

public PageReference runTest () {
        insert newSession; 
        PageReference ref = new PageReference ('/apex/LaunchTests');
        return ref;
        
    }


Controller:

public class LaunchTestsController {
    public List <Test_item__c> newItem { get; set;} 
    
    public LaunchTestsController () {
        
        string str = 'SELECT Id, Question__c, Response__c, Response1__c, Responce2__c, Answer__c FROM Test_item__c';
        this.newItem = Database.query(str);
    }
    
    
}
VF Page:
<apex:page controller="LaunchTestsController" >
    
    <apex:form >
    <apex:pageBlock title="Questions">
        <apex:pageBlockTable value="{!newItem}" var="item">
        <apex:column value="{!item.Question__c}"/>
           
        </apex:pageBlockTable>

        </apex:pageBlock>
        
    </apex:form>
</apex:page>