B4J Tutorial [WebApp] Quiz Example

Erel

Administrator
Staff member
Licensed User

Online link: http://basic4ppc.com:51042/quiz/index.html

This is an example of an online quiz. When the WebSocket is connected five random questions are created.

The user can go back and forth between the questions. After the last question the user score is calculated.

The Change event is raised when the selected radio button changes. Instead of handling the Change event of each of the four radios we handle the Change event of the parent element:
B4X:
Private Sub Questions_Div_Change (Params As Map)
   Dim target As String = Params.Get("target") 'find the checked radio
   Dim index As Int = target.SubString(1) 'remove the 'a'
   Dim qd As QuestionData = questions.Get(questionIndex)
   qd.UserAnswerIndex = index
   btnNext.SetProp("disabled", False) 'enable the next button
End Sub
The SetPage sub is responsible for showing the question and answers and also to set the checked button if the user already answered this question.

The example is included in the online examples project: http://www.basic4ppc.com/android/forum/threads/webapp-web-apps-overview.39811/

Note that jServer v2.02+ is required for this example (it fixes an issue with JQueryElement.SetProp).
 

Beja

Expert
Licensed User
Hi,
I can't see the Quiz example project?.. when I went to that page and clicked on the quiz tutorial I found a cross link to this one. and returned back.
 
Top