GZHU Software Direction Comprehensive Course Design-Course Management System (Qt+mysql)

Preface

  • Author: Light as the breeze cyf
  • Date: 2021/1/4-2021/1/11
  • This article comes from the Comprehensive Course Design of Software Direction in Senior Three School

1. Topics and Contents of Course Design

1. Basic Facts

(1) Students belong to only one class (e.g. Accounting 181)
(2) There are six classes in Grade 18 of the Accounting Department, one class has a head teacher, and one teacher may be more than one head teacher.
(3) There are required professional courses and optional courses for students (optional courses are not selected by all, so it is necessary to take them together to simplify the elective courses in the same class).
(4) Different classes may be taught together (e.g. 181, 182 databases)
(5) A teacher can belong to more than one course group. A course group includes more than one teacher, and one of them is the person in charge of the course.
(6) A teacher can teach more than one course, and a course may be taught by more than one teacher (e.g. computer introduction is taught by more than one teacher).
(7) There may be more than one teacher in the same class in the same course (e.g. Introduction)
(8) A teacher may teach more than one lesson in the same class
(9) required courses must be opened; if there are not enough people in the optional courses, they should not be opened

2. Time

(1) 1-16 weeks, Monday to Friday, 1-9 sections; the duration of the course must be the same as the course credits.
(2) The same class cannot have more than one lesson in the same section, and different classes may have the same lesson together.
(3) to reduce the workload, regardless of the compulsory courses, the optional courses; only consider the students, only the teachers

3. Users

(1) Students: choose their own optional courses, check their own personal timetable, check their own personal scores, check their own performance points;
(2) Teachers (who are teachers and can only query and modify the course scores)
(3) The Dean (and one of the teachers) can view all the students, courses and teachers, but can only modify the score of the courses he teaches.

2. Experimental Environment (Technical Selection)

1. Language: C++.

2. Development Framework: Qt5.9 (64bit)

3. Development environment: Qt Creator 4.3.0

4. Compiler: MSVC 2017 64bit

5. Database: mysql5.7

Note: [Probable problems]

3. Demand Analysis Design

1. Basic Data Table

2. Basic System Design

3. E-R Diagram


4. Business Needs Consideration

1. Students choose specialized elective courses

(1) Do not conflict with existing courses
(2) The maximum number of elective credits may not be exceeded
(3) Number exceeding maximum capacity is not optional

2. Course Scheduling Requirements

(1) There are two types of specialized required courses and specialized optional courses for students.
(2) Different classes may be taught together
(3) A teacher can belong to more than one course group. A course group includes more than one teacher, one of whom is the course leader.
(4) One teacher may teach more than one course, and one course may be taught by more than one teacher.
(5) There may be more than one teacher teaching the same lesson in the same class
(6) A teacher may teach more than one lesson in the same class
(7) required courses

3. Course Scheduling Algorithm

(1) Prioritize courses in multiple classes.
(2) Walk through the class schedule to find out the common free time for several classes to schedule the course.
(3) There are different schedules for different courses according to the class hours. For 16 weeks each semester, 48 classes have priority over 1-16 weeks of evening classes; 32 classes have priority over 1-16 weeks of daytime classes; 16 classes are mostly experimental classes, which need to be opened after the theory class, so the experiment classes have priority over 9-16 weeks of daytime.

4. Students'personal timetable query

The student's personal timetable includes the duration of the course, the subjects to be taught at the corresponding time, the teacher, the location of the course, the type of course, and the type of examination.

5. Class Schedule Query

There is a basic timetable in a class. The roughly rudimentary form of the students'timetable in this class is the class timetable, which includes specialized required courses, specialized optional courses, general knowledge required courses and other specialized courses.

6. Teachers'personal timetable inquiry

The teacher's personal timetable includes the time of class, the subjects to be taught at the corresponding time, the teacher, the place of class, the type of course, and the type of examination.

7. Teachers Inquire into the Students'Selected Courses Table

Teachers can inquire about their students'choice of subjects, including the number, name and other basic information.

8. Teachers'Scoring

Teachers can enter the results of students who have chosen to teach their own subjects and sign up for a score ranging from 0 to 100.

9. Student Performance Points Ranking

Internal system calculates score points of students with current login account

5. System Functions and Logical Design

1. Teacher System, Student System

2. Administrator System

VI. UI Design and Function Display

1. Login Interface

  • Users choose their own login identity, enter their account number and password to complete the login operation [different identity systems will go to admin table, teacher table, student table to query user account information]

2. Retrieve Password

  • The user can retrieve the password based on the mailbox reserved in the validation user information. When the user enters the account and mailbox, the system automatically matches the mailbox reserved by the user. If the match is successful, the system will send a 6-digit random number validation code to the mailbox. After the user receives the validation code, the user enters the validation code column, sets a new password, and submits the system modification.Correct, the modification is successful, otherwise, the modification is rejected.

3. Administrator function panel

  • The administrator system has three main functions: student information maintenance, course information maintenance and password modification.

4. Student Information Maintenance Interface

  • Administrators can obtain information about students in classes according to their specialties and classes, modify information about students in tables and submit it it to the database, undo changes to table data before submitting to the database, select the cells in which the corresponding students are in the table, delete student records from the database, and update information about students in classes.Record blank lines, enter new student information, submit to the database and refresh the class student information.

5. Administrator Query Teacher's Schedule and Manual Scheduling Interface

  • Administrators can add courses to teachers by clicking on the start cell of the corresponding time of the course, selecting the course, setting the class, week number, number of subsections, location information, and then clicking the Add button to add to the database and refresh the timetable.
  • Administrators can delete lessons from the teacher's timetable: by clicking on the lessons in the timetable and clicking the Delete button, the system deletes records from the database's pool of courses and refreshes the timetable.

6. Administrator queries class schedule and arranges required course interface for class

  • Administrators can select the appropriate class in the class list and view the class schedule information [showing only required courses]. They can add and delete required courses for the class. Add course operation modes: Select course name->Select class->Click the Add Course button. Delete courses in the same way as the teacher's scheduling system.

7. Schedule required courses for the class

  • Intelligent Course Scheduling System: By clicking on the Intelligent Course Scheduling button, the system will automatically schedule all required courses for each class of the profession, and update the automatic Time field related to the database course pool table. Refreshing the course table can see the courses added to the timetable.(Because the accounting class already has data and the software class schedule is empty, the required accounting courses are added to the software class schedule for the convenience of testing)

8. Administrator Change Password

  • After the administrator has logged in successfully, click Modify Password and enter the new password twice in the pop-up window of Modify Password to complete the password modification operation.

9. Teacher Function Panel

  • The teacher system has four main functions: inquiry of teachers'personal timetable, course selection/result management, change of password, and inquiry of all students' information in the grade specific to the dean.
  • DeanNon-dean

10. Query of Teachers'Schedules

  • Teachers can manually select the courses to be offered, which operate in the same way as the administrator-side teacher scheduling system.

11. Teachers inquire about students'information and modify/enter results in selected courses

  • Teachers can choose their own classes, find information about the students in the classes, enter or modify the results in the results column, and submit to the database to update the data.

12. Teachers Change Passwords

13. The Dean inquires about the college students by class

  • The Dean has the right to inquire about the information of students in the whole grade class, and can display the information of students by class, but has no right to modify the data.

14. Student Function Panel

  • The student system consists of four main functions: student selection, timetable query, course results and score query, and password modification.

15. Student Course Selection System

  • Students can drop out of selected courses and choose courses (only one class can be selected for a course).
  • Students can select the corresponding classes and view the basic information of the corresponding teachers.
  • The system can compare the information of students'choosing courses with their individual timetables, detect whether the new course time conflicts with the existing courses, and refuse to choose courses if the conflict occurs.
  • The system can determine whether the number of people who choose a course operates on the maximum capacity of the course. If the number of people who choose a course is full, they refuse to do so.

16. Students Query Personal Schedules

  • Students can click the Query Schedule button to get information about their required and optional courses, which are displayed in the schedule.

17. Student Performance Query

  • Students can query the basic information and results of their selected courses. Clicking on the results query button can display the results information in a pop-up window.

18. Student Change Password

7. Analysis of the results of the experiment, the harvest and experience of the experiment

1. Analysis of experimental results:

(1) Through business requirements analysis, this experiment designs the basic tables and their attributes, and considers the relationship between the tables, completes the design of the relational database.
(2) The experimental GUI is designed using Qt5.9, and through the connection with the database, the data is added or deleted, and the user interaction design is completed, basically meeting the user's needs.
(3) Business logic such as course selection and adjusting has been simplified in this experiment, and there are still some differences with the actual application. There are many factors to consider.

2. Experiments and experiences:

(1) Skilled in using the SQL language to operate MySQL database, add, delete and alter data
(2) A deeper understanding of table building and data structure construction using Power Designer.
(3) Improve the ability to conduct business analysis and business logic design based on a given topic
(4) Learn to use Qt for database connection, and use QSqlTableModel class to query database, insert and update data.
(5) Improve the ability to design user interaction interface according to business requirements, familiarize yourself with the use of each control in Qt development framework, and learn to design simple and reasonable interaction interface.
(6) Improve the ability of rational layout, splitting and reuse of the system's global functions.

8. Download Address

  • Since the database data involves personal information and considering the security of the mailbox retrieve password involving the blogger's own key, only the core source code is provided, along with the packaged software and SQL scripts for the basic tables of SQL.

Note: The database configuration needs the same settings as the source code of the post-text database to connect to the database!

  • Usage: Run sql script to create corresponding database on host, add user information by itself, decompress software, double-click run exe file to use in theory.

9. File directory and core source code

1. File directory

2. Database Connections

QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL");  
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("123456");                                                   
db.setDatabaseName("jwxt_gzhu");                                            
bool bRet=db.open();                                                        
if(bRet==false)                                                             
{                                                                           
    qDebug()<<"error open database"<<db.lastError().text();                 
    QMessageBox::warning(this,"Database Connection Failure","The database could not be connected, please contact the administrator for processing!");               
    exit(0);                                                                
}                                                                           
qDebug()<<"open database success";  

3. Logon window

  • The system queries the database to verify the account information in the corresponding database according to the identity selection, and creates the function panel window of the corresponding identity user after successful login.
  • Identity setting: Administrator: identity=0, Teacher: identity=1, Student: identity=2
//Logon button
    connect(ui->login,&QPushButton::clicked,this,[=](){
        if(indentity==0){
            qDebug()<<"Administrator login ";

            //Get the account password you entered
            QString id = ui->id_input->text();
            QString pwd=ui->pwd_input->text();
            //Query admin table
            QSqlTableModel model;
            model.setTable("admin");
            model.select();
            int rowCount=model.rowCount();
            bool loginSuccess=false;
            for(int i=0;i<rowCount;++i)
            {
                QSqlRecord record=model.record(i);
                if(record.value(0)==id&&record.value(1)==pwd)
                {
                    qDebug()<<"Account password matched database successfully!";
                    adminWin=new AdminWin(id);
                    this->hide();
                    adminWin->show();
                    loginSuccess=true;
                    break;
                }
            }
            if (loginSuccess==false)
                QMessageBox::warning(this,"Logon Failure","Incorrect account or password! Please re-enter!");

        }
        else if(indentity==1){
            qDebug()<<"Teacher Login ";
            
            //Get the account password you entered
            QString id = ui->id_input->text();
            QString pwd=ui->pwd_input->text();
            qDebug()<<"Account acquired:"<<id<<"Password:"<<pwd;

            //Query the teacher table
            QSqlTableModel model;
            model.setTable("teacher");

            model.select();
            int rowCount=model.rowCount();
            bool loginSuccess=false;
            for(int i=0;i<rowCount;++i)
            {
                QSqlRecord record=model.record(i);
                
                if(record.value(0)==id&&record.value(4)==pwd)
                {
                    qDebug()<<"Account password matched database successfully!";
                    teacherWin=new TeacherWin(id);
                    this->hide();
                    teacherWin->show();
                    loginSuccess=true;
                    break;
                }
            }
            if (loginSuccess==false)
                QMessageBox::warning(this,"Logon Failure","Incorrect account or password! Please re-enter!");
        }
        else{
            qDebug()<<"Student Login ";

            //Get the account password you entered
            QString id = ui->id_input->text();
            QString pwd=ui->pwd_input->text();
            qDebug()<<"Account acquired:"<<id<<"Password:"<<pwd;

            //Query the teacher table
            QSqlTableModel model;
            model.setTable("student");

            model.select();
            int rowCount=model.rowCount();
            bool loginSuccess=false;
            for(int i=0;i<rowCount;++i)
            {
                QSqlRecord record=model.record(i);

                if(record.value(0)==id&&record.value(5)==pwd)
                {
                    qDebug()<<"Account password matched database successfully!";
                    studentWin=new StudentWin(id);
                    this->hide();
                    studentWin->show();
                    loginSuccess=true;
                    break;
                }
            }
            if (loginSuccess==false)
                QMessageBox::warning(this,"Logon Failure","Incorrect account or password! Please re-enter!");

        }
});

4. Defined functions related to database access

class SqlTools
{
public:
    SqlTools();
    //Get corresponding fields based on identity and id, required field name
    QVariant getPersonalInfo(int identity,QString id,QString infoNeed);
    //Query coursetable to get all course ids//types: Query course categories: 0:all, 1:required, 2:optional
    QVariantList getCourseIds(int type);
    //Query the coursetable to get basic information about the course
    QSqlRecord getCourseInfo(QString id);
    //Query the coursePool table to get the start information
    QList<QSqlRecord> getCourseOpenInfo(QString courID);
    //Query sc table to get the number of students selected for a course
    int getCourseSelectCount(QString CPID);
    //Query the sc table to determine if a course has a choice
    bool isSelectCourse(QString stuID,QString CPID);
    //Query sc table to get individual course selection
    QList<QSqlRecord> getStuSelectCourses(QString stuID);
    //Query the coursePool table to get information about the teachers'choice of courses
    QList<QSqlRecord> getTeaSelectCourses(QString teaID);
    //Add course selection records to sc table
    bool addCourseRecord(QString stuID,QString CPID);
    //Delete course selection records from sc table
    bool removeCourseRecord(QString stuID,QString CPID);
    //Query the coursepool table for information
    QSqlRecord coursePoolInfo(QString CPID);
    //Pop-up window showing specified teacher information
    void showTeacherInfo(QString TeaName);
    //Get course information based on query criteria
    QList<QSqlRecord> getCourses(QString filter,QString value);
    //Gets the value of a field in the specified table
    QList<QVariant> getTableColumnList(QString tableName,QString fieldName);
    //Get a teacher id based on the name of the teacher
    QString getPersonalIDbyName(int identity,QString name);
    //Delete course from coursepool
    bool removeCourseFromCoursepool(QString CPID);
    //Get all records in the table that meet the criteria based on the criteria
QList<QSqlRecord> getFilterRecords(QString tableName,QString filter,QString value);

private:
    QSqlTableModel* model;
};

5. Functions defined by the timetable system (timetable query, scheduling, adding or deleting courses, etc.)

class CourseTable;
}

class CourseTable : public QWidget
{
    Q_OBJECT

public:
    explicit CourseTable(int identity,QString id,QWidget *parent = 0);
    ~CourseTable();

private:
    Ui::CourseTable *ui;
    int identity;
    QString id;
    SqlTools * sqlTool;
    //Query Database for Course Table Information
public slots:
    void getCourseToTable();
    void getCourse();
    void addCourse();
    void removeCourse();
    void getClassCourse();
    void getCoursepoolList();
    void addCourseForClass();  //Add lessons to the class [Modify the opening class field in the coursePool table]
    void removeCourseForClass();   //Move the class out of the course [Modify the opening class field in the coursePool table]

    void autoScheduleCourse();  //Intelligent Scheduling

    QString getDay(int column);  //Number of turns, e.g. 1->Monday
    QString getSection(int section);  //Sections 1->1-2
};

6. Functions defined by the Student Information Management System

class studentInfoManage : public QWidget
{
    Q_OBJECT

public:
    explicit studentInfoManage(QWidget *parent = 0);
    ~studentInfoManage();

private:
    Ui::studentInfoManage *ui;
    QSqlTableModel* model;
    QTableView* view;
    QVBoxLayout* lay;
    QStandardItemModel* addRecordTable;

//    QSqlTableModel* modelAdd;
//    QTableView* viewAdd;
//    QVBoxLayout* layAdd;

public slots:
    void addClassName();  //Add class name (read from database according to specialty)
    void selectClassAndShowTable();  //Select a class and refresh the class information
    void addRecord();  //Add a new record to the table
    void addCommit();  //Submit new data
    void modifyComfirm();  //Confirm data modification (submit database)
    void modifyRestore();  //Undo Modification
    void removeRecords();  //Delete selected records

    void hideModifyTools();
    void setTitle(QString title);

};

7. Functions Defined by Student Course Selection System

class Course_Selection;
}

class Course_Selection : public QWidget
{
    Q_OBJECT

public:
    explicit Course_Selection(QWidget *parent = 0);
    explicit Course_Selection(QString id,QWidget *parent = 0);
    ~Course_Selection();
    void getID(QString id);
    void welcome();
private:
    Ui::Course_Selection *ui;
    QString userId;
    QSqlTableModel* model;
    SqlTools* sqlTool;
    QTreeWidgetItem* currentItem;
public slots:
    void getCourses(int courseType); //Query database for optional courses, add to form tree control
    void selectCourse();  //Students choose courses, sc table adds records	
    void cancelSelectCourse();  //Drop out of class, delete records from sc table
    void showCourseTeacherInfo();  //Get Teacher Information
};

10. Development Log

Keywords: Database MySQL Qt

Added by dadamssg on Thu, 14 Oct 2021 20:11:03 +0300