Design and Implementation of Fill-in-the-blank Questions based on Open Source Online Judge System

This report discusses the shortcomings of the existing online judge system's problem type, and describes the implementation and applicability of the fill-in-the-blank questions based on the open source online judge system. It is based on the open source online judge system named HUSTOJ, to realize the online judgment function of code-fill-in-the-blank and result-fill-in-the-blank questions by analyzing its system architecture, judgment process and redesigning its database.


Introduction
With the advent of the artificial intelligence era, programming skills have become a research hotspot of education at home and abroad [1]. Recently, in China, the Ministry of Education's newly released "Key Points of Educational Informationization and Cybersecurity in 2019" pointed out that education informationization should become the supporter and leader of education modernization, and it needs to promote the implementation of programming education in primary and secondary schools [2]. However, through years of teaching practice experience, programming education can not effectively reflect the students' programming level through the examination of the face-to-face test. For this reason, the online judge system has been developed to assist teachers in programming teaching [3].
Online judge system originated from ACM International Collegiate Programming Contest (ACM-ICPC). The user can submit the source code of various programming languages (such as C, C++) online, compile and execute it, and verify the correctness of the program source code through predesigned test data [4]. Today, quite a few universities in China have developed appropriate online judge systems, such as POJ, HUSTOJ, ZOJ, XUJCOJ, Lanqiao Cup practice system and more.
The existing online judge system has been perfected to meet the needs of programming teaching in domestic universities. Nevertheless, if these systems are deployed to primary and secondary schools and high school, there will be two obvious shortcomings: -The single type of question is easy for students to lose interest in doing the problem.
-Programming problems are so difficult that they are not suitable for beginners to practice. For the purpose of reducing the difficulty of learning programming and enhancing the interest of beginners in programming learning, this report will add code-fill-in-the-blank and result-fill-in-theblank questions based on the open source system called HUSTOJ. HUSTOJ [5][6] is the online judge system of Huazhong University of Science and Technology (HUST). It was open source under the GPL protocol at the end of 2008. The system architecture consists of two parts: web and core. This report mainly focuses on the modification and extension of the web part.

HUSTOJ System
The HUSTOJ system is deployed with using the LNMP (Linux + Nginx + MySQL + PHP) architecture. The structure of the system consists of a front end and a core judge end, and the two ends share a database to realize data communication between them. The answer submitted by the user will be stored in the database through the web side, and afterward the core will read the data from the database to judge the problem and write the result to the database. This is beneficial to achieve centralized control of data and to ensure data consistency and maintainability. The programming problem of the HUSTOJ system is judged at the core end. The core end polls the queue of pending questions from the database. When the length of the queue is greater than 0, the answer code will be extracted for compilation. If the compilation error occurs, an error is returned. After the compilation is successful, the system will use the test data to verify the correctness of the compiled program, and only when all the test data has passed will it return success. When the answer is completely correct, the system will also check the code for plagiarism.

Design of Fill-in-the-blank Questions
The result-fill-in-the-blank questions are dissimilar from the code-fill-in-the-blank questions. The answer to the result-fill-in-the-blank question is a string, which requires the user to submit a string that cannot contain any other characters including spaces and newlines. It does not require being compiled and it can be directly judged at the web end. It can effectively save system resources and improve the efficiency of judgment. The answer to the code-fill-in-the-blank question is a code. And the system fills it into the missing piece of pre-prepared compilable code and writes it to the database. Therefore, the code-fill-in-the-blank problem needs to be compiled, and the judgment is the same as the programming problem. Both of them are read by the core to evaluate the database.

Design of the Database
There are more than 20 tables in the database of HUSTOJ system. The tables used at the core end are the solution, the problem, the compileinfo, the sim, the users, the custominput, the runtimeinfo, and the source_code . The solution table holds the answers submitted by the user, and the problem  table holds the details of the problem, and the source_code table holds the codes submitted by the  user. Since the table for recording the fill-in-the-blank information cannot affect the original database, in order to effectively manage the fill-in-the-blank problem, the problem_fill and solution_fill tables are added to the original database.
The problem_fill table records the mark of the fill-in-the-blank question, the correct answer to the result-fill-in-the-blank question, the missing code for the code-fill-in-the-blank question, and the missing mark.

The Code Design of the Judgment
After filling the answer of the missing code, the code-fill-in-the-blank passes it to the core end for judgment. When there is more than one code filled in, the system uses md5 to distinguish each answer of the fill-in-the-blank question. The key code is as follows: $

System Testing
The system's judgment is based on the black box test method, and the report will also use the black box test method to test the system. From the test results in Figure 4, it is known that the system after the extended fill-in-the-blank question can achieve the desired effect.

Summary
This paper deeply studied the working principle of the open source online judge system, and added the function of setting the fill-in-the-blank question. The questioner could not only set the programming problem, but also set the result-fill-in-the-blank and the code-fill-in-the-blank question. The system source code after the extended fill-in-the-blank question was stored in the GitHub code repository [7]. In the following research, we could continue to expand other types of questions such as multiple-choice questions and judgment questions. And you could also add other practical features such as school-level exams and contests.