1. Trang chủ
  2. » Luận Văn - Báo Cáo

Báo cáo nhóm học phần lập trình di Động chủ Đề “app làm trắc nghiệm

44 0 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề App Làm Trắc Nghiệm
Tác giả Nguyễn Khương Duy, Vũ Nguyễn, Nguyễn Xuân Đại, Phạm Đức Mạnh
Người hướng dẫn Bùi Thị Như
Trường học Trường Đại Học Công Nghệ Giao Thông Vận Tải
Chuyên ngành Công Nghệ Thông Tin
Thể loại báo cáo
Năm xuất bản 2022
Thành phố Hà Nội
Định dạng
Số trang 44
Dung lượng 2,7 MB

Nội dung

public void dialog_success{ Dialog dialog=new Dialogthis dialog.requestWindowFeatureWindow.FEATURE_NO_TITLE dialog.setContentViewR.layout.dialog_success dialog.show; Button btnok=Butt

Trang 1

TRƯỜNG ĐẠI HỌC CÔNG NGHỆ GIAO THÔNG VẬN TẢI

KHOA CÔNG NGHỆ THÔNG TIN

Hà Nội, tháng 12 năm 2022

Trang 2

M;c l;c

1.Giới thiệu 1

1.1 Mục tiêu 1

1.2 Actors và Use Cases 1

1.3 Mô tả 2

2 Thiết kế cơ sở dữ liệu và chức năng 2

2.1.SQL 2

2.1.1 Category 2

2.1.2 User 4

2.1.3 Quiz Contract 9

2.2.Giao diện và code 14

2.2.1 Đăng Nhập, Đăng Ký 14

2.2.2 Thêm Câu hỏi môn Toán 27

2.2.3 Thêm câu hỏi môn Văn 32

2.2.4 Cập nhật câu hỏi Toán, Tiếng Việt 36

2.2.5 Danh sách toàn bộ câu hỏi Toán và Tiếng Việt 45

2.6 Màn hình khi làm trắc nghiệm 51

3.Phân công công việc 62

Trang 3

1.Giới thiệu

1.1 M;c tiêu

Trong thời kì hiện nay, những ứng dụng trên điện thoại đang đóng góp không nhỏ vào đời sống của con người bởi sự tiện ích, nhỏ gọn nhưng hiệu quả không kém gì những trang Web Một trong những ứng dụng có thể kể đến là trong học tập, hiện tại đã và đang có nhiều phần mềm hỗ trợ học tập cho mọi lứa tuổi, mọi môn học.

Do đó, em xin lựa chọn đề tài phát triển ứng dụng thi trắc nghiệm Toán và Tiếng Việt cho các bé.

1.2 Actors và Use Cases

1

Trang 4

1.3 Mô tả

Ứng dụng cho phép bé làm câu hỏi trắc nghiệm môn Toán và Tiếng Việt, có chấm điểm và hiển thị kết quả ngay sau khi làm Bé có thể nhìn thấy danh sách câu hỏi.

Admin có thể đăng nhập, đăng ký, quản lý các câu hỏi

2 Thiết kế cơ sở dữ liệu và chức năng

private DBHelper dbHelper;

public static final String SQL_CREATE_CAT = "CREATE TABLE tbl_category(\n" +

"\t id INTEGER PRIMARY KEY AUTOINCREMENT,\n" +

"\t name TEXT NOT NULL);";

public static final String TBL_CAT = "tbl_category";

public static final String TAG = "CategotyDAO";

public categoryDao(Context context){

2

Trang 5

db dbHelper= getWritableDatabase();

}

public int insertCat(Category category){

ContentValues values = new ContentValues();

public List<Category> allCat(){

List<Category> categories=new ArrayList<>();

Cursor c=db.query(TBL_CAT,null,null,null,null,null,null ;) c.moveToFirst();

while (c.isAfterLast() == false) {

Category category = new Category(

}

}

2.1.2 User

3

Trang 6

import tktsp.example.a17dtha2_aptracnghiem.endcode.enCode;public class userDao {

private SQLiteDatabase db;

private DBHelper dbHelper;

public static final String SQL_CREATE_USER = "CREATE TABLE tbl_user(\n" + "\t username text PRIMARY KEY,\n" +

"\t password text NOT NULL,\n" +

"\t name_user text NOT NULL,\n" +

"\t email text NOT NULL UNIQUE,\n" +

"\t permission INTEGER NOT NULL);";

public static final String TBL_USER = "tbl_user";

public static final String TAG = "UserDAO";

//kh i t o DB, cho phép ghi sqlở ạ

public userDao(Context context) {

dbHelper = new DBHelper(context);

db = dbHelper.getWritableDatabase();

}

public int insertUser(User user) {

enCode enCode = new enCode();

String pass = enCode.md5(user.getPassword().toString());

ContentValues values = new ContentValues();

values.put("username", user.getUsername());

values.put("password", pass);

4

Trang 7

public List<User> getallUser() {

List<User> dsuser = new ArrayList<>();

Cursor cursor = db.query(TBL_USER, null, null, null, null, null, null)

cursor.moveToFirst();//bắắt đầầu t hàng đầầu tiênừ

while (cursor.isAfterLast() == false) { //nêắu qua kh i phầần t cuốắi cùngỏ ừ User u = new User(

public boolean checkUsername(String username) {

String sql = "SELECT * FROM " + TBL_USER + " WHERE username='" + username + "'"; Cursor c = db.rawQuery(sql, null)

Log.d("giatri", String.valueOf(c.getCount()));

5

Trang 8

public Boolean checkLogin(String username String pass) {,

List<User> listuser = new ArrayList<>();

enCode edCode = new enCode();

String password = edCode.md5(pass);

String sql = "SELECT * FROM " + TBL_USER + " WHERE username='" + username + "' and password='"+ password + "'";

Cursor c = db.rawQuery(sql, null)

public User getProfile(String username) {

// String sql = "SELECT * FROM " + TBL_USER + " WHERE username='" + username + "'"; // WHERE username='" + username + "'

String where="username = ?";

String[] whereArgs={username};

// Cursor c = db.rawQuery(sql, null);

Cursor c=db.query(TBL_USER,null,where whereArgs, ,null,null,null ;)

Trang 9

public class quizcontractDao {

private SQLiteDatabase db;

private DBHelper dbHelper;

public static final String SQL_CREATE_QUIZ = "CREATE TABLE tbl_quiz(\n" + "\t id INTEGER PRIMARY KEY AUTOINCREMENT,\n" +

"\t question text NOT NULL,\n" +

"\t option1 text NOT NULL,\n" +

"\t option2 text NOT NULL ,\n" +

"\t option3 text NOT NULL ,\n" +

"\t answer text NOT NULL, \n" +

"\t category INTEGER NOT NULL);";

public static final String TBL_QUIZ = "tbl_quiz";

public static final String TAG = "QuizContractDAO";

7

Trang 10

dbHelper= new DBHelper(context);

db dbHelper= getWritableDatabase();

}

public int insertQuiz(QuizContract quiz){

ContentValues values=new ContentValues();

public List<QuizContract> getQuizbyCat(int id){

List<QuizContract> listQuiz=new ArrayList<>();

Trang 11

if (db.delete(TBL_QUIZ,where,whereArgs)< ){0 return -1;

}

}catch (Exception e){

Log.e( TAG, e.toString());

}

return ;1

}

public int updateQuiz(QuizContract quiz){

ContentValues values=new ContentValues();

if (db.update(TBL_QUIZ,values where whereArgs)==-, , 1) { return -1;

Trang 12

2.2.Giao diện và code

2.2.1 Đăng Nhập, Đăng Ký

2.2.1.1 Đăng Ký

Code mẫu:

10

Trang 13

public void onClick(View view) {

Intent Main=new Intent(registerUser.this,MainActivity.class) startActivity(Main);

finish();

11

Trang 14

//kh i t o userDao đ bắắt đầầu th c hi n nghi p vở ạ ể ự ệ ệ ụ

userDao=new userDao(registerUser.this ;)

//check điêầu ki nệ

if (edtName.getText().toString().isEmpty() || edtUsename.getText().toString().isEmpty() || edtPassword.getText().toString().isEmpty() || edtRPassword.getText().toString().isEmpty() || edtEmail.getText().toString().isEmpty()){

Toast.makeText(registerUser.this,"Khống Được B Tróng"ỏ ,Toast.LENGTH_LONG).show(); else if } (edtUsename.getText().toString().length()<5 || edtPassword.getText().toString().length()< ){5

Trang 15

public void dialog_success(){

Dialog dialog=new Dialog(this)

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) dialog.setContentView(R.layout.dialog_success)

dialog.show();

Button btnok=(Button) dialog.findViewById(R.id.btnOk) btnok.setOnClickListener(new View.OnClickListener() { @Override

public void onClick(View view) {

intent=new Intent(registerUser.this,MainActivity.class) startActivity(intent)

Trang 16

Code mẫu:

mport androidx.annotation.Nullable;

import androidx.appcompat.app.AppCompatActivity;import android.app.Dialog;

Trang 17

Button btnDangky btnLogin, ;

EditText edtUsername edtPassword, ;

userDao user;

15

Trang 18

user=new userDao(MainActivity.this)

FacebookSdk.sdkInitialize(getApplicationContext());

btnloginf.setReadPermissions(Arrays.asList("public_profile" "email", ));

btnloginf.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override

public void onSuccess(LoginResult loginResult) {

Paper.init(MainActivity.this ;)

Paper.book().write(General.USER_CHECK,"Facebook")

Paper.book().write(General.USER_NAME,"null");

Trang 19

public void onClick(View view) {

Intent AcRegister=new Intent(MainActivity.this,registerUser.class ;)

user=new userDao(MainActivity.this ;)

Boolean taikhoan= user.checkLogin(username password), ;

if (taikhoan==true || username.equals("admin") && password.equals("admin")){

Paper.init(MainActivity.this ;)

Paper.book().write(General.USER_NAME, username);

// Intent AcRegister=new Intent(MainActivity.this,processbar_Activity.class);

Intent AcRegister = new Intent(MainActivity.this,bottomNavigation.class ;)

startActivity(AcRegister);

finish();

else } {

Toast.makeText(MainActivity.this,"Vui Lòng Ki m Tra l i Tài ể ạ

Kh a"ỏ ,Toast.LENGTH_SHORT).show();

Trang 20

Paper.book().write(General.USER_EMAIL, email1);

Trang 21

Code mẫu:

import androidx.appcompat.app.AppCompatActivity;import android.app.Dialog;

Trang 22

import android.widget.Toast;

import tktsp.example.a17dtha2_aptracnghiem.DAO.quizcontractDao;

import tktsp.example.a17dtha2_aptracnghiem.model.QuizContract;

public class addQuestionToan extends AppCompatActivity {

EditText txtcauhoi txtoption1 txtoption2 txtoption3 txtcaudung, , , , ;

Button btnadd btnback, ;

public void onClick(View view) {

Intent intent=new Intent(addQuestionToan.this,quanlyTracNghiem.class)

Trang 23

public void showdialog(){

Dialog dialog = new Dialog(addQuestionToan.this)

public void onClick(View view) {

Intent intent=new Intent(addQuestionToan.this,listTracNghiemToan.class) startActivity(intent);

Trang 24

Code mẫu:

import androidx.appcompat.app.AppCompatActivity;import android.app.Dialog;

Trang 25

import tktsp.example.a17dtha2_aptracnghiem.DAO.quizcontractDao;

import tktsp.example.a17dtha2_aptracnghiem.model.QuizContract;

public class addQuestionVan extends AppCompatActivity {

EditText txtcauhoi txtoption1 txtoption2 txtoption3 txtcaudung, , , , ;

public void onClick(View view) {

Intent intent=new Intent(addQuestionVan.this,quanlyTracNghiem.class ;)

}catch (Exception e){

Log.e("loi",e.toString());

}

}

23

Trang 26

public void showdialog(){

Dialog dialog = new Dialog(addQuestionVan.this)

public void onClick(View view) {

Intent intent=new Intent(addQuestionVan.this,listTracNghiemVan.class) startActivity(intent);

Trang 27

Code mẫu:

import androidx.appcompat.app.AppCompatActivity;import android.app.Dialog;

Trang 28

import tktsp.example.a17dtha2_aptracnghiem.DAO.quizcontractDao;

import tktsp.example.a17dtha2_aptracnghiem.model.QuizContract;

public class detailTracNghiemToan extends AppCompatActivity {

EditText txtcauhoi txtoption1 txtoption2 txtoption3 txtcaudung, , , , ;

Button btnUpdate btnback, ;

public void onClick(View view) {

QuizContract quiz=new QuizContract(

Trang 29

});

btnback.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Intent intent=new Intent(detailTracNghiemToan.this,listTracNghiemToan.class ;) startActivity(intent);

public void showdialog(){

Dialog dialog = new Dialog(detailTracNghiemToan.this)

Trang 30

Intent intent=new Intent(detailTracNghiemToan.this,listTracNghiemToan.class ;) startActivity(intent);

public class detailTracNghiemVan extends AppCompatActivity {

EditText txtcauhoi txtoption1 txtoption2 txtoption3 txtcaudung, , , , ;

Button btnUpdate btnback, ;

Trang 31

public void onClick(View view) {

QuizContract quiz=new QuizContract(

});

btnback.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Intent intent=new Intent(detailTracNghiemVan.this,listTracNghiemVan.class ;)

startActivity(intent);

29

Trang 32

public void showdialog(){

Dialog dialog = new Dialog(detailTracNghiemVan.this ;)

public void onClick(View view) {

Intent intent=new Intent(detailTracNghiemVan.this,listTracNghiemVan.class ;) startActivity(intent);

Trang 33

-List toán:

import androidx.appcompat.app.AppCompatActivity;import androidx.recyclerview.widget.LinearLayoutManager;import androidx.recyclerview.widget.RecyclerView;import android.content.Intent;

Trang 34

import tktsp.example.a17dtha2_aptracnghiem.adapter.tracnghiemtoanAdapter;import tktsp.example.a17dtha2_aptracnghiem.model.QuizContract;

public class listTracNghiemToan extends AppCompatActivity {

recyclerView = (RecyclerView) findViewById(R.id.listquiz)

recyclerView.setLayoutManager(new LinearLayoutManager(listTracNghiemToan.this ;)) quizcontractDao=new quizcontractDao(listTracNghiemToan.this)

listquiz quizcontractDao= getQuizbyCat(1)

adapter=new tracnghiemtoanAdapter(listquiz,this ;)

public void onClick(View view) {

Intent intent=new Intent(listTracNghiemToan.this,addQuestionToan.class ;) startActivity(intent);

}

});

btnback.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Intent intent=new Intent(listTracNghiemToan.this,quanlyTracNghiem.class) startActivity(intent);

Trang 35

- List tiếng việt:

import androidx.appcompat.app.AppCompatActivity;import androidx.recyclerview.widget.LinearLayoutManager;import androidx.recyclerview.widget.RecyclerView;import android.content.Intent;

Trang 36

import tktsp.example.a17dtha2_aptracnghiem.adapter.tracnghiemtoanAdapter;import tktsp.example.a17dtha2_aptracnghiem.model.QuizContract;

public class listTracNghiemVan extends AppCompatActivity {

recyclerView = (RecyclerView) findViewById(R.id.listquiz)

recyclerView.setLayoutManager(new LinearLayoutManager(listTracNghiemVan.this ;)) quizcontractDao=new quizcontractDao(listTracNghiemVan.this ;)

listquiz quizcontractDao= getQuizbyCat(2)

adapter=new tracnghiemtoanAdapter(listquiz,this ;)

public void onClick(View view) {

Intent intent=new Intent(listTracNghiemVan.this,addQuestionVan.class ;) startActivity(intent);

}

});

btnback.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Intent intent=new Intent(listTracNghiemVan.this,quanlyTracNghiem.class ;) startActivity(intent);

Trang 37

2.6 Màn hình khi làm trắc nghiệm

Code mẫu:

import androidx.annotation.RequiresApi;

import androidx.appcompat.app.AppCompatActivity;import android.animation.ArgbEvaluator;

import android.animation.ObjectAnimator;import android.annotation.SuppressLint;

import android.app.Dialog;

35

Trang 38

public class QuizActivity extends AppCompatActivity {

Button btnHuy btnNext, ;

Trang 39

private List<QuizContract> quizContractList;

private int questionCounter;

private int questionTotal;

private QuizContract questionCurrent;

private int score;

private boolean answered;

quizcontractDao quizcontractDao;

private CountDownTimer countDownTimer;

private long timeLeftInMillis;

textColorDefaultCd txtCountDown= getTextColors();

quizcontractDao=new quizcontractDao(QuizActivity.this ;)

Paper.init(QuizActivity.this)

int id_cat= Paper.book().read(General.CATEGORY)

quizContractList quizcontractDao= getQuizbyCat(id_cat);

questionTotal quizContractList= size();

Collections.shuffle(quizContractList); //dòng này cho phép sáo tr n phầần t trong m ngộ ử ả showNextQuestion();

Ngày đăng: 03/01/2025, 21:43

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN