How to build MCQ App Connect to WampServer by Android Studio

MCQ App Connect to WampServer by Android Studio

Introduction :

In the digital age, educational application plays a vital role for both learners and educators. Creating a basic multiple choice question (MCQ) app connected to a local server (wampserver) using Android Studio IDE is a very interesting and educational project for Android app developer.

This dynamic MCQ app is based on server-client communication program that connect to WampServer. Building a simple MCQ app using Android Studio is helpful for student as well as teacher in the learning process. Such educational tools or application is useful for various educational purposes like quiz, online-exam etc.

In this article, I shall show you how to create a Multiple Choice Question (MCQ) app connected to a local server (WampServer) using Android Studio. You have to implement HTTP requests in the MCQ app to communicate with the local server (wampserver). Here, I use volley library to connect MCQ app to the local server (wampserver).Using php language, you can send and receive data (questions) between the app and the wampserver.

About the application :

This is a simple MCQ app which connects to a local server (wampServer). Actually, the app is for both student and teacher. When you open the app on your phone, you can see two buttons on the screen. One for student and other for teacher.

When you click on student button, the app will dynamically fetch questions and answer choices from a local server (wampServer). After that, the app displays the question and answer choices to the student for submitting their answer. Then, the submitted answer will be stored in server (wampServer) database.

When you click on teacher button, you can see four buttons by which you can add new questions, update old questions, see all questions with answers and also see students given answer with their name.

In the app, I have shown only 10 questions in student section. You can change as you like. You can also use a remote server (VPS) instead of the local server (wampServer) for this MCQ app. You have to set up the remote server (VPS) for this purpose.

Step for create the application :

Before creating the MCQ app, you have to install Android Studio IDE on your pc. If you do not know how to build an Android app on Android Studio IDE, you can follow the link. After that, you have to install and set up a local server (wampserver) on your pc to handle backend operations.

You can also google search for connect a phone to local server (wampserver) of your pc. You have to follow the below step to build the multiple choice question (MCQ) app.

Step 1 :

First, create a new project “MCQ_app” with empty activity and check on legacy android.support libraries.

Step 2 :

When the app will be build, open manifest file and add the following code before application tag.

After that, add the below code in between application tag.

Step 3 :

Now, paste the code in dependencies of build.gradle(module.app) then click on “Sync Now” with net is on your pc.

The dependencies look like below code.

Step 4 :

Then, create a folder or directory in the res folder and name it “raw”. Here, you have to paste two file aa.m4a and bb.m4a. The two files are sound files which tell you student answer is right or not. It is optional. You can avoid this step.

Step 5 :

Now, open MainActivity.java file and replace the following code.

Now, open activity_main.xml file and replace the following code.

Step 6 :

Then, create a new activity name it MainActivity2 with layout. After that, open MainActivity2.java file and paste the following code.

Open activity_main2.xml file and replace the following code.

Step 7 :

Then, create a new activity name it MainActivity3 with layout. After that, open MainActivity3.java file and paste the following code.

Now, open activity_main3.xml file and replace the following code.

Step 8 :

Then, create a new activity name it show_student with layout. After that, open show_student.java file and paste the following code.

Now, open activity_show_student.xml file and replace the following code.

Step 9 :

Then, create a new activity name it Answer_teacher with layout. After that, open Answer_teacher.java file and paste the following code.

Now, open activity_answer_teacher.xml file and replace the following code.

Step 10 :

Then, create a new activity name it MakeQuestion_teacher with layout. After that, open MakeQuestion_teacher.java file and paste the following code.

Now, open activity_make_question_teacher.xml file and replace the following code.

Step 11 :

Then, create a new activity name it Show_teacher with layout. After that, open Show_teacher.java file and paste the following code.

Now, open activity_show_teacher.xml file and replace the following code.

Step 12 :

Then, create a new activity name it Update_teacher with layout. After that, open Update_teacher.java file and paste the following code.

Now, open activity_update_teacher.xml file and replace the following code.

After all activity when complete, the manifest file look like below code.

Step 13 :

Create a layout resource file in layout folder and name it listview_items_student. Open listview_items_student.xml file and paste the below code.

Step 14 :

Create a layout resource file in layout folder and name it listview_items_teacher. Open listview_items_teacher.xml file and paste the below code.

Step 15 :

Create a layout resource file in layout folder and name it listview_itemsanswer. Open listview_itemsanswer.xml file and paste the below code.

Step 16 :

Create a java file in com.example.mcq_app folder and name it ListViewAdapter. Open ListViewAdapter.java file and paste the below code.

Step 17 :

Create a java file in com.example.mcq_app folder and name it ListViewAdapterforanswer. Open ListViewAdapterforanswer.java file and paste the below code.

Step 18 :

Create a java file in com.example.mcq_app folder and name it Subject. Open Subject.java file and paste the below code.

Step 19 :

Create a java file in com.example.mcq_app folder and name it Subjectanswer. Open Subjectanswer.java file and paste the below code.

Step 20 :

After creating all files and paste the code, open wampserver on your pc. Here, you have to create a database named “kritika”. Now create two table “moc1” and “student”. In “moc1” table create the column id, question, ans1, ans2, ans3, ans4 and ansright. In “student” table create the column id, name, que1, que2, que3, que4, que5, que6, que7, que8, que9, que10.

Now, you have to open www folder of File Explorer. In C:\wamp64\www folder you have to paste the following php files. First create insertname.php and paste the below code.

Step 21 :

Create showdata.php and paste the below code.

Step 22 :

Create data.php and paste the below code.

Step 23 :

Create update.php and paste the below code.

Step 24 :

Create showanswer.php and paste the below code.

Step 25 :

Create insertanswer1.php and paste the below code.

Run the application :

Now, connect your phone to computer via USB cable (data cable). At last, you have to run the app by clicking the green “Run” button in the Android Studio IDE. After that, the app will be installed and launch on your device (phone). You can see your app on a phone like below image.

Output of MCQ App build by Android Studio

Conclusion :

After completing this article, you have learned how to build dynamic MCQ app with local server (wampServer) connectivity using Android Studio IDE. After that, you can build more complex learning app using Android Studio which connect with any type of server like remote server (VPS). Thank you for visiting my site.

Scroll to Top