Programming simulation operation question generation method, display control method and related products

By generating and displaying programming simulation problems, and using abstract syntax trees to linearize code blocks and results, the problem of existing programming problems not being able to intuitively demonstrate the running logic is solved, thus improving the code comprehension ability and learning efficiency of young children.

CN121565044APending Publication Date: 2026-02-24BEIJING SIMING QICHUANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511771430.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-27
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

Existing programming problems fail to intuitively demonstrate the execution logic of program code, making it difficult for young children to develop a logical understanding of program code execution.

Method used

By generating programming simulation challenges, the code of the challenges is linearized using an abstract syntax tree to identify the code blocks that can be tested, and corresponding challenges are generated based on the execution results of these code blocks. The execution order and results of these code blocks are displayed so that users can understand the real execution logic of the code.

Benefits of technology

It improves young children's understanding of program code execution logic, reduces learning difficulty, and increases learning efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121565044A_ABST
    Figure CN121565044A_ABST
Patent Text Reader

Abstract

The invention provides a programming simulation operation question generation method, a display control method and a related product. The display control method comprises the following steps: acquiring a programming simulation operation question; the programming simulation operation question comprises question codes and questions for each investigable code block in the question codes; the investigable code block is a code block which generates actual operation in the title code; and displaying the programming simulation operation problem. Therefore, the user can know the sequential execution process of each code block of the title code on the basis of seeing the title code, so that the execution sequence of the code can be more intuitively known, and the internal logic of the code is understood.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of code programming teaching technology, and more specifically, to a method for generating programming simulation exercises, a display control method, and related products. Background Technology

[0002] The essence of programming is "solving real-world problems with code," and acquiring this ability requires students to repeatedly practice with targeted test questions, transforming abstract concepts into actionable skills, and ultimately achieving the leap from "knowledge understanding" to "problem-solving." Therefore, in the implementation of coding education, programming problems are usually used to assist students' learning and drive their skill advancement.

[0003] Most current programming problems focus on writing complete or partial code. However, these problems do not reflect the real-world execution scenarios of the code, making it difficult for users to develop a logical understanding of the program's execution based on the problems. Summary of the Invention

[0004] The purpose of this application is to provide a method for generating programming simulation problems, a display control method, and related products, in order to solve the problem that existing programming problems do not intuitively demonstrate the running logic of program code, making it difficult for young children to develop a logical understanding of program code execution.

[0005] In a first aspect, embodiments of this application provide a method for generating programming simulation questions, comprising: obtaining question code; the question code comprising at least two code blocks; Generate an abstract syntax tree for the code of the given problem; The problem code is linearized based on the abstract syntax tree to obtain the linearized code of the problem code; wherein each line of code in the linearized code corresponds to a code block in the problem code; Based on the abstract syntax tree, examineable code blocks are identified in the problem code; the examineable code blocks are the code blocks in the problem code that generate actual operations. Based on each of the examineable code blocks and the correct execution results of each of the examineable code blocks when executed in the question code, a question is generated for each of the examineable code blocks.

[0006] In the above implementation process, since the abstract syntax tree is the structured representation of the question code, and the linearization of the question code is generated based on the abstract syntax tree, the linearized code can reflect the actual execution logic of the question code. Thus, based on the linearized code, the examineable code blocks in the question code can be reliably identified. Furthermore, since the questions for examineable code blocks are generated based on each examineable code block and the correct execution results when each examineable code block is executed, the questions closely match the real-world execution scenario of the question code, improving the authenticity and reliability of the questions. This allows users to build a logical understanding of the program code execution through the questions.

[0007] Optionally, examineable code blocks in the problem code are determined based on the abstract syntax tree, including: Determine the leaf nodes of the abstract syntax tree, wherein the leaf nodes are nodes in the abstract syntax tree that have no child nodes; For each leaf node, starting from that leaf node, backtracking layer by layer along the parent-child relationship path of the abstract syntax tree towards the root node. When the backtracking first reaches an operation node, the operation node and all its child nodes are identified as the code blocks in the problem code that can be examined. The operation node represents the node used to perform the specific operation.

[0008] In the above implementation, since the abstract syntax tree (API) is a structured representation of the problem code, there is a correspondence between each node in the API and the code fields in the problem code. Therefore, starting from a leaf node in the API, the code is backtracked layer by layer along the parent-child relationship path towards the root node. When an operation node is reached for the first time, the corresponding code blocks of that operation node and all its child nodes in the problem code are identified as examineable code blocks. This allows for the accurate identification of the smallest code block that can generate actual operations from the problem code, facilitating the setting of corresponding problems for any stage of the problem code's execution.

[0009] Optionally, the problem code is linearized based on the abstract syntax tree to obtain linearized code, including: Traverse each node in the abstract syntax tree and generate the code field corresponding to each node; For each branch structure in the abstract syntax tree, the code fields corresponding to each node in the branch structure are combined according to the parent-child relationship between each node and the node type of each node to obtain the code line corresponding to the branch structure. The code lines corresponding to each branch structure are arranged according to their sequential position in the abstract syntax tree to obtain the linearized code.

[0010] In the above implementation, there is a correspondence between the branching structure in the abstract syntax tree and the code blocks in the problem code. In other words, the abstract syntax tree itself is a structured representation of the problem code. Therefore, by traversing the abstract syntax tree and generating linearized code according to the parent-child relationships between nodes in the abstract syntax tree and the node type of each node, the generated linearized code can be made to have the same execution logic as the actual execution logic of the problem code. Thus, when running the code blocks in the problem code based on the linearized code, the actual execution logic of the problem code can be simulated through the linearized code, thereby helping users understand the execution logic of the problem code without actually running the problem code.

[0011] Optionally, based on each of the examineable code blocks and the execution results of each of the examineable code blocks when executed in the question code, a question is generated for each of the examineable code blocks, including: For at least a portion of the target examineable code blocks in all examineable code blocks, generate questions for each of the target examineable code blocks; The questions for each of the aforementioned target examineable code blocks are generated based on the execution results of each of the aforementioned target examineable code blocks when they are executed in the question code and the corresponding error execution results of each of the aforementioned target examineable code blocks; the error execution results corresponding to each of the aforementioned target examineable code blocks are different from the execution results of each of the aforementioned target examineable code blocks when they are executed.

[0012] In the above implementation, questions are generated based on the execution results of the target examineable code block and the corresponding error results of each target examineable code block. This ensures that the questions closely match the real-world execution scenario of the code, effectively helping users understand the code logic and improving their learning outcomes.

[0013] Optionally, based on each examineable code block and the execution result of each examineable code block, questions are generated for each examineable code block, including: For a set of examineable code blocks, a question is generated based on the execution results of each examineable code block in the question code when it is executed. The examineable code block group includes at least two adjacent examineable code blocks that have an interaction relationship.

[0014] In the above implementation, multiple examineable code blocks with interactive relationships are treated as a whole, forming an examineable code block group. A question is then generated based on this examineable code block group, allowing for question generation for code blocks of varying complexity. When a code block with a question is subsequently triggered, displaying that question helps the user learn about the multiple interacting code blocks.

[0015] Optionally, the question code includes variables, and the execution result of each examineable code block when executed in the question code includes the variable value corresponding to each examineable code block when executed in the question code. Based on each examineable code block and the execution result of each examineable code block, a question is generated for each examineable code block, including: The variables of the problem code are determined based on the abstract syntax tree; For any testable code block, generate questions based on the testable code block and the variable values ​​corresponding to the testable code block when it is executed.

[0016] In the above implementation, since the examineable code block is the code block in the question code that generates the actual operation, it is usually closely related to variable values. Therefore, the variable values ​​corresponding to the examineable code block when it is executed in the question code can reflect the actual operation of the examineable code block. By generating questions based on this examineable code block and its corresponding variable values ​​when executed in the question code, it is possible to combine the abstract execution logic of the code with specific state changes (variable values). This allows users to learn about difficult content related to variables and actual operations through these questions, thereby reducing the difficulty for users to understand the changes of variables and other difficult content related to actual operations throughout the code execution process.

[0017] Optionally, the variables for determining the problem code based on the abstract syntax tree include: Determine the variable declaration node in the abstract syntax tree; Extract the variable from the attribute information of the variable declaration node.

[0018] In the above implementation, since the abstract syntax tree (AST) is a structured representation of the problem code, variable declaration nodes are determined within the AST, and variables are extracted from the attribute information of each variable declaration node. This allows for the accurate identification of each variable in the problem code.

[0019] Optionally, when the examineable code block is a code block representing a conditional judgment, the correct execution result of the examineable code block includes the judgment result of the code block representing the conditional judgment. Based on each examineable code block and the execution result of each examineable code block, a question is generated for the examineable code block, including: Based on the examineable code block and the judgment result when the examineable code block is executed, a question is generated for the examineable code block.

[0020] In the above implementation, since the examineable code block represents a conditional judgment, the actual operation generated by the examineable code block is usually related to the judgment result. Therefore, the judgment result when the examineable code block is executed in the question code can reflect the actual operation of the examineable code block. By generating a question based on the examineable code block and the judgment result when it is executed in the question code, the abstract execution logic of the code can be combined with the specific state changes (judgment results). This allows users to learn about the code block representing conditional judgments through the question, thereby reducing the difficulty for users to understand the changes of difficult content related to actual operations, such as the code block representing conditional judgments, throughout the entire code execution process.

[0021] Secondly, this application provides a display control method for a programming simulation exercise, comprising: Obtain programming simulation exercises; the programming simulation exercises include question code and questions targeting each examineable code block in the question code; the examineable code block is the code block in the question code that generates the actual operation; The programming simulation exercise is displayed.

[0022] Because current programming problems don't visually demonstrate the execution logic of program code, young children often struggle to understand the specific meaning of the code, hindering their ability to develop a logical understanding of program code execution. To address this issue, the above implementation displays a simulated programming problem, including the problem code and questions testing each code block. This allows users to understand the sequential execution of each code block, providing a more intuitive understanding of the code's execution order and its internal logic.

[0023] Optionally, the programming simulation exercise is displayed, including: Display all code blocks of the problem code; The code blocks are triggered sequentially according to the execution logic of the question code, and the triggered code blocks are executed based on the linearized code corresponding to the code block; the linearized code is a code sequence obtained by linearizing the question code based on the abstract syntax tree of the question code; If the currently running code block is an examineable code block, display the question for the examineable code block, and after the question is answered, allow triggering the next code block of the currently running code block.

[0024] In the above implementation scheme, when the currently triggered code block is a testable code block with a set question, the question will be displayed. Since the testable code block is the code block within the question code that generates the actual operation, it is usually related to variables, and the question corresponding to the testable code block is generated based on the correct execution result when the testable code block is executed. Therefore, when a code block with a set question is triggered, displaying the question promptly for the user to learn allows for timely learning of difficult content related to variables and actual operations, based on the code execution order. This reduces the difficulty for users to understand the changes in variables and other difficult content related to actual operations throughout the code execution process. Therefore, the solution of this application makes it easier for younger users to understand the internal logic of program code and variable changes, thus reducing the learning difficulty for younger users and improving learning efficiency.

[0025] Optionally, after the problem is solved, it is allowed to trigger the next code block of the currently running code block, including: Obtain the answer data for the given question; If the answer data differs from the correct answer to the question, a first prompt message is output, indicating an error in the answer data; or... If the answer data matches the correct answer to the question, the next code block of the currently running code block is allowed to be triggered.

[0026] In the above implementation, the next code block of the currently executed code block is only triggered if the answer matches the correct answer. This requires the user to answer the question for the currently executed code block accurately, and accurate answers require the user to truly understand the function and execution logic of the current code block. This forces the user to "execute" the code at a cognitive level, rather than passively browsing. It guides the user's thinking to synchronize with the program's execution flow, helping the user gradually build a correct understanding of each code block. As the user accumulates and connects their understanding of each code block, they can gradually piece together a complete understanding of the entire question's code execution logic.

[0027] If the user's answer does not match the correct answer, the system will output a prompt message informing the user that their answer is incorrect. This allows the user to promptly recognize any misunderstandings or logical errors, enabling them to reflect and correct their mistakes in a timely manner, thus reducing the accumulation of misconceptions.

[0028] Optionally, each of the code blocks is triggered sequentially according to the execution logic of the question code, including: In response to the triggering operation of any code block, if the previously triggered code block is the code block preceding the code block in the execution logic of the question code, then the code block is executed and the triggered code blocks and / or their corresponding execution results are displayed sequentially in the preset result recording area. If the previously triggered code block is not the preceding code block in the execution logic of the code in the question, a second prompt message indicating an error in the code execution order will be fed back.

[0029] In the above implementation, by limiting the triggering and display of each code block to a specific execution logic, users can intuitively understand the execution order of the code and comprehend its internal logic through the display sequence of the code blocks. Simultaneously, by displaying the execution results of each triggered code block in the results recording area, users can understand the actual operations triggered by each code block, thereby reducing the difficulty for users to understand the changes in complex aspects related to actual operations throughout the code's execution process.

[0030] Optionally, the execution result corresponding to the code block includes variable name and / or variable value; displaying the execution result corresponding to each triggered code block includes: The pre-defined variable table is updated sequentially based on the execution results of each code block; The updated variable table is displayed sequentially in the preset result record area. The variable table is used to store each variable in the question code and the value of each variable.

[0031] In the above implementation, a pre-defined variable table is updated sequentially based on the execution results of each code block, and the updated variable table is then displayed sequentially in a pre-defined result record area. Since code blocks typically generate actual operations, and these operations are usually related to variables, changes in the variable states in the variable table can reflect the abstract operational logic of the problem code. This transforms the abstract operational logic of the problem code into a visual representation of changes in variable states, allowing users to understand the operational logic of the problem code through these changes, significantly reducing the difficulty for users to comprehend the abstract operational logic of the problem code.

[0032] Thirdly, this application provides a display control system for programming simulation exercises, including: a system front-end and a system back-end; The system backend is configured to acquire question code; the question code includes at least two code blocks; generate an abstract syntax tree (AST) of the question code; linearize the question code based on the AST to obtain linearized code; wherein each line of code in the linearized code corresponds to a code block in the question code; determine the examineable code blocks in the question code based on the AST; the examineable code blocks are the code blocks in the question code that generate actual operations; and generate questions for the examineable code blocks based on each examineable code block and the execution results when each examineable code block is executed. The system front-end is configured to acquire and display the programming simulation test questions; the programming simulation test questions include the test question code and questions for each of the testable code blocks.

[0033] Fourthly, this application provides a device for generating programming simulation problems, comprising: The first acquisition module is configured to acquire the question code; the question code includes at least two code blocks. The first generation module is configured to generate an abstract syntax tree for the code of the problem; The code linearization module is configured to linearize the problem code based on the abstract syntax tree to obtain linearized code of the problem code; wherein each line of code in the linearized code corresponds to a code block in the problem code; The determination module is configured to identify examineable code blocks in the problem code based on an abstract syntax tree; the examineable code blocks are the code blocks in the problem code that generate actual operations. The second generation module is configured to generate questions for each of the examineable code blocks based on each of the examineable code blocks and the execution results of each of the examineable code blocks. Fifthly, this application provides a display control device for a programming simulation exercise, comprising: The second acquisition module is configured to acquire programming simulation exercise questions; the programming simulation exercise questions include question code and questions targeting each examineable code block in the question code; the examineable code block is the code block in the question code that generates the actual operation; The display module is configured to display the programming simulation exercise.

[0034] Sixthly, embodiments of this application provide an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the programming simulation exercise generation method of the first aspect and / or the programming simulation exercise display control method of the second aspect.

[0035] In a seventh aspect, embodiments of this application provide a storage medium storing computer-executable instructions. When the computer-executable instructions are invoked and executed by a processor, the computer-executable instructions cause the processor to implement the programming simulation exercise generation method of the first aspect and / or the programming simulation exercise display control method of the second aspect.

[0036] Eighthly, according to an embodiment of this application, a computer program product includes a computer program that, when executed by a processor, implements the method for generating programming simulation exercise questions of the first aspect and / or the method for displaying programming simulation exercise questions of the second aspect. Attached Figure Description

[0037] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is a flowchart illustrating a method for generating programming simulation questions provided in an embodiment of this application; Figure 2 This is a flowchart illustrating a method for displaying and controlling a programming simulation exercise, as provided in an embodiment of this application. Figure 3 This is a schematic diagram illustrating a title code provided in an embodiment of this application; Figure 4(a) shows the results based on Figure 3 The diagram shows the structure of the abstract syntax tree for the first part corresponding to the code in the example question. Figure 4(b) shows the results based on... Figure 3 The diagram shows the structure of the abstract syntax tree for the second part corresponding to the code in the example question. Figure 4(c) is based on Figure 3 The diagram shows the structure of the abstract syntax tree for the third part corresponding to the code in the example question. Figure 5 for Figure 3 A diagram illustrating a compound statement code snippet; Figure 6(a) shows the results based on... Figure 3 The diagram shows the structure of the abstract syntax tree for the first part corresponding to the code in the example question. Figure 6(b) is based on Figure 3 The diagram shows the structure of the abstract syntax tree for the second part corresponding to the code in the example question. Figure 7 To Figure 3 The diagram shows the result of marking the examineable code segments in the code of the problem shown. Figure 8 for Figure 3 A diagram illustrating the linearized code corresponding to the given problem code; Figure 9 This application provides a schematic diagram of the display interface of the system front end. Figure 10 This application provides another schematic diagram of the system front-end display interface; Figure 11(a) is a schematic diagram of the structure of a variable table provided in an embodiment of this application; Figure 11(b) is a schematic diagram of another variable table structure provided in an embodiment of this application; Figure 12 A schematic diagram of a device for generating programming simulation problems provided in this application embodiment; Figure 13 A schematic diagram of the structure of a display control device for a programming simulation exercise provided in this application embodiment; Figure 14 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0039] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0040] Example 1: To address the problem that existing programming problems do not closely resemble real-world code execution scenarios, hindering users from developing a logical understanding of program code execution based on the problems, this application provides a display control system for simulating programming problems, including a system front-end and a system back-end. The system front-end and system back-end can be on the same electronic device, or they can be on different electronic devices.

[0041] The system backend is used to generate the questions, while the system frontend is used to control the display of the simulated questions.

[0042] Combination Figure 1 As shown, this application provides a method for generating programming simulation questions, which can be applied to the system backend. The method for generating programming simulation questions may include the following steps: Step S101: Obtain the problem code; the problem code includes at least two code blocks.

[0043] Optionally, the problem code can be a code snippet with a specific code structure. This specific code structure can include at least one of sequential, selection, and loop structures. The problem code can also be code within a function that implements a specific function.

[0044] Step S102: Generate the abstract syntax tree of the problem code.

[0045] Abstract syntax trees (ASTs) represent the syntactic structure of problem code in a tree-like format, where each node in the tree represents a syntactic structure within the problem code. In this embodiment, after obtaining the problem code, each code block can be traversed, and lexical analysis can be performed on each code block to generate an AST.

[0046] This transforms the problem code from unstructured text data into highly structured data, facilitating more systematic analysis and improving the accuracy of subsequent code analysis. Furthermore, it allows for code normalization, removing meaningless code blocks (such as comments) and symbols used only for syntax delimiters, thus eliminating redundancy and improving the efficiency of subsequent code analysis.

[0047] Step S103: Linearize the problem code based on the abstract syntax tree to obtain the linearized code of the problem code; wherein each line of code in the linearized code corresponds to a code block in the problem code.

[0048] Optionally, each node in the abstract syntax tree can be traversed to generate the code field corresponding to each node; for each branch structure in the abstract syntax tree, the code fields corresponding to each node in the branch structure are combined according to the parent-child relationship between each node and the node type of each node to obtain the code line corresponding to the branch structure; the code lines corresponding to each branch structure are arranged according to the order of each branch structure in the abstract syntax tree to obtain the linearized code.

[0049] Step S104: Based on the abstract syntax tree, determine the examineable code blocks in the problem code; the examineable code blocks are the code blocks in the problem code that generate actual operations.

[0050] Optionally, leaf nodes of the abstract syntax tree can be determined. Leaf nodes are nodes in the abstract syntax tree that have no child nodes. For each leaf node, starting from that leaf node, backtracking layer by layer along the parent-child relationship path of the abstract syntax tree towards the root node. When the backtracking first reaches an operation node, the code block corresponding to that operation node and all its child nodes in the problem code is determined as the testable code block; the operation node represents the node used to perform the specific operation.

[0051] Optionally, the operation node can be one of the operator node, variable declaration node, and return statement node.

[0052] In an abstract syntax tree, operator nodes represent operations such as calculation, comparison, logical judgment, or assignment. Variable declaration nodes represent the introduction of a variable. Return statement nodes represent return statements.

[0053] Step S105: Based on each examineable code block and the execution result of each examineable code block, generate questions for the examineable code blocks.

[0054] Optionally, the linearized code of the problem code can be run to obtain the execution result of each line of code in the linearized code. Based on the correspondence between each line of code in the linearized code and the code block in the problem code, the execution result of each line of code is determined as the correct execution result of the corresponding code block.

[0055] Alternatively, the interpreter can be used to execute each line of code in the linearized code sequentially to obtain the execution result of each line of code.

[0056] Optionally, a subset of examineable code blocks can be selected from all examineable code blocks, and corresponding questions can be generated for each selected examineable code block. Alternatively, questions can be generated for each examineable code block individually. Furthermore, questions can be generated for multiple adjacent examineable code blocks that interact with each other.

[0057] In one optional implementation of this application, generating questions for each examineable code block based on each examineable code block and the execution result of each examineable code block includes: generating questions for at least some target examineable code blocks among all examineable code blocks; the questions for each target examineable code block are generated based on the execution result of each target examineable code block and the corresponding error execution result of each target examineable code block; the error execution result corresponding to each target examineable code block is different from the execution result of each target examineable code block.

[0058] In some embodiments, for each target examineable code block, the execution result when the target examineable code block is executed and the error execution result that is different from the execution result can be structured, thereby converting it into a structured question that can be displayed and selected by the user.

[0059] In one embodiment, for each target examineable code block, given the execution result of the target examineable code block, an erroneous execution result different from that result can be automatically generated. Alternatively, a third prompt message can be issued, including the execution result of the target examineable code block, to prompt the user to input data different from that result. Upon receiving feedback data for the third prompt message, if the feedback data differs from the execution result of the target examineable code block, then the feedback data is taken as the erroneous execution result corresponding to that target examineable code block.

[0060] In another optional implementation of the embodiments of this application, questions are generated for each examineable code block based on the execution results of each examineable code block when it is executed. This includes: for a group of examineable code blocks, generating questions for the group of examineable code blocks based on the correct execution results of each examineable code block in the question code; wherein, the group of examineable code blocks includes at least two adjacent examineable code blocks that have an interaction relationship.

[0061] For example, in Figure 3 The test code shown includes testable code blocks such as "int i=1", "i<=5", and "i++". These testable code blocks interact with each other; that is, after "i++" is executed, the result of the judgment in "i<=5" may change accordingly.

[0062] Similarly, it is possible to obtain error results that differ from the execution results of each examineable code block when it is executed in the question code, and then structure the question information for that examineable code block group (including error results and execution results when the examineable code block group is executed), thereby converting it into a structured question that can be displayed and selected by the user.

[0063] In one optional implementation of this application's embodiments, the question code includes variables, and the execution result of each examineable code block includes the variable value corresponding to the execution of each examineable code block. Based on each examineable code block and the execution result of each examineable code block, questions are generated for each examineable code block, including: The variables in the question code are determined based on the abstract syntax tree; for any testable code block, a question is generated based on the testable code block and the variable values ​​corresponding to the testable code block when it is executed.

[0064] Optionally, the variable values ​​corresponding to the testable code block when it is executed in the question code, as well as the values ​​that are different from the variable values ​​corresponding to the testable code block when it is executed, can be structured to obtain the question for the testable code block.

[0065] Optionally, variable declaration nodes can be identified in the abstract syntax tree; variables can be extracted from the attribute information of the variable declaration nodes.

[0066] Optionally, the attribute information of the variable declaration node may include the variable's name, variable type, and the variable's position in the question code. The variable's position in the question code may include the variable's row number and column number in the question code.

[0067] For example, if the problem code is C++ code, the variable declaration node in the abstract syntax tree corresponding to the problem code can include "VarDecl:".

[0068] If the problem code is Java code, then the variable declaration node in the abstract syntax tree corresponding to the problem code can include "VariableDeclarationFragment:".

[0069] Alternatively, regular expressions can be used to identify variables in the problem code.

[0070] In another optional implementation of this application's embodiments, when the examineable code block is a code block representing a conditional judgment, the execution result of the examineable code block includes the judgment result of the code block representing the conditional judgment. Based on each examineable code block and the execution result of each examineable code block, questions are generated for the examineable code blocks, including: Based on the examineable code block and the judgment result when the examineable code block is executed, a question is generated for the examineable code block.

[0071] Optionally, the judgment results when the examineable code block is executed, as well as the judgment results that differ from those when the examineable code block is executed, can be structured to obtain questions for the examineable code block.

[0072] exist Figure 1 Based on the example, after generating questions for each testable code block, the programming simulation questions can be displayed. The programming simulation questions include the question code and questions for each testable code block within the question code.

[0073] When the system front-end and back-end are not on the same electronic device, the back-end device can send all code blocks of the problem code, the examineable code blocks, the problem with the examineable code blocks, and the linearized code of the problem code to the front-end device. In other words, the back-end device can send the programming simulation problem and its corresponding linearized code to the front-end device. Upon receiving the programming simulation problem and its corresponding linearized code from the back-end device, the front-end device can directly control the display of the programming simulation problem based on the linearized code. Alternatively, the front-end device can save the linearized code and the programming simulation problem before controlling the display of the simulation problem based on the linearized code.

[0074] When the system front-end and back-end are on the same electronic device, the system back-end can store the programming simulation questions in its memory after generating them. Conversely, when the system front-end needs to control the display of the programming simulation questions, it can retrieve them from memory for display control.

[0075] Combination Figure 2 As shown, this application provides a method for displaying programming simulation questions, applied to the system front end. The method for displaying programming simulation questions may include the following steps: Step S201: Obtain programming simulation test questions; programming simulation test questions include test questions and questions for each testable code block in the test questions; testable code blocks are the code blocks in the test questions that generate actual operations.

[0076] Step S202: Display the programming simulation exercise.

[0077] In one optional implementation of this application, the code blocks in the question code and the questions for each examineable code block in the question code can be directly displayed on the display interface. Each code block is triggered sequentially according to the execution logic of the question code, and the triggered code block runs based on the linearized code corresponding to that code block. If the currently running code block is an examineable code block, the next code block of the currently running code block is only allowed to be triggered after the question is solved.

[0078] Optionally, if the answer data for the question is obtained, the next code block of the currently running code block can be triggered.

[0079] Alternatively, the next code block of the currently executed code block can only be triggered if the answer data for the question is obtained and matches the correct answer. Conversely, if the answer data differs from the correct answer, an initial message indicating an error in the answer data can be issued.

[0080] The initial notification can be in the form of text or sound. If the initial notification is in text form, it can be displayed on the system front end. If the initial notification is in sound form, it can be played.

[0081] In another optional implementation of this application's embodiments, the code blocks in the question code can be displayed on the display interface first. Then, each code block is triggered sequentially according to the execution logic of the question code, and the triggered code block runs based on the linearized code corresponding to that code block. If the currently running code block is an examineable code block, the question for the examineable code block is displayed, and after the question is answered, the next code block of the currently running code block can be triggered.

[0082] When a code block is triggered, the code block itself is not actually executed; instead, the linearized code corresponding to the code block is executed.

[0083] In one embodiment, each code block can be configured to be actively selected for triggering, allowing the user to choose the code block to be executed after displaying it. In this optional embodiment, triggering of each code block can be conditionally restricted. When any code block is triggered, if the previously triggered code block is the preceding code block in the execution logic of the question code, then that code block can be executed, and the triggered code blocks and / or their corresponding execution results will be sequentially displayed in a preset result recording area. If the previously triggered code block is not the preceding code block in the execution logic of the question code, a second prompt indicating an error in the code execution order can be provided.

[0084] The second notification can exist in the form of text or sound. If the second notification is in text form, it can be displayed on the system front end. If the second notification is in sound form, it can be played.

[0085] For example, the second prompt message may include, but is not limited to, one or more of the following: screen flashing, emitting a preset prompt sound, vibration, displaying error prompt messages.

[0086] In another embodiment, each code block can also be automatically triggered and executed sequentially according to the execution logic of the question code. However, if the currently triggered code block is a code block that requires a question, the question must be answered first before the next code block is automatically triggered. Similarly, in this embodiment, the triggered code blocks and their corresponding execution results can be displayed sequentially in a preset result recording area. Furthermore, in this embodiment, the currently triggered code blocks can be displayed differently, such as highlighted or flashing, allowing users to intuitively understand the execution order of each code block directly based on the displayed code blocks, rather than relying on changes in the result recording area. This helps users understand the operational logic of the problem code.

[0087] Optionally, the execution result corresponding to the code block may include variable name and / or variable value; displaying the execution result corresponding to each triggered code block includes: sequentially updating the preset variable table according to the execution result of each code block; sequentially displaying the updated variable table in the preset result record area, the variable table being used to store each variable in the question code and the value of each variable.

[0088] In one optional implementation of this application, for each code block, if the code block is used to add a variable, after the code block finishes running, the variable name of the newly added variable corresponding to the code block is stored in the variable table. If the code block is used to assign a value to a variable, after the code block finishes running, if the variable table includes the variable name in the code block, the corresponding value of the variable name in the variable table is updated using the variable value in the code block; or, if the variable table does not include the variable name in the code block, the variable name in the code block and the variable value corresponding to the variable name are stored in the variable table.

[0089] The programming simulation exercise display control system provided in this application allows users to see the programming simulation exercise, meaning all code blocks in the exercise code can be displayed. These displayed code blocks are triggered sequentially according to the exercise code's execution logic. This allows users to understand the sequential execution process of each code block by simply viewing the exercise code, thus gaining a more intuitive understanding of the code's execution order and its internal logic. Furthermore, the above implementation of this application displays the exercise when the currently triggered code block is a testable code block with an exercise. Since testable code blocks are the code blocks in the exercise code that generate actual operations, typically related to variables, and the exercise corresponding to a testable code block is generated based on the correct execution result of that block, timely displaying the exercise for user learning when a code block with an exercise is triggered allows for timely learning of difficult aspects related to variables and actual operations, reducing the difficulty for users in understanding the changes in variables and other operational-related aspects throughout the code's execution process. Therefore, the solution proposed in this application makes it easier for younger users to understand the internal logic of the program code and the changes in variables, which reduces the learning difficulty of the code for younger users and improves learning efficiency.

[0090] Example 2 This embodiment is based on Embodiment 1, and is grounded in... Figure 3 The code shown provides further examples of how to generate and control the display of programming simulation questions.

[0091] right Figure 3 Parsing the code shown in the figure yields the abstract syntax tree shown in Figures 4(a)-4(c).

[0092] In the abstract syntax trees shown in Figures 4(a)-4(c), `FunctionDecl` represents a function declaration, and `main` represents the function name. `FunctionDecl main` represents a function declaration node, and the name of this function is `main`. This corresponds to the code block "int main" in the problem code. `CompoundStmt` represents a compound statement. A compound statement represents combining multiple statements together to form an independent execution unit. Correspondingly, in... Figure 3 The code shown in the question includes compound statements such as Figure 5 The complete code shown.

[0093] The node “CompoundStmt” has five child nodes: the first child node DeclStmt, the second child node DeclStmt, the third child node DeclStmt, the fourth child node ForStmt, and the fifth child node ReturnStmt.

[0094] DeclStmt represents the statement declaration node. The first child node of the node "CompoundStmt" is "DeclStmt", which includes a child node "VarDecl a : int". Here, VarDecl represents a variable declaration, a represents the variable name, and int represents the integer type. In other words, "VarDecl a : int" declares an integer variable named 'a', corresponding to the code block "int a" in the problem's code.

[0095] The second child node of the node "CompoundStmt", DeclStmt, includes a child node "VarDecln : int = 0". "= 0" indicates that the initial value of variable n is 0. In other words, "VarDecl n : int = 0" declares an integer variable named n and assigns it the initial value 0, corresponding to the code block "int n = 0" in the problem's code. The third child node of the node "CompoundStmt", DeclStmt, includes a child node "VarDecl m: int = 0". "VarDecl m : int = 0" declares an integer variable named m and assigns it the initial value 0, corresponding to the code block "int m = 0" in the problem's code. The fourth child node of the node "CompoundStmt", "ForStmt", corresponds to the code block "for" in the problem's code. Furthermore, "ForStmt" includes a 4-branch structure.

[0096] The first branch of the "ForStmt" structure is used for variable initialization, corresponding to the code block "int i = 1" in the problem code. In this implementation, the root node of the first branch of the "ForStmt" structure is "DeclStmt", which represents the execution of variable declaration operation. The node "DeclStmt" includes a child node "VarDecl i : int = 1", which further declares an integer variable named i and assigns the initial value 1 to the integer variable i.

[0097] The second branch of "ForStmt" defines a conditional expression, corresponding to the code "i<= 5". In this embodiment, the root node of the second branch of "ForStmt" is "BinaryOperator<=", where BinaryOperator represents a binary operator, and <= is the specific operation type of the BinaryOperator node. "BinaryOperator<=" indicates that it is used to compare two values; if the value on the left is less than or equal to the value on the right, it returns true; otherwise, it returns false. The node "BinaryOperator<=" includes two child nodes, representing the value on the left and the value on the right of "BinaryOperator<=" respectively. In this embodiment, the two child nodes of the child node "BinaryOperator<=" are "DeclRefExpr i" and "IntegerLiteral 5".

[0098] DeclRefExpr is used to declare a variable that has already been declared and is used in the code. In this example, i is the name of the entity referenced by DeclRefExpr. Correspondingly, "DeclRefExpr i" is used to declare the variable i in the code. Thus, the value to the left of "BinaryOperator<=" is i.

[0099] IntegerLiteral is used to represent a fixed integer value. In this embodiment, 5 is the specific integer value represented by IntegerLiteral. Correspondingly, "IntegerLiteral 5" represents the integer value 5. Thus, the value on the right side of "BinaryOperator<=" is 5.

[0100] The third branch of "ForStmt" defines the iterative expression, corresponding to the code "i++". In this embodiment, the root node of the third branch of "ForStmt" is "UnaryOperator ++", where "UnaryOperator" represents a unary operator, "++" represents the specific operation type of "UnaryOperator", and "UnaryOperator ++" represents incrementing the operand by 1. "UnaryOperator ++" includes a child node "DeclRefExpr i". As mentioned above, "DeclRefExpr i" is used to declare the variable i used in the code. Correspondingly, i is the operand of "UnaryOperator ++". The fourth branch of "ForStmt" defines the statement to be executed when the condition of the conditional expression is true. In this embodiment, the fourth child node of "ForStmt" is "CompoundStmt".

[0101] In this embodiment, the root node "CompoundStmt" of the fourth branch structure of ForStmt includes multiple child nodes, which are, from top to bottom, the first child node "CallExpr operator>>", the second child node "IfStmt", the third child node "IfStmt", the fourth child node "CallExpr operator<<" and the fifth child node "CallExproperator<<".

[0102] In the node "CallExpr operator>>", CallExpr represents the function call expression, and operator>> is the specific target of CallExpr. operator>> represents the overloaded right shift operator. Correspondingly, "CallExproperator>>" represents calling the right shift operator>>, however, in the context of C++ I / O streams, the right shift operator>> can be used as an input operator. Therefore, "CallExpr operator>>" actually represents inputting data from the input stream and storing it in a variable.

[0103] The node "CallExpr operator>>" includes two child nodes: "DeclRefExpr cin" and "DeclRefExpr a". `cin` is a predefined global object in the C++ standard library, representing the standard input stream object. In other words, "DeclRefExpr cin" indicates that the standard input stream object `cin` is used in the code. "DeclRefExpr a" indicates that the variable `a` is used.

[0104] `cin` can be associated with user input. For example, the user input could be [6, 4, 7, 2, 8]. Correspondingly, the node "CallExpr operator>>" and its child nodes "DeclRefExpr cin" and "DeclRefExpr a" can sequentially read 6, 4, 7, 2, 8 into the variable `a`. The node "CallExpr operator>>", its child node "DeclRefExpr cin", and its child node "DeclRefExpr a" correspond to the code `cin>>a` in the problem.

[0105] The second child node of the fourth child node "CompoundStmt" of "ForStmt" includes three branch structures, corresponding to the condition judgment, the then branch, and the else branch.

[0106] The root node of the branch structure used for conditional evaluation is "BinaryOperator>", where "BinaryOperator" represents a binary operator, and ">" represents the specific operation type of "BinaryOperator". "BinaryOperator>" uses the ">" operator to connect two operands. The root node "BinaryOperator>" includes two child nodes, "DeclRefExpr a" and "IntegerLiteral 5", representing the values ​​on the left and right sides of the ">" operator. In other words, the node "BinaryOperator>" and its child nodes "DeclRefExpr a" and "IntegerLiteral 5" correspond to the condition a>5. The then branch defines the statement to be executed if the condition a>5 is true, and the else branch defines the statement to be executed if the condition a>5 is false.

[0107] The then - branch structure includes the node "CompoundStmt" and its child node "UnaryOperator ++", and the child node "DeclRefExpr n" of the node "UnaryOperator ++". The then - branch represents incrementing the value of the variable n by 1, corresponding to the code "n++" in the problem code. The else - branch structure includes the node "CompoundStmt" and its child node "UnaryOperator ++", and the child node "DeclRefExpr m" of the node "UnaryOperator ++". The else - branch represents incrementing the value of the variable m by 1, corresponding to the code "m++" in the problem code.

[0108] The third node "IfStmt" of the fourth child node "CompoundStmt" of "ForStmt" includes two branch structures. One branch structure represents conditional judgment, corresponding to the code block "a>5&&i<3" in the problem code, and the other branch structure represents the then - branch, corresponding to the code block "cout<<n<<endl" in the problem code. The then - branch is executed when the result of the conditional judgment expression "a>5&&i<3" is true.

[0109] In the "IfStmt" which is the third node of the fourth child node "CompoundStmt" of "ForStmt", the branch structure representing conditional judgment includes the node "BinaryOperator&&", the two child nodes of the node "BinaryOperator&&", which are "BinaryOperator>" and "BinaryOperator<" respectively, and the two child nodes of the node "BinaryOperator>" and the two child nodes of the node "BinaryOperator<".

[0110] Here, "&&" represents the logical AND operator. Correspondingly, the node "BinaryOperator&&" indicates that a logical AND operation is performed; the result is true only if both operands are true. The child node "BinaryOperator>" of node "BinaryOperator&&" indicates the use of the ">" operator. The two child nodes of node "BinaryOperator>" are "DeclRefExpr a" and "IntegerLiteral 5". The child node "DeclRefExpr a" indicates the use of variable 'a', which is the value on the left side of the ">" operator. "IntegerLiteral 5" represents the integer value 5. The integer value 5 is the value on the right side of the ">" operator. Therefore, the node "BinaryOperator>", its child node "DeclRefExpr a", and its child node "IntegerLiteral 5" correspond to the code block a>5 in the problem code.

[0111] The node "BinaryOperator&&" has a child node "BinaryOperator<" indicating the use of the operator "<". The child node "BinaryOperator<" includes two child nodes: "DeclRefExpr i" and "IntegerLiteral3". "DeclRefExpr i" indicates the use of variable i, which is the value on the left side of the operator "<". "IntegerLiteral 3" indicates the integer value 3, which is the value on the right side of the operator "<". Therefore, the node "BinaryOperator<", its child node "DeclRefExpr i", and its child node "IntegerLiteral 3" correspond to the problem code "i<3". The "then" branch structure in the third child node "IfStmt" of the fourth child node "CompoundStmt" of ForStmt includes the node "CompoundStmt", the child node "CallExpr operator<<" of the node "CompoundStmt", and the three child nodes of the node "CallExpr operator<<". The node “CallExpr operator<<” has three child nodes: “DeclRefExpr cout”, “DeclRefExpr i”, and “CallExpr endl”.

[0112] CallExpr represents a call to an operator. "operator<<" denotes the overloaded left shift operator and is the specific target of the CallExpr call. In the C++ iostream context, operator<< is overloaded as the stream insertion operator; correspondingly, "CallExpr operator<<" indicates that the value of the variable is inserted into the output stream for display.

[0113] `cout` is a predefined global object in the C++ standard library that represents the standard output stream object. Correspondingly, `DeclRefExpr cout` represents a reference to the standard output stream object; in other words, `DeclRefExpr cout` is used to provide delivery services. `DeclRefExpr i` represents a reference to the variable `i`, meaning that variable `i` is the content being delivered.

[0114] The current value of variable i can be output through the then branch structure in the third child node "IfStmt" of the fourth child node "CompoundStmt".

[0115] In the node "CallExpr endl", endl is a stream operator defined in the C++ standard library. The node "CallExpr endl" indicates a call to the stream operator endl. The stream operator endl is used to insert a newline character into the current output stream and to force-clear the output buffer, making all pending output content display immediately.

[0116] The fourth child node of “ForStmt”, “CompoundStmt”, has a fourth child node “CallExpr operator<<” that includes three child nodes: “DeclRefExpr cout”, “DeclRefExpr n”, and “CallExpr endl”. Thus, the node “CallExpr operator<<”, its child node “DeclRefExpr cout”, its child node “DeclRefExpr n”, and its child node “CallExpr endl” all correspond to the code cout<< in the problem. <n<<endl。

[0117] Similarly, "CallExpr operator<<" indicates sending the value of a variable to the output stream, the child node "DeclRefExpr cout" of "CallExproperator<<" represents the output stream, and the child node "DeclRefExpr n" of "CallExpr operator<<" indicates using the variable n. Thus, the value of variable n can be output through the nodes "CallExpr operator<<", the child node "DeclRefExpr cout" of "CallExproperator<<", and the child node "DeclRefExpr n" of "CallExpr operator<<". Likewise, "CallExpr endl" indicates inserting a newline character into the current output stream and forcibly clearing the output buffer, so that all content to be output is displayed immediately. In other words, after outputting the value of variable n, a newline character is output, and the output buffer is forcibly cleared, so that all values ​​of variable n are displayed immediately. The fourth child node of “ForStmt”, “CompoundStmt”, has a fifth child node “CallExpr operator<<” that includes three child nodes: “DeclRefExpr cout”, “DeclRefExpr m”, and “CallExpr endl”. Thus, the nodes “CallExproperator<<”, “DeclRefExpr cout” (a child node of “CallExpr operator<<”), “DeclRefExpr m” (a child node of “CallExproperator<<”), and “CallExpr endl” (a child node of “CallExpr operator<<”) all correspond to the code cout<< in the problem. <m<<endl。

[0118] Similarly, the value of variable m can be output through the node "CallExpr operator<<", its child node "DeclRefExpr cout", its child node "DeclRefExpr m", and its child node "CallExpr endl". After outputting the value of variable m, a newline character is output, and the output buffer is forcibly cleared so that all values ​​of variable m are displayed immediately.

[0119] The fifth child node of the node "CompoundStmt", "ReturnStmt", includes a child node "IntegerLiteral 0". "ReturnStmt" represents a return statement used to return a value after the main function finishes execution. "IntegerLiteral 0" indicates that the integer value 0 is used as the return value after the function finishes execution.

[0120] Based on the abstract syntax trees shown in Figures 4(a) to 4(c), the examineable code blocks in the problem code are identified.

[0121] For example, in the abstract syntax trees shown in Figures 6(a) and 6(b), the nodes in red are all leaf nodes.

[0122] For each leaf node in Figures 6(a) and 6(b), starting from that leaf node, backtracking layer by layer along the parent-child relationship path of the abstract syntax tree towards the root node. Upon first backtracking to an operation node, the code blocks corresponding to that operation node and all its child nodes in the problem code are identified as examineable code blocks. In the case of... Figure 7 The diagram shown illustrates the code for the question. Each code block highlighted in yellow is a code block that can be examined.

[0123] For each leaf node in Figures 6(a) and 6(b), the corresponding operation node is the node closest to and above that leaf node, marked with a green, yellow, or blue marker. Specifically, nodes marked in green are operator nodes, nodes marked in yellow are variable declaration nodes, and nodes marked in blue are return statement nodes.

[0124] For example, taking the leaf nodes “VarDecl a : int”, “VarDecl n : int = 0”, “VarDeclm: int = 0” or “VarDecl i : int = 1” as examples, the first operation node they backtrack to is “DeclStmt”.

[0125] Taking the leaf node “DeclRefExpr i” or “IntegerLiteral 5” as an example, the first backtracked operation node can be “BinaryOperator<=”.

[0126] Then, a linearized sequence of problem code can be generated based on the abstract syntax tree.

[0127] For the abstract syntax tree shown in Figures 4(a)-4(c), traverse each node in the abstract syntax tree and generate the code field corresponding to each node; for each branch structure in the abstract syntax tree, combine the code fields corresponding to each node in the branch structure according to the parent-child relationship between nodes and the node type of each node to obtain the code line corresponding to the branch structure; arrange the code lines corresponding to each branch structure according to the order of the branch structures in the abstract syntax tree to obtain the following... Figure 8 The linearized code shown.

[0128] An interpreter can be used to... Figure 8 Each line of code in the linearized code shown is executed line by line to obtain the execution result of each line. Since each line of code in the linearized code corresponds to a code block in the problem code, the execution result of each line of code in the linearized code is the correct running result of the corresponding code block when it is executed in the problem code. Since the examineable code block is the code block in the problem code that generates the actual operation, this method can also obtain the correct running result of the examineable code block when it is executed in the problem code.

[0129] Finally, questions targeting the examineable code block can be generated using the examineable code block and the execution results of the examineable code block when it is executed in the question code.

[0130] Then, all code blocks in the question code can be displayed on the system front end. At the same time, each code block can be triggered sequentially according to the execution logic of the question code, and the triggered code block runs based on the linearized code corresponding to that code block. If the currently running code block is an examineable code block, the question of the examineable code block will be displayed.

[0131] For example, based on such Figure 3 If the currently running code block is "i++", and code block "i++" is a testable code block, then the system will display questions for code block "i++". The system front-end display result can be as follows: Figure 9 As shown.

[0132] Once the answer data for the question is obtained, the next code block after the currently running code block will be executed automatically.

[0133] Furthermore, the execution results of each code block after being triggered can be displayed sequentially in the preset result recording area.

[0134] In some embodiments, the execution result of each code block is typically related to variables. Therefore, the variables after each code block is triggered and executed can be displayed sequentially in a preset result recording area. For example, the display result on the system front end can be as follows: Figure 10 As shown.

[0135] By using the variable declaration node "DeclStmt" in the abstract syntax tree shown in Figures 4(a)-4(c), it can be determined that in such a way... Figure 3 The code shown includes variables a, n, m, and i.

[0136] A variable table can be constructed using variables a, n, m, and i. The variable table can include two columns and four rows. The rows in the first column are used to store the variable names a, n, m, and i, and the rows in the second column are used to store the values ​​of each variable name a, n, m, and i.

[0137] For example, when the code block "int a" is triggered, "int a" runs based on the linearized code corresponding to that code block, and the execution result is: defining variable a. This execution result, i.e., recording variable a, can be recorded in a preset result recording interval. The recorded result can be shown in Figure 11(a).

[0138] When the code block "int n = 0" is triggered, the execution result is: define variable n and assign an initial value of 0 to variable n. The variable table shown in Figure 11(a) can be updated using variable n and the initial value of variable n0 to obtain the variable table shown in Figure 11(b).

[0139] Similarly, for each code block in the problem code shown in Figure 4, when the code block is triggered to run, the variable table of the result record interval can be updated according to the execution order using the execution results.

[0140] Example 3 Based on the same inventive concept, this application also provides a device for generating programming simulation problems. Please refer to... Figure 12 As shown, Figure 12 It shows the use of Figure 1 The illustrated method generates a programming simulation exercise generation device 200. It should be understood that the specific functions of device 200 are described above; to avoid repetition, detailed descriptions are omitted here. Device 200 includes at least one software function module that can be stored in memory or embedded in the operating system of device 100 in the form of software or firmware. Specifically: Combination Figure 12 As shown in the figure, this application provides a programming simulation exercise generation device 200, including: a first acquisition module 120, a first generation module 121, a code linearization module 123, a determination module 124, and a second generation module 125.

[0141] The first acquisition module 120 is configured to acquire the question code; the question code includes at least two code blocks. The first generation module 121 is configured to generate an abstract syntax tree (AST) of the question code. The code linearization module 123 is configured to linearize the question code based on the AST, obtaining linearized code; where each line of code in the linearized code corresponds to a code block in the question code. The determination module 124 is configured to determine the examineable code blocks in the question code based on the AST; the examineable code blocks are the code blocks in the question code that generate actual operations. The second generation module 125 is configured to generate questions for each examineable code block based on each examineable code block and the correct execution results when each examineable code block is executed.

[0142] In one feasible embodiment of this application, the determining module 124 is specifically configured as follows: Determine the leaf nodes of the abstract syntax tree (AST). A leaf node is a node in the AST that has no child nodes. For each leaf node, starting from that leaf node, backtrack layer by layer along the parent-child relationship path of the AST towards the root node. When the backtracking reaches an operation node for the first time, determine the code block in the problem code corresponding to that operation node and all its child nodes as the testable code block. An operation node represents the node used to perform a specific operation.

[0143] In one feasible implementation of this application, the code linearization module 123 is specifically configured to: traverse each node in the abstract syntax tree and generate code fields corresponding to each node; for each branch structure in the abstract syntax tree, combine the code fields corresponding to each node in the branch structure according to the parent-child relationship between each node and the node type of each node to obtain the code line corresponding to the branch structure; arrange the code lines corresponding to each branch structure according to the sequential position relationship of each branch structure in the abstract syntax tree to obtain linearized code.

[0144] In one feasible embodiment of this application, the second generation module 125 is specifically configured to: generate questions for at least some of the target examineable code blocks among all examineable code blocks; the questions for each target examineable code block are generated based on the execution result of each target examineable code block when it is executed and the corresponding error execution result of each target examineable code block; the error execution result corresponding to each target examineable code block is different from the execution result of each target examineable code block when it is executed.

[0145] In one feasible embodiment of this application, the second generation module 125 is specifically configured to: generate questions for the examineable code block group based on the execution results of each examineable code block in the examineable code block group when it is executed; wherein, the examineable code block group includes at least two adjacent examineable code blocks that have an interaction relationship.

[0146] In one feasible implementation of this application, the question code includes variables, and the correct execution result of each examineable code block when executed in the question code includes the variable value corresponding to the execution of each examineable code block. The second generation module 125 is specifically configured to: determine the variables of the question code based on the abstract syntax tree; and for any examineable code block, generate a question for that examineable code block based on the examineable code block and the variable value corresponding to the execution of the examineable code block.

[0147] In one feasible implementation of this application, the second generation module 125 is specifically configured to: determine variable declaration nodes in the abstract syntax tree; and extract variables from the attribute information of the variable declaration nodes.

[0148] In one feasible embodiment of this application, when the examineable code block is a code block representing a conditional judgment, the correct execution result when the examineable code block is executed includes the judgment result of the code block representing the conditional judgment. The second generation module 125 is specifically configured to: generate a question for the examineable code block based on the examineable code block and the judgment result when the examineable code block is executed.

[0149] Based on the same inventive concept, this application also provides a display control device for a programming simulation exercise. Please refer to... Figure 13 As shown, Figure 13 It shows the use of Figure 2 The illustrated method generates a programming simulation exercise using a device 300. It should be understood that the specific functions of device 300 are described above; to avoid repetition, detailed descriptions are omitted here. Device 300 includes at least one software function module that can be stored in memory or embedded in the operating system of device 300 in the form of software or firmware. Specifically: Combination Figure 13 As shown in the figure, this application embodiment provides a display control device 300 for programming simulation exercises, including: a second acquisition module 301, a display module 302, a trigger operation module 303, and a second display module 304. Wherein: The second acquisition module 301 is configured to acquire programming simulation questions; the programming simulation questions include question code and questions targeting each testable code block in the question code; the testable code block is the code block in the question code that generates the actual operation. The display module 302 is configured to display programming mode running questions.

[0150] The display module 302 is configured to display all code blocks of the question code; trigger each code block sequentially according to the execution logic of the question code, and the triggered code block runs based on the linearized code corresponding to the code block; the linearized code is a code sequence obtained by linearizing the question code based on the abstract syntax tree of the question code; if the currently running code block is an examineable code block, display the question of the examineable code block, and after the question is solved, allow triggering the next code block of the currently running code block.

[0151] In one feasible implementation of this application, the display module 302 may be specifically configured to acquire answer data for a question; if the answer data is different from the correct answer corresponding to the question, output a first prompt message, the first prompt message being used to indicate that the answer data is incorrect; or, if the answer data is the same as the correct answer corresponding to the question, allow triggering the next code block of the currently running code block.

[0152] In one feasible embodiment of this application, the display module 302 can be specifically configured to respond to the triggering operation of any code block. If the previously triggered code block is the code block preceding the code block in the running logic of the question code, then the code block is executed and the triggered code blocks and their corresponding execution results are displayed sequentially in a preset result recording area. If the previously triggered code block is not the code block preceding the code block in the running logic of the question code, then a second prompt message indicating an error in the code execution order is fed back.

[0153] In one feasible embodiment of this application, the display module 302 can be specifically configured to sequentially update a preset variable table according to the execution results of each code block; and sequentially display the updated variable table in a preset result record area. The variable table is used to store each variable in the question code and the value of each variable.

[0154] It should be understood that, for the sake of brevity, some of the content described in Embodiment 1 will not be repeated in this embodiment.

[0155] Example 4: Based on the same inventive concept, this embodiment provides an electronic device, see [link to relevant documentation]. Figure 14 As shown, it includes a processor 410 and a memory 420. Wherein: The processor 410 is used to execute one or more programs stored in the memory 420 to implement the above-described method for generating and / or controlling the display of programming simulation problems.

[0156] It is understandable that the processor 410 can be a processor core or processor chip, or other circuitry capable of program configuration and execution. The memory 420 can be RAM (Random Access Memory), ROM (Read-Only Memory), flash memory, etc., but this is not a limitation.

[0157] It's understandable. Figure 14 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 14 The more or fewer components shown, or having the same Figure 14 Different configurations are shown. For example, it may also have an internal communication bus for communication between the processor 410 and the memory 420; or it may have an external communication interface, such as a USB (Universal Serial Bus) interface, a CAN (Controller Area Network) bus interface, etc.; or it may have an information display component such as a display screen, but this is not a limitation.

[0158] Based on the same inventive concept, this embodiment also provides a computer-readable storage medium, such as a floppy disk, optical disk, hard disk, flash memory, USB flash drive, SD (Secure Digital Memory Card), MMC (Multimedia Card), etc., in which one or more programs implementing the above steps are stored. These one or more programs can be executed by one or more processors to implement the above-described method for generating and / or controlling the display of the programming simulation exercise. Further details will not be elaborated here.

[0159] Based on the same inventive concept, this embodiment also provides a computer program product, which includes a computer program that, when executed by a processor, implements the above-described method for generating and / or displaying simulation problems. Further details will not be elaborated here.

[0160] For example, a computer program product may be an installation package or a program package.

[0161] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0162] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0163] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0164] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.

[0165] In this article, "multiple" refers to two or more.

[0166] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A method for generating programming simulation problems, characterized in that, include: Get the question code; The problem code includes at least two code blocks; Generate an abstract syntax tree for the code of the given problem; The problem code is linearized based on the abstract syntax tree to obtain the linearized code of the problem code; wherein each line of code in the linearized code corresponds to a code block in the problem code; Based on the abstract syntax tree, examineable code blocks are identified in the problem code; the examineable code blocks are the code blocks in the problem code that generate actual operations. Based on each of the examineable code blocks and the execution results of each of the examineable code blocks, questions are generated for each of the examineable code blocks.

2. The generation method according to claim 1, characterized in that, Based on the abstract syntax tree, the examineable code blocks in the problem code are identified, including: Determine the leaf nodes of the abstract syntax tree, wherein the leaf nodes are nodes in the abstract syntax tree that have no child nodes; For each leaf node, starting from that leaf node, backtracking layer by layer along the parent-child relationship path of the abstract syntax tree towards the root node. When the backtracking first reaches an operation node, the operation node and all its child nodes are identified as the code blocks in the problem code that can be examined. The operation node represents the node used to perform the specific operation.

3. The generation method according to claim 1, characterized in that, Based on each of the examineable code blocks and the execution results of each of the examineable code blocks, questions are generated for each of the examineable code blocks, including: For at least a portion of the target examineable code blocks in all examineable code blocks, generate questions for each of the target examineable code blocks; The questions for each of the target examineable code blocks are generated based on the execution results of each target examineable code block and the corresponding error execution results; the error execution results corresponding to each target examineable code block are different from the execution results of each target examineable code block.

4. A method for displaying and controlling a programming simulation exercise, characterized in that, include: Obtain programming simulation test questions; the programming simulation test questions include test questions and questions for each testable code block of the test questions; The examineable code block is the code block in the problem code that generates the actual operation; The programming simulation exercise is displayed.

5. A display control system for programming simulation exercises, characterized in that, This includes the system front-end and system back-end; The system backend is configured to acquire the question code; the question code includes at least two code blocks; and generate an abstract syntax tree for the question code. The question code is linearized based on the abstract syntax tree to obtain linearized code; each line of code in the linearized code corresponds to a code block in the question code; examineable code blocks in the question code are determined based on the abstract syntax tree; the examineable code blocks are the code blocks in the question code that generate actual operations; based on each examineable code block and the execution result when each examineable code block is executed, a question is generated for the examineable code block; The system front-end is configured to acquire and display the programming simulation test questions; the programming simulation test questions include the test question code and questions for each testable code block of the test question code.

6. A device for generating programming simulation problems, characterized in that, include: The first acquisition module is configured to acquire the question code; The problem code includes at least two code blocks; The first generation module is configured to generate an abstract syntax tree for the code of the problem; The code linearization module is configured to linearize the problem code based on the abstract syntax tree to obtain linearized code of the problem code; wherein each line of code in the linearized code corresponds to a code block in the problem code; The determination module is configured to identify examineable code blocks in the problem code based on an abstract syntax tree; the examineable code blocks are the code blocks in the problem code that generate actual operations. The second generation module is configured to generate questions for each of the examineable code blocks based on each of the examineable code blocks and the execution results of each of the examineable code blocks.

7. A display control device for a programming simulation exercise, characterized in that, include: The second acquisition module is configured to acquire programming simulation exercise questions; the programming simulation exercise questions include question code and questions targeting each examineable code block in the question code; the examineable code block is the code block in the question code that generates the actual operation; The display module is configured to display the programming simulation exercise.

8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing computer-executable instructions that can be executed by the processor, the processor executing the computer-executable instructions to implement the method for generating programming simulation questions according to any one of claims 1 to 3, or the method for displaying programming simulation questions according to claim 4.

9. A storage medium, characterized in that, The storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method for generating programming simulation problems according to any one of claims 1 to 3, or the method for displaying programming simulation problems according to claim 4.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method for generating programming simulation questions according to any one of claims 1 to 3, or the method for displaying programming simulation questions according to claim 4.