I want to make Multiple-choice test with ionic for android
Where I save Questions and how show the Questions?
How understand user selects the right answer?
Can you please help me.
I want to make Multiple-choice test with ionic for android
Where I save Questions and how show the Questions?
How understand user selects the right answer?
Can you please help me.
you should save the questions in the controller associated with the route and view you would like to present the questions from. this would be in the controllers.js file from either quickstart.
the easiest way to tell if the user selects the right answer might be to put an ng-click attribute on each answer which calls a function in your controller which determines whether the selected answer is correct or not.
you should start by doing some angularjs tutorials, because that is what an ionic application is based on.
good luck.
you can save Questions to json format and then you can get Questions from json file
for more information use this links
» http://learn.ionicframework.com/formulas/backend-data/
» AngularJS: factory $http.get JSON file
» https://www.phase2technology.com/caching-json-arrays-using-cachefactory-in-angularjs-1-2-x/
for example
this is my Questions file with JSON format
{
"Questions": [
{
"QuestionsID" : "1",
"QuestionsTitle" : "question 1",
"QuestionsText" : "which one is Answers?",
"Answers1" : "i'm Answers",
"Answers2" : "i'm not Answers",
"Answers3" : "i'm not Answers",
"Answers4" : "i'm not Answers",
"TrueAnswers" : "Answers1"
},
{
"QuestionsID" : "2",
"QuestionsTitle" : "question 2",
"QuestionsText" : "which one is Answers?",
"Answers1" : "i'm not Answers",
"Answers2" : "i'm Answers",
"Answers3" : "i'm not Answers",
"Answers4" : "i'm not Answers",
"TrueAnswers" : "Answers2"
}
]
}
Now i can get Questions from json file and save in arrays then use this array
this is angular code
// Caching the river...
myApp.factory('myCache', function($cacheFactory) {
return $cacheFactory('myData');
});
// Displays a list of articles in the river
myApp.controller('MyMain', ['$scope', '$http', 'myCache',
function ($scope, $http, myCache) {
var cache = myCache.get('myData');
if (cache) {
$scope.variable = cache;
}
else {
$http.get('lib/Questions.son')
.success(function(data) {
$scope.variable = data;
myCache.put('myData', data);
}
);
}
}
Now can use $scope.variable
Your question is too general,I think it is better go this link and learn AngularJS https://www.codecademy.com/en/courses/learn-angularjs