Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quizpage #5

Open
wants to merge 3 commits into
base: Development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project 2/config/project-scratch-def.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"orgName": "Demo Company",
"orgName": "mayingjunlang Company",
"edition": "Developer",
"features": [],
"settings": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<aura:documentation>
<aura:description>Documentation</aura:description>
<aura:example name="ExampleName" ref="exampleComponentName" label="Label">
Example Description
</aura:example>
</aura:documentation>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<aura:component>

</aura:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>46.0</apiVersion>
<description>A Lightning Component Bundle</description>
</AuraDefinitionBundle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.THIS {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<design:component >

</design:component>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
({
myAction : function(component, event, helper) {

}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
({
helperMethod : function() {

}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
({

// Your renderer method overrides go here

})
3 changes: 3 additions & 0 deletions Project 2/force-app/main/default/classes/QuestionClass.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class QuestionClass {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>46.0</apiVersion>
<status>Active</status>
</ApexClass>
100 changes: 87 additions & 13 deletions Project 2/force-app/main/default/classes/QuizPageController.cls
Original file line number Diff line number Diff line change
@@ -1,32 +1,106 @@

public class QuizPageController {

public list<Questions__c> QuesList {get;set;}

public string choice {get;set;}

integer count=0;
integer limitSize=10;

public void getQues(){
quesList=[SELECT name FROM Questions__c LIMIT:limitSize OFFSET:count];
integer score=0;
integer totalRecs=0;

list<account> newAcc=[SELECT Id FROM account WHERE OwnerId = :UserInfo.getUserID() LIMIT 1];

public QuizPageController() {
q = [SELECT id, Name FROM Quiz__c LIMIT 1];
ques = [SELECT Name ,A__c,B__c,C__c,D__c,CorrectAnswer__c FROM Questions__c WHERE Quiz__c IN :q LIMIT :limitSize OFFSET :count ];
totalrecs=ques.size();


}

public list<quiz__c> q;
public list<questions__c> ques;





public Quiz__c getQuiz() {
return q[0];
}

public PageReference Q1(){
count=0;
return null;
public Questions__c getQuestions(){
return ques[count];


}



public List<SelectOption> getAnswers() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('A1','Answer 1'));
options.add(new SelectOption('A2','Answer 2'));
options.add(new SelectOption('A3','Answer 3'));
options.add(new SelectOption('A4','Answer 4'));
options.add(new SelectOption('A',Ques[count].a__c));
options.add(new SelectOption('B',Ques[count].b__c));
options.add(new SelectOption('C',Ques[count].c__c));
options.add(new SelectOption('D',Ques[count].d__c));
return options;
}



public PageReference Q1(){
count=0;
return null;
}

public PageReference next(){
if(choice == ques[count].CorrectAnswer__c){
score++;

System.debug('score:'+score);
}

count++;
choice=null;
return null;
}

public Boolean getNxt() {
if(count> totalRecs-2)
return true;
else
return false;
}

public Boolean getLst(){
if(count==TotalRecs-1){
return false;
}else{
return true;
}
}

public PageReference previous(){
count--;
return null;
}

public void submit(){
if(choice == ques[count].CorrectAnswer__c){
score++;
}
System.debug('score:'+score);
System.debug('final'+ques.size());
AccountQuiz__c newAccQuiz = new AccountQuiz__c(name='test', Account__c=newAcc[0].Id, Quiz__c=q[0].id,Score__c=((score*100/ques.size())));
insert newAccQuiz;


}








}
36 changes: 36 additions & 0 deletions Project 2/force-app/main/default/classes/indiLeadController.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public with sharing class indiLeadController {

public indiLeadController(){

}



public static list<account> getAccount(){
list<account> accList =[SELECT name, points__c FROM account ORDER BY points__c DESC LIMIT 5];
list<account> newaccList = new list<account>();
for(account a :accList){
a.ranking__c=accList.indexOf(a)+1;
newaccList.add(a);
}

return newaccList;
}

public static list<account> getmyAccount(){
list<account> myaccList = [SELECT name, points__c FROM account ORDER BY points__c DESC];
list<account> myownaccList =[SELECT name, points__c FROM account WHERE OwnerId = :UserInfo.getUserID()];
account myacc=[SELECT name, points__c FROM account WHERE OwnerId = :UserInfo.getUserID()][0];
integer rank = myaccList.IndexOf(myacc)+1;
system.debug('rank:'+rank);

list<account> mynewaccList = new list<account>();
for(account a : myownaccList){
a.ranking__c=rank;
mynewaccList.add(a);
}

return mynewaccList;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="urn:metadata.tooling.soap.sforce.com" fqn="indiLeadController">
<apiVersion>46.0</apiVersion>
<status>Active</status>
</ApexClass>
3 changes: 3 additions & 0 deletions Project 2/force-app/main/default/classes/sad.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class sad {

}
5 changes: 5 additions & 0 deletions Project 2/force-app/main/default/classes/sad.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>46.0</apiVersion>
<status>Active</status>
</ApexClass>
23 changes: 23 additions & 0 deletions Project 2/force-app/main/default/components/IndiLeadComp.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<apex:component controller="indiLeadController">


<apex:pageBlock title="Your rank!">
<apex:pageBlockTable value="{!myAccount}" var="a">
<apex:column value="{!a.ranking__c}" />
<apex:column value="{!a.name}" />
<apex:column value="{!a.points__c}" />
</apex:pageBlockTable>
</apex:pageBlock>


<apex:pageBlock title="Top players">
<apex:pageBlockTable value="{!Account}" var="a">
<apex:column value="{!a.ranking__c}" />
<apex:column value="{!a.name}" />
<apex:column value="{!a.points__c}" />
</apex:pageBlockTable>
</apex:pageBlock>



</apex:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexComponent xmlns="urn:metadata.tooling.soap.sforce.com" fqn="IndiLeadComp">
<apiVersion>46.0</apiVersion>
<label>IndiLeadComp</label>
</ApexComponent>
Loading