Code quality optimization information generation method and device for teaching scene application, equipment and medium
By constructing an educational code semantic feature library and using pre-trained models to process student code, the problems of low efficiency and poor adaptability in code quality assessment and optimization in teaching scenarios are solved. This achieves accurate code quality assessment and differentiated optimization suggestions, improving the consistency and accuracy of the assessment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-03-13
AI Technical Summary
In teaching settings, existing code quality assessment and optimization methods suffer from problems such as low teacher assessment efficiency, poor compatibility with automated tools, and a lack of differentiated assessment strategies, resulting in inconsistent and inaccurate assessment results.
We construct a semantic feature library for educational codes. By identifying teaching intent markers, example code patterns, and education industry-specific annotation standards in textbook codes, we use a pre-trained model to process student codes, obtain key features, and generate quality assessment information based on similarity and annotation standards, providing targeted optimization suggestions.
It enables precise evaluation and optimization of code quality in teaching scenarios, generates differentiated and progressive optimization suggestions, improves the efficiency and accuracy of evaluation, and meets the learning needs of different students.
Smart Images

Figure CN121658348A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of computer software engineering and artificial intelligence technology, specifically to a method, apparatus, device, and medium for generating code quality optimization information for teaching scenarios. Background Technology
[0002] In today's era of rapidly developing digital education, programming instruction is playing an increasingly important role in all levels and types of education. Students develop logical thinking and problem-solving skills by writing code. However, code quality assessment and optimization currently face numerous challenges in teaching settings.
[0003] Traditional code quality assessment methods mostly rely on teachers manually checking student code. This method not only consumes a significant amount of teachers' time and energy, but the assessment results are also easily influenced by teachers' personal subjective factors. Different teachers may have different standards for judging code quality, leading to a lack of consistency and objectivity in the assessment results. For example, when grading dozens of coding assignments for a class, teachers may use different criteria for judging code at different times due to factors such as fatigue.
[0004] While existing automated code analysis tools can detect syntax errors to some extent, their semantic understanding of code is limited. Most of these tools are developed based on general programming scenarios and do not fully consider the specificities of teaching scenarios. For example, general code analysis tools cannot recognize the teaching intent markers specific to textbook code, nor can they properly understand the commenting conventions specific to the education industry. In actual teaching, teachers may add specific comments to code to guide students in understanding the code logic, but general tools cannot associate these comments with teaching objectives, thus failing to provide effective code quality assessments and optimization suggestions tailored to teaching scenarios.
[0005] Furthermore, general-purpose code analysis tools lack differentiated assessment strategies tailored to teaching scenarios. Teaching code and student assignment code have different characteristics and requirements. Teaching code is typically designed to demonstrate specific programming concepts or techniques, emphasizing clarity and exemplification; while student assignment code focuses more on assessing students' mastery of knowledge points, allowing for some errors and imperfections. Existing assessment tools do not develop corresponding assessment standards and tiered suggestions to address these differences, often using a uniform standard to evaluate all code. This results in assessment results that fail to accurately reflect the actual quality of code in teaching scenarios and cannot meet the needs of diverse students.
[0006] In summary, existing code evaluation and optimization methods suffer from problems such as low teacher evaluation efficiency, poor adaptability of automated tools to teaching scenarios, and lack of differentiated evaluation strategies in teaching settings. There is an urgent need for a code quality evaluation and optimization suggestion generation method specifically designed for teaching applications to solve these problems. Summary of the Invention
[0007] In view of the above problems, this disclosure provides a method, apparatus, device and medium for generating code quality optimization information for teaching scenarios, which can at least partially solve the above technical problems.
[0008] According to a first aspect of the present disclosure, a method for generating code quality optimization information for teaching scenarios is provided. The method includes: identifying teaching intent markers, example code patterns, and education industry-specific annotation standards in textbook code; constructing a semantic feature library based on the teaching intent markers, example code patterns, and education industry-specific annotation standards; processing student code using a pre-trained model to obtain key features in the student code; matching the key features with the semantic feature library to obtain quality assessment information; determining the error severity level of the student code based on the quality assessment information; and generating code quality optimization information for the student based on the quality assessment information, the error severity level, and the student's ability level.
[0009] According to embodiments of this disclosure, identifying instructional intent markers, example code patterns, and education-specific annotation standards in textbook code includes: scanning the textbook code line by line based on text matching to identify instructional intent markers in the textbook code; classifying the textbook code according to different programming concepts and knowledge points to obtain different types of example code; obtaining the overall structure and key structural features of the example code, and determining the typical structural pattern of the programming concept to which the example code belongs based on the overall structure and key structural features, as the example code pattern; and analyzing education-specific annotation standards from multiple aspects such as the level of annotation detail, the correspondence with code logic, and the hierarchical structure.
[0010] According to embodiments of this disclosure, text matching is used to scan textbook code line by line, including: scanning the textbook code line by line based on a predefined regular expression pattern that matches the format of the teaching intent marker, and identifying the teaching intent marker in the textbook code. The overall structure includes the positions of the initialization part, the loop condition part, and the loop body update part, and the logical relationship between the three; key structural features include the declaration method of the loop variable, the judgment logic of the loop condition, and the operation on the loop variable in the loop body. The annotation specifications unique to the education industry are analyzed from multiple aspects such as the level of detail of the comments, the correspondence with the code logic, and the hierarchical structure, including: calculating the ratio of the number of comment lines to the total number of lines of code in the textbook code; analyzing the semantic relationship between the comment content in the textbook code and adjacent code segments; obtaining the hierarchical structure of the comments in the textbook code; and organizing the ratio, semantic relationship, and hierarchical structure to obtain the annotation specifications.
[0011] According to embodiments of this disclosure, a pre-trained model is used to process student code to obtain key features in the student code, including: performing deep semantic encoding on the student code to generate a high-dimensional semantic representation vector; extracting the complexity, functional completeness, and logical consistency of the student code from the semantic representation vector as candidate features; determining a first weight for each candidate feature based on teaching objectives and code evaluation priorities; and performing weighted fusion of each candidate feature based on the first weight to obtain key features.
[0012] According to embodiments of this disclosure, key features are matched with a semantic feature library to obtain quality assessment information, including: calculating a first similarity between the key features and the teaching intention marker, and a second similarity between the key features and the example code pattern; evaluating the annotations in the student code based on education industry-specific annotation specifications to obtain annotation index scores; and performing a weighted summation of the first similarity, the second similarity, and the annotation index scores to obtain quality assessment information.
[0013] According to embodiments of this disclosure, error severity levels include minor errors, moderate errors, and severe errors, and student ability levels include beginner, intermediate, and advanced students. Based on quality assessment information, error severity levels, and student ability levels, code quality assessment information is generated for each student, including: generating different levels of code quality optimization information for different error severity levels in student code for students of different ability levels.
[0014] According to embodiments of this disclosure, the method further includes: displaying real-time quality assessment information and code quality optimization information in a progressive interface.
[0015] A second aspect of this disclosure provides a code quality optimization information generation device for teaching scenarios, the method comprising: an identification module for identifying teaching intent markers, example code patterns, and education industry-specific annotation standards in textbook code, and constructing a semantic feature library based on the teaching intent markers, example code patterns, and education industry-specific annotation standards; a processing module for processing student code using a pre-trained model to obtain key features in the student code; a matching module for matching the key features with the semantic feature library to obtain quality assessment information; a determination module for determining the error severity level of the student code based on the quality assessment information; and a generation module for generating code quality optimization information for the student based on the quality assessment information, the error severity level, and the student's ability level.
[0016] A third aspect of this disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.
[0017] A fourth aspect of this disclosure also provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implement the steps of the above-described method.
[0018] A fifth aspect of this disclosure also provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method.
[0019] The code quality optimization information generation method for teaching scenarios according to the embodiments of this disclosure can achieve the purpose of accurately evaluating code quality and generating targeted optimization suggestions by constructing an educational code semantic feature library and realizing quantitative evaluation based on a large model.
[0020] By locating code issues from multiple dimensions and performing weighted matching evaluation, the system can accurately pinpoint code problems and generate precise optimization information.
[0021] The information generation process is optimized by introducing a hierarchical suggestion system. Based on student ability assessment and error severity assessment, the system identifies student code problems from multiple dimensions. Combining the learning needs of students at different levels and the difficulty of error repair, it generates differentiated and progressive optimization suggestions to achieve more precise teaching guidance. Attached Figure Description
[0022] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0023] Figure 1 The illustration schematically depicts an application scenario diagram of a code quality optimization information generation method, apparatus, device, medium, and program product for teaching scenarios according to embodiments of the present disclosure;
[0024] Figure 2 A flowchart illustrating a method for generating code quality optimization information for teaching scenarios according to an embodiment of the present disclosure is shown.
[0025] Figure 3 This schematic diagram illustrates a structural block diagram of a code quality optimization information generation device for teaching scenarios according to an embodiment of the present disclosure.
[0026] Figure 4 A block diagram of an electronic device suitable for implementing a code quality optimization information generation method for teaching scenarios, according to an embodiment of the present disclosure, is illustrated. Detailed Implementation
[0027] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0028] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0029] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0030] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0031] In the technical solution disclosed herein, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, and displayed data) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with relevant laws, regulations, and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.
[0032] In scenarios involving automated decision-making using personal information, the methods, devices, and systems provided in this disclosure all offer users corresponding entry points for choosing to agree to or reject the automated decision-making results. If the user chooses to reject, the process proceeds to the expert decision-making stage. Here, "automated decision-making" refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests, or economic, health, and credit status through computer programs, and then making a decision. Here, "expert decision-making" refers to the activity of making decisions by personnel who specialize in a particular field, possess specialized experience, knowledge, and skills, and have reached a certain level of professional expertise.
[0033] Figure 1 The illustration schematically depicts an application scenario diagram of a code quality optimization information generation method, apparatus, device, medium, and program product for teaching scenarios according to embodiments of the present disclosure.
[0034] like Figure 1 As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, a server 105, and a database 106. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, the server 105, and the database 106. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0035] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 and the database 106 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as office applications, shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platforms, financial consumer applications, etc. (this is just an example). The database 106 can store a preset knowledge base.
[0036] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0037] Server 105 can be a server that provides various services, such as a backend management server that supports and responds to code quality assessment and optimization requests sent by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can send the generated code quality optimization information to the first terminal device 101, the second terminal device 102, and the third terminal device 103 for display.
[0038] It should be noted that the code quality optimization information generation method for teaching scenarios provided in this embodiment can generally be executed by server 105. Correspondingly, the code quality optimization information generation device for teaching scenarios provided in this embodiment can generally be located in server 105. The code quality optimization information generation method for teaching scenarios provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the code quality optimization information generation device for teaching scenarios provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0039] It should be understood that Figure 1 The number of terminal devices, networks, servers, and databases shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, servers, and databases can be included.
[0040] The following will be based on Figure 1 The described scene, through Figure 2 The method for generating code quality optimization information for teaching scenarios, as described in the disclosed embodiments, is described in detail.
[0041] Figure 2 The flowchart illustrates a method for generating code quality optimization information for teaching scenarios according to an embodiment of the present disclosure.
[0042] like Figure 2As shown, the code quality optimization information generation method for teaching scenario applications in this embodiment includes operations S210 to S250, and this code quality optimization information generation method for teaching scenario applications can be executed by server 105.
[0043] In operation S210, the teaching intent markers, example code patterns, and education industry-specific annotation specifications in the textbook code are identified, and a semantic feature library is constructed based on the teaching intent markers, example code patterns, and education industry-specific annotation specifications.
[0044] When operating the S220, a pre-trained model is used to process the student code and obtain key features from the student code.
[0045] In operation S230, key features are matched with the semantic feature library to obtain quality assessment information.
[0046] In operation S240, the severity level of errors in student codes is determined based on quality assessment information.
[0047] When operating S250, code quality optimization information is generated for students based on quality assessment information, error severity level, and student ability level.
[0048] In some embodiments, textbook codes need to be collected and preprocessed before identifying instructional intent markers, example code patterns, and education-specific annotation conventions in the textbook codes.
[0049] Code Data Collection: This involves collecting extensive code data from various sources within teaching scenarios, covering different programming languages such as Python, Java, and C++. This can include example code from various textbooks, which is typically carefully written to illustrate specific programming concepts or techniques; code submitted by students in daily assignments, lab projects, and course exams; and typical code written by teachers for demonstration and explanation during instruction. The collected data should be as comprehensive as possible, covering different difficulty levels and programming topics to ensure the comprehensiveness and accuracy of subsequent analysis and evaluation.
[0050] Code data cleaning: A thorough cleaning process is performed on the collected code data. First, invalid characters resulting from input errors, such as garbled text and unrecognizable special symbols, are removed. Simultaneously, redundant spaces and tabs are processed to standardize whitespace formatting and ensure a clear and readable code structure. For example, for Python code, indentation is standardized, using a consistent 4-space indentation to avoid inconsistent indentation or mixing of spaces and tabs. Furthermore, syntax errors are checked and corrected, such as incomplete statements and incorrect punctuation, ensuring basic syntactic correctness and laying a solid foundation for subsequent tokenization and analysis.
[0051] Word segmentation: Based on the syntax rules of different programming languages, appropriate professional word segmentation tools are selected to perform word segmentation on the cleaned code. For example, for Java code, tools can be used to accurately decompose the code into basic tokens, such as keywords, identifiers, operators, and constants, according to the lexical rules of the Java language. For Python code, tools can be used for word segmentation. The purpose of word segmentation is to transform the code into a sequence of basic units that are easy for computers to process, facilitating subsequent in-depth analysis of the code structure and semantics.
[0052] In some embodiments, identifying instructional intent markers, example code patterns, and education-specific annotation standards in textbook code includes: scanning the textbook code line by line based on text matching to identify instructional intent markers in the textbook code; classifying the textbook code according to different programming concepts and knowledge points to obtain different types of example code; obtaining the overall structure and key structural features of the example code, and determining the typical structural pattern of the programming concept to which the example code belongs based on the overall structure and key structural features, as the example code pattern; and analyzing education-specific annotation standards from multiple aspects such as the level of annotation detail, the correspondence with code logic, and the hierarchical structure.
[0053] Furthermore, the textbook code is scanned line by line based on text matching, including: scanning the textbook code line by line based on a predefined regular expression pattern that matches the teaching intent mark format, and identifying the teaching intent mark in the textbook code.
[0054] The overall structure includes the location of the initialization part, the loop condition part, and the loop body update part, as well as the logical relationship between the three. Key structural features include the declaration method of the loop variable, the judgment logic of the loop condition, and the operation on the loop variable in the loop body.
[0055] This study analyzes the unique commenting standards in the education industry from multiple aspects, including the level of detail of comments, their correspondence with code logic, and hierarchical structure. This includes: calculating the ratio of comment lines to total code lines in the textbook code; analyzing the semantic relationships between comment content and adjacent code segments in the textbook code; obtaining the hierarchical structure of comments in the textbook code; and organizing the ratio, semantic relationships, and hierarchical structure to obtain the commenting standards.
[0056] For example, the extraction of instructional intent markers involves using text matching techniques such as regular expressions to scan the textbook code line by line. A predefined regular expression pattern, such as " / / \[.*?\]", is used to identify instructional intent annotation markers in the code. When an annotation matching the pattern is identified, its content is extracted. Subsequently, Named Entity Recognition (NER) technology from Natural Language Processing is used to analyze the extracted marker content and determine the specific instructional knowledge point associated with it. For example, for a marker like " / / [Instructional Objective: Implementation of Bubble Sort Algorithm]", NER technology can identify the specific knowledge point as "bubble sort algorithm". The identified knowledge points are mapped to the corresponding code snippets and stored in an educational code semantic feature library so that when evaluating student code later, it can be determined whether the student's code is associated with a specific instructional intent.
[0057] For example, the summary of example code patterns involves systematically categorizing a large number of collected example codes according to different programming concepts and knowledge points, such as loop structures, function definitions and calls, data structure operations, and algorithm implementations. For each category, pattern recognition algorithms are used for in-depth analysis. Taking the analysis of the "for loop" example code as an example, the overall structure of the code is first analyzed to determine the location and logical relationship of the initialization part, the loop condition part, and the loop body update part. Next, key structural features are extracted, such as the declaration method of the loop variable, the judgment logic of the loop condition, and the operations on the loop variable in the loop body. Through the analysis and comparison of multiple similar example codes, typical structural patterns of this type of programming concept are summarized. These summarized patterns and their corresponding teaching knowledge points are then marked and stored in the educational code semantic feature library as a reference for evaluating whether students' code structures meet teaching requirements.
[0058] For example, the comment standardization analysis involves a detailed analysis of comment standards specific to the education industry from multiple dimensions. First, the ratio of comment lines to total code lines is calculated to measure the level of detail in the comments. Generally, for explanations of basic programming knowledge, the comment ratio may be relatively high to help students better understand the code logic. Second, semantic analysis techniques are used to analyze the semantic relationships between comment content and adjacent code segments to determine whether the comments accurately explain the code's function and logic. For example, it checks whether the comments clearly explain the input and output of the code segment, the role of key variables, and the execution steps of the algorithm. Furthermore, the hierarchical structure of the comments is observed to determine whether there are high-level comments on the overall code function, mid-level comments on key code blocks, and low-level comments on individual lines of code, ensuring that the comments assist students in understanding the code from different levels. These analysis results on comment standards are then compiled and stored in an educational code semantic feature library for evaluating the rationality and standardization of student code comments.
[0059] In some embodiments, a pre-trained model is used to process student code to obtain key features in the student code, including: performing deep semantic encoding on the student code to generate a high-dimensional semantic representation vector; extracting the complexity, functional completeness, and logical consistency of the student code from the semantic representation vector as candidate features; determining the first weight of each candidate feature based on teaching objectives and code evaluation priorities; and performing weighted fusion of each candidate feature based on the first weight to obtain key features.
[0060] For example, a large model suitable for code understanding, such as a pre-trained model based on the Transformer architecture, is selected, and the pre-processed student code is input into it. The large model performs deep semantic encoding on the student code, generating a high-dimensional semantic representation vector. During the encoding process, the large model uses a self-attention mechanism to fully capture the semantic dependencies between different terms in the code, constructing a semantic graph of the code and comprehensively understanding its semantics. For instance, when processing a complex nested function call code, the large model can clearly identify parameter passing, return value handling, and the relationship between the internal logic of functions and external calls.
[0061] Key features are extracted from the semantic representation vectors generated by the large model. These features may include code complexity metrics (such as cyclomatic complexity, deep nesting levels, etc.), functionality integrity features (derived through comparison with common functionality implementation patterns), and logical consistency features (analyzing whether there are contradictions or unreasonable jumps in the code logic). For each feature, its weight is determined using methods such as the Analytic Hierarchy Process (AHP) based on the teaching objectives and code evaluation focus. For example, for code evaluation aimed at cultivating students' basic programming logic, the first weight of the logical consistency feature may be relatively high; while for teaching scenarios that emphasize functionality implementation, the first weight of the functionality integrity feature is higher.
[0062] In some embodiments, key features are matched with a semantic feature library to obtain quality assessment information, including: calculating a first similarity between the key features and the teaching intention markers, and a second similarity between the key features and the example code pattern; evaluating the annotations in the student code based on education industry-specific annotation specifications to obtain annotation index scores; and performing a weighted summation of the first similarity, the second similarity, and the annotation index scores to obtain quality assessment information.
[0063] For example, the extracted student code features are matched with corresponding features in the educational code semantic feature library. For instructional intent markers, the semantic similarity score between the student code and related code segments in the semantic feature library is calculated, using methods such as cosine similarity. For example code patterns, the similarity between the student code structure and example patterns in the semantic feature library is compared, and a similarity score is obtained through a structure matching algorithm. For annotation standards, various standardization indicators of the student code annotations are scored based on the annotation analysis results in the semantic feature library. Then, combining the weights of each feature, a weighted summation is used to calculate the overall matching score between the student code and the semantic feature library, thus quantifying the evaluation results.
[0064] For example, if the similarity score of instructional intent markers accounts for 30% of the total score, the similarity score of example code patterns accounts for 40%, and the annotation standardization score accounts for 30%, then:
[0065] Final score = Teaching intention mark similarity score × 0.3 + Example code pattern similarity score × 0.4 + Commenting standardization score × 0.3.
[0066] In some embodiments, based on students' historical assignment completion, exam scores, and current assessment results, a clustering algorithm is used to categorize students' abilities into three levels: beginner, intermediate, and advanced. Simultaneously, issues such as deviation from teaching intent, structural inconsistencies, and non-standard annotations are scored based on three aspects: the scope of error impact, the difficulty of fixing it, and the degree of obstruction to achieving teaching objectives. Error severity is then categorized into three levels: minor, moderate, and severe. That is, error severity levels include minor, moderate, and severe errors, and student ability levels include beginner, intermediate, and advanced students.
[0067] Based on quality assessment information, error severity levels, and students' ability levels, code quality assessment information is generated for students, including: generating different levels of code quality optimization information based on different error severity levels in student code for students of different ability levels.
[0068] For example, based on the quantitative assessment results, student ability level, and error severity level, the scores of each part are analyzed in depth to generate targeted code optimization information (hereinafter referred to as suggestions) for student code.
[0069] Recommendations for differentiating students at the beginner level:
[0070] Minor errors: Provide links to review basic concepts (such as corresponding chapters in textbooks or short video explanations) and examples of specific steps. For example, if the code contains simple syntax errors, the suggestion includes an example of the correct syntax format and a link to a syntax explanation video.
[0071] Medium-level errors: Break down the correct implementation logic using flowcharts and pseudocode to guide students in making gradual corrections. For example, for issues with disorganized code structure, provide a clear program execution flowchart and corresponding pseudocode framework.
[0072] Critical error: Provide a complete reference code snippet, highlighting key parts, and accompanied by audio explanations to aid understanding.
[0073] Recommendations for stratification for intermediate students:
[0074] Minor errors: Identify the root cause and potential risks of the error, encourage independent exploration of solutions, and provide an index of relevant technical documentation. For example, if the correspondence between comments and code logic is unclear, highlight the importance of comments in code maintenance and recommend reading professional commenting guidelines.
[0075] Medium error: Provide a comparative analysis of multiple optimization approaches, guiding students to consider the advantages and disadvantages of different solutions. For example, when the code structure is unreasonable, compare the performance and applicable scenarios of recursive and iterative implementations.
[0076] Serious error: Provide a framework for guiding modification solutions, leaving some key steps for students to complete independently, thus cultivating their ability to solve problems independently.
[0077] Recommendations for advanced student stratification:
[0078] Minor errors: Suggest innovative directions for improvement and recommend cutting-edge technical resources. For example, for problems with slightly higher code complexity, suggest trying emerging code optimization algorithms and recommend relevant papers or open-source projects.
[0079] Medium-level errors: Organize expert experience sharing case studies or industry best practices to guide students to learn from and improve upon them.
[0080] Critical error: Initiate group discussions or code reviews to promote communication and learning among students and optimize code from multiple perspectives.
[0081] In some embodiments, the method further includes displaying real-time quality assessment information and code quality optimization information in a progressive interface.
[0082] Exemplary quality assessment and code quality optimization information is presented in a progressive interface. Upon first viewing, only a basic suggestion layer is displayed, including the issue type, severity level, and brief improvement directions. Clicking the "View Details" button expands to a more in-depth guidance layer, providing specific modification steps, sample code, and relevant technical documentation. Based on the student's ability and the type of error, extended learning resources, such as programming exercises, open-source projects, or academic papers, are automatically recommended.
[0083] Based on the above-mentioned code quality optimization information generation method for teaching scenarios, this disclosure also provides a code quality optimization information generation device for teaching scenarios. The following will combine... Figure 3 The device is described in detail.
[0084] Figure 3 The diagram illustrates a structural block diagram of a code quality optimization information generation apparatus for teaching scenarios according to an embodiment of the present disclosure.
[0085] like Figure 3 As shown, the code quality optimization information generation device 300 for teaching scenarios in this embodiment includes an identification module 310, a processing module 320, a matching module 330, a determination module 340, and a generation module 350.
[0086] The identification module 310 is used to identify teaching intent markers, example code patterns, and education industry-specific annotation standards in the textbook code, and to construct a semantic feature library based on these markers. In one embodiment, the identification module 310 can be used to perform the operation S210 described above, which will not be repeated here.
[0087] The processing module 320 is used to process the student code using a pre-trained model to obtain key features from the student code. In one embodiment, the processing module 320 can be used to perform the operation S220 described above, which will not be repeated here.
[0088] The matching module 330 is used to match key features with a semantic feature library to obtain quality assessment information. In one embodiment, the matching module 330 can be used to perform the operation S230 described above, which will not be repeated here.
[0089] The determination module 340 is used to determine the error severity level of the student code based on quality assessment information. In one embodiment, the determination module 340 can be used to perform the operation S240 described above, which will not be repeated here.
[0090] The generation module 350 is used to generate code quality optimization information for students based on quality assessment information, error severity levels, and students' ability levels. In one embodiment, the generation module 350 can be used to perform the operation S250 described above, which will not be repeated here.
[0091] According to embodiments of this disclosure, identifying instructional intent markers, example code patterns, and education-specific annotation standards in textbook code includes: scanning the textbook code line by line based on text matching to identify instructional intent markers in the textbook code; classifying the textbook code according to different programming concepts and knowledge points to obtain different types of example code; obtaining the overall structure and key structural features of the example code, and determining the typical structural pattern of the programming concept to which the example code belongs based on the overall structure and key structural features, as the example code pattern; and analyzing education-specific annotation standards from multiple aspects such as the level of annotation detail, the correspondence with code logic, and the hierarchical structure.
[0092] According to embodiments of this disclosure, text matching is used to scan textbook code line by line, including: scanning the textbook code line by line based on a predefined regular expression pattern that matches the format of the teaching intent marker, and identifying the teaching intent marker in the textbook code. The overall structure includes the positions of the initialization part, the loop condition part, and the loop body update part, and the logical relationship between the three; key structural features include the declaration method of the loop variable, the judgment logic of the loop condition, and the operation on the loop variable in the loop body. The annotation specifications unique to the education industry are analyzed from multiple aspects such as the level of detail of the comments, the correspondence with the code logic, and the hierarchical structure, including: calculating the ratio of the number of comment lines to the total number of lines of code in the textbook code; analyzing the semantic relationship between the comment content in the textbook code and adjacent code segments; obtaining the hierarchical structure of the comments in the textbook code; and organizing the ratio, semantic relationship, and hierarchical structure to obtain the annotation specifications.
[0093] According to embodiments of this disclosure, a pre-trained model is used to process student code to obtain key features in the student code, including: performing deep semantic encoding on the student code to generate a high-dimensional semantic representation vector; extracting the complexity, functional completeness, and logical consistency of the student code from the semantic representation vector as candidate features; determining a first weight for each candidate feature based on teaching objectives and code evaluation priorities; and performing weighted fusion of each candidate feature based on the first weight to obtain key features.
[0094] According to embodiments of this disclosure, key features are matched with a semantic feature library to obtain quality assessment information, including: calculating a first similarity between the key features and the teaching intention marker, and a second similarity between the key features and the example code pattern; evaluating the annotations in the student code based on education industry-specific annotation specifications to obtain annotation index scores; and performing a weighted summation of the first similarity, the second similarity, and the annotation index scores to obtain quality assessment information.
[0095] According to embodiments of this disclosure, error severity levels include minor errors, moderate errors, and severe errors, and student ability levels include beginner, intermediate, and advanced students. Based on quality assessment information, error severity levels, and student ability levels, code quality assessment information is generated for each student, including: generating different levels of code quality optimization information for different error severity levels in student code for students of different ability levels.
[0096] According to embodiments of this disclosure, the apparatus further includes a display module for displaying real-time quality assessment information and code quality optimization information in a progressive interface.
[0097] According to embodiments of this disclosure, any plurality of modules among the identification module 310, processing module 320, matching module 330, determining module 340, and generating module 350 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the identification module 310, processing module 320, matching module 330, determining module 340, and generating module 350 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any one of the three implementation methods or a suitable combination of any of them. Alternatively, at least one of the identification module 310, processing module 320, matching module 330, determining module 340, and generating module 350 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0098] Figure 4 A block diagram illustrating an electronic device suitable for generating code quality optimization information for educational applications, according to an embodiment of the present disclosure, is shown.
[0099] like Figure 4 As shown, an electronic device 400 according to an embodiment of the present disclosure includes a processor 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage portion 408 into a random access memory (RAM) 403. The processor 401 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 401 may also include onboard memory for caching purposes. The processor 401 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0100] RAM 403 stores various programs and data required for the operation of electronic device 400. Processor 401, ROM 402, and RAM 403 are interconnected via bus 404. Processor 401 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 402 and / or RAM 403. It should be noted that the programs may also be stored in one or more memories other than ROM 402 and RAM 403. Processor 401 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0101] According to embodiments of this disclosure, the electronic device 400 may further include an input / output (I / O) interface 405, which is also connected to a bus 404. The electronic device 400 may also include one or more of the following components connected to the input / output (I / O) interface 405: an input section 406 including a keyboard, mouse, etc.; an output section 407 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the input / output (I / O) interface 405 as needed. A removable medium 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 410 as needed so that computer programs read from it can be installed into the storage section 408 as needed.
[0102] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0103] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 402 and / or RAM 403 and / or one or more memories other than ROM 402 and RAM 403 described above.
[0104] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the unstructured contract data processing method provided in the embodiments of this disclosure.
[0105] When the computer program is executed by the processor 401, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0106] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via communication section 409, and / or installed from removable medium 411. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0107] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411. When the computer program is executed by processor 401, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0108] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on a user's computing device, partially on a user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0109] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0110] Those skilled in the art will understand that the features described in the various embodiments of this disclosure can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments of this disclosure can be combined and / or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0111] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A method for generating code quality optimization information for teaching scenarios, characterized in that, The method includes: Identify teaching intent markers, example code patterns, and education industry-specific annotation standards in textbook codes, and construct a semantic feature library based on the teaching intent markers, example code patterns, and education industry-specific annotation standards; The pre-trained model is used to process student code to obtain key features in the student code; The key features are matched with the semantic feature library to obtain quality assessment information; The severity level of the error in the student code is determined based on the quality assessment information. Based on the quality assessment information, the error severity level, and the student's ability level, code quality optimization information is generated for the student.
2. The method according to claim 1, characterized in that, The identification of teaching intent markers, example code patterns, and education-specific commenting conventions in the textbook code includes: The textbook code is scanned line by line based on text matching to identify teaching intent markers in the textbook code; The textbook code is categorized according to different programming concepts and knowledge points to obtain different types of example code; Obtain the overall structure and key structural features of the example code, and determine the typical structural pattern of the programming concept to which the example code belongs based on the overall structure and key structural features, as the example code pattern; This analysis examines the unique annotation standards in the education industry from multiple perspectives, including the level of detail in the comments, their correspondence with the code logic, and their hierarchical structure.
3. The method according to claim 2, characterized in that, The text-based line-by-line scanning of the textbook code includes: Based on a predefined regular expression pattern that matches the format of instructional intent markers, the textbook code is scanned line by line to identify the instructional intent markers in the textbook code; The overall structure includes the positions of the initialization part, the loop condition part, and the loop body update part, as well as the logical relationships between them; the key structural features include the declaration method of the loop variable, the judgment logic of the loop condition, and the operation on the loop variable in the loop body; The analysis of commenting conventions unique to the education industry from multiple aspects, including the level of detail, correspondence with code logic, and hierarchical structure, includes: Calculate the ratio of the number of comment lines to the total number of lines of code in the textbook code; Analyze the semantic relationships between the comments and adjacent code segments in the textbook code; Obtain the hierarchical structure of comments in the textbook code; The annotation specification is obtained by organizing the proportions, semantic relationships, and hierarchical structure.
4. The method according to claim 1, characterized in that, The process of using a pre-trained model to process student code and obtain key features from the student code includes: The student code is subjected to deep semantic encoding to generate a high-dimensional semantic representation vector; The complexity, functional completeness, and logical consistency of the student code are extracted from the semantic representation vector as candidate features. For each candidate feature, a first weight is determined based on teaching objectives and code evaluation priorities; The key features are obtained by weighting and fusing each candidate feature based on the first weight.
5. The method according to claim 1 or 4, characterized in that, The key features are matched with the semantic feature library to obtain quality assessment information, including: Calculate the first similarity between the key feature and the instructional intent marker, and the second similarity between the key feature and the example code pattern; The comments in the student code are evaluated based on the specific commenting standards of the education industry to obtain a commenting index score; The quality assessment information is obtained by weighted summation of the first similarity score, the second similarity score, and the annotation index score.
6. The method according to claim 1, characterized in that, The error severity levels include minor errors, moderate errors, and severe errors; the student's ability levels include beginner students, intermediate students, and advanced students. Based on the quality assessment information, the error severity level, and the student's ability level, code quality assessment information is generated for the student, including: Based on the different error severity levels in student code from students of different ability levels, generate different levels of code quality optimization information.
7. The method according to claim 1 or 6, characterized in that, The method further includes: It displays real-time quality assessment information and code quality optimization information in a progressive interface.
8. A code quality optimization information generation device for teaching scenarios, characterized in that, The device includes: The identification module is used to identify teaching intent markers, example code patterns, and education industry-specific annotation standards in textbook code, and to construct a semantic feature library based on the teaching intent markers, example code patterns, and education industry-specific annotation standards. The processing module is used to process student code using a pre-trained model to obtain key features from the student code; The matching module is used to match the key features with the semantic feature library to obtain quality assessment information; The determination module is used to determine the error severity level of the student code based on the quality assessment information; The generation module is used to generate code quality optimization information for the student based on the quality assessment information, the error severity level, and the student's ability level.
9. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.