HomeGuidesDeveloper HubRelease Notes
Get supportBook a chat
Developer Hub

FieloELR.QuestionService Class

The FieloELR.QuestionService class includes one method.

Submit Question

FieloELR.QuestionService.QuestionResponseResult FieloELR.QuestionService.submitQuestion (FieloELR.QuestionService.QuestionResponseWrapper questionResponseWrapper)

Allows Members to submit a Question Response for a specific Module Response. It also gives information about Member attempts.

Parameters

ParameterTypeDescription
questionResponseWrapperFieloELR.QuestionService.QuestionResponseWrapperQuestion Response record, including Members' submitted Answers.
class FieloELR.QuestionService.QuestionResponseWrapper{
	//Constructor that will receive the Question and the Module Response ID given by the Take Module API.
	global QuestionResponseWrapper(Id moduleResponseId, Question__c question);
	//Set Answer for short answer Questions
	global void setShortAnswer(String answer);
	//Send the Answer option selected for Single choice Questions
	global void setAnswer(AnswerOption__c answerOption);
	//Send the list of Answer options selected for Multiple choice Questions
	global void setAnswers(List<AnswerOption__c> answerOptions);
	//Send mapping between Options and chosen Answers
	global void setMatchingAnswers(Map<Id,String> answersMap);
}

Return Value

TypeDescription
FieloELR.QuestionService.QuestionResponseResultThe result of the Question Response.
class FieloELR.QuestionService.QuestionResponseResult{
	//Question records
	Question__c question;
	//Number of attempts that the Question was taken
	Integer numberOfAttempts;
	//Question Response with qualification of the question
	QuestionResponse__c questionResponse;
	//List of Answers for the given Question
	List<FieloELR.QuestionService.AnswerWrapper> answerWrappers;
	//Flag that will inform if the Member can repeat the same question
	Boolean canRepeatQuestion;
	//Short description with the information about the corrected answers
	String correctedAnswers;
	//Flag that will inform if the corrected Answers should be shown or not
	Boolean showDetailedAnswers;
}

class FieloELR.QuestionService.AnswerWrapper{
	//Answer option record
	AnswerOption__c answerOption;
	//Status for the option (correct, incorrect, neutral)
	String answerStatus;
}
//Operation to take a Module (First Page)
Set<String> fieldsModule = new Set<String>{'Name','FieloELR__Description__c', 'FieloELR__ApprovalGrade__c'}; 
Set<String> fieldsQuestion = new Set<String>{'FieloELR__QuestionText__c','FieloELR__Type__c'}; 
Set<String> fieldsAnswerOption = new Set<String>{'FieloELR__AnswerText__c','FieloELR__MatchingOption__c'}; 
FieloELR__Member__c member = [SELECT Id, FieloPLT__Program__c FROM FieloPLT__Member__c WHERE Id =: MemberService.getMemberId()];
FieloELR__Module__c module = [SELECT Id FROM FieloELR__Module__c LIMIT 1];
FieloELR.ModuleService.ModuleWrapper moduleWrapper = FieloELR.ModuleService.takeModule(module.Id, member.Id, fieldsModule, fieldsQuestion, fieldsAnswerOption);
FieloELR__Module__c module = moduleWrapper.module;
FieloELR__ModuleResponse__c moduleResponse = moduleWrapper.moduleResponse; 	//record created for the member, will be send by parameter in submit method
List<FieloELR__Question__c> questions = moduleWrapper.questions; //includes answer options related lists
//Finish operation of taking Module
//Submit Questions
for(FieloELR__Question__c question : moduleWrapper.questions){
  FieloELR.QuestionService.QuestionResponseWrapper questionWrapper = new FieloELR.QuestionService.QuestionResponseWrapper(moduleResponse.Id, question);
    if(question.FieloELR__Type__c == 'Short Answer'){
      questionWrapper.setShortAnswer('Selected option');
    }else if(question.FieloELR__Type__c == 'Single Choice' || question.FieloELR__Type__c == 'Statement'){
      questionWrapper.setAnswer(selectedAnswerOption);
    }else if(questionType != 'Multiple Choice' && questionType != 'Matching Options'){
      questionWrapper.setAnswers(selectedAnswerOptions);
    }   
    //Submit Question
    Boolean isCorrect = FieloELR.QuestionService.submitQuestion(questionWrapper);
}
//Finish submitting Questions