Intelligent answer sheet layout method and device, equipment and medium

The intelligent answer sheet layout method, which protects against semantic information segmentation and measures height, solves the problems of table breakage, option spanning multiple pages, and text-image separation in existing technologies. It achieves efficient and accurate answer sheet editing and layout, and supports editing and PDF generation for multiple question types and paper sizes.

CN122452503APending Publication Date: 2026-07-24SHENZHEN ERYI EDUCATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN ERYI EDUCATION CO LTD
Filing Date
2026-06-17
Publication Date
2026-07-24

Smart Images

  • Figure CN122452503A_ABST
    Figure CN122452503A_ABST
Patent Text Reader

Abstract

The application relates to an intelligent answer sheet layout method and device, equipment and a medium. The method comprises the following steps: obtaining test question information to be laid out, wherein the test question information comprises content data and semantic information of a test question; performing segmentation and protection processing on the content data based on the semantic information to obtain a protected content unit sequence; in response to a user's editing operation on the test question information, determining a layout update range affected by the editing operation; performing height measurement and layout calculation on the protected content unit sequence in the layout update range to generate page layout information; and based on the page layout information and a preset marking mode, calling a corresponding question type rendering adapter to generate and render an answer sheet.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of answer sheet layout technology, and in particular to an intelligent answer sheet layout method, apparatus, device and medium. Background Technology

[0002] Currently, online answer sheet editors have become core tools for teachers in creating exam papers and organizing tests. Mainstream technologies, based on Vue 3, TypeScript, and Pinia, implement virtual DOM measurement and basic layout functions, supporting the editing and PDF generation of answer sheets for multiple question types and paper sizes. However, existing technologies have significant technical shortcomings in practical teaching and examination applications, failing to meet teachers' core needs for efficient editing, accurate and aesthetically pleasing layout, and stable system compatibility.

[0003] Therefore, it is necessary to provide an intelligent answer sheet typesetting method, device, equipment, and medium to meet teachers' core needs for efficient editing, accurate and aesthetically pleasing typesetting, and stable and compatible system. Summary of the Invention

[0004] In view of the above, this application provides a method, apparatus, device and medium for intelligent answer sheet typesetting, the purpose of which is to solve the above-mentioned technical problems.

[0005] Firstly, this application provides a method for intelligent answer sheet layout, the method comprising: Obtain the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions; Based on the semantic information, the content data is segmented and protected to obtain a sequence of protected content units, including: based on the semantic information, identifying one or more semantic units in the content data; for each semantic unit, applying a segmentation and protection rule corresponding to the type of the semantic unit; and determining the content within the semantic unit as the protected content unit. The semantic unit includes at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate question content belonging to the same question group. In response to the user's editing operation on the test question information, determine the layout update range affected by the editing operation; Within the scope of the layout update, the height of the protected content unit sequence is measured and the layout is calculated to generate page layout information; Based on the page layout information and the preset marking mode, the corresponding question type rendering adapter is called to generate and render the answer sheet.

[0006] In some embodiments, the step of segmenting and protecting the content data based on the semantic information to obtain a protected content unit sequence includes: Based on the semantic information, one or more semantic units in the content data are identified; the semantic units include at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate question content belonging to the same question group; For each semantic unit, a segmentation protection rule corresponding to the type of the semantic unit is applied to determine the content within the semantic unit as the protected content unit.

[0007] In some embodiments, applying a segmentation protection rule corresponding to the question type of the semantic unit for each semantic unit includes: Obtain a predefined segmentation strategy library for each semantic unit type; the segmentation strategy library stores at least two segmentation strategy options and corresponding applicable conditions, the segmentation strategy options include the overall preservation strategy, the conditional segmentation strategy, and the minimum unit segmentation strategy; Calculate the page blank rate and semantic integrity score after applying different segmentation strategy options to the current semantic unit; Based on preset weighting rules, the page blank rate and semantic integrity score are weighted and calculated to obtain a comprehensive score for each segmentation strategy option. The segmentation strategy with the highest overall score is selected as the optimal segmentation strategy.

[0008] In some embodiments, determining the layout update range affected by the editing operation in response to a user's editing operation on the test question information includes: Determine the target question for which the editing operation is performed; Starting with the target question, subsequent questions are defined as the initial update range; Based on the protected content unit sequence, the boundary of the initial update range is adjusted so that the starting boundary of the layout update range is aligned with the starting boundary of the protected content unit.

[0009] In some embodiments, within the layout update scope, height measurement of the protected content unit sequence includes: For each protected content unit within the layout update range, a corresponding multidimensional measurement key is constructed. The multidimensional measurement key is generated based at least on the content hash value, container width, and style parameters of the content unit. Check if there is a cached height value in the cache that matches the multidimensional measurement key; If it does not exist, perform the following operations: Detect and wait for the asynchronous resources contained within the content unit to finish loading; After the asynchronous resource loading is complete, measure the actual rendering height of the content unit; If the asynchronous resource fails to load within a preset time, a predefined placeholder resource is used to replace the failed asynchronous resource, and the height is measured based on the placeholder resource. The correspondence between the multidimensional measurement key and the actual rendering height is stored in the cache.

[0010] In some embodiments, within the scope of the layout update, layout calculation is performed on the protected content unit sequence, including: Get the remaining layoutable height of the current page; Obtain the protected content units and their measured heights within the layout update range in sequence; Determine whether the remaining layoutable height is less than the measured height of the currently layoutable protected content unit; If so, then according to the segmentation rules corresponding to the type of the protected content unit to be typed, it is moved to the next page for typed as a whole, or it is forcibly segmented on the current page; Update the page layout information and the remaining layoutable height of the current page.

[0011] In some embodiments, the step of generating and rendering the answer sheet by calling the corresponding question type rendering adapter based on the page layout information and the preset marking mode includes: Based on the question type identifier in the question information, obtain the corresponding question type rendering adapter instance from the question type adapter factory; According to the preset marking mode, obtain the corresponding marking mode adapter instance from the marking mode adapter factory; The rendering method of the question type rendering adapter instance and the generation method of the marking mode adapter instance are invoked to generate the rendering instructions for the answer sheet based on the page layout information.

[0012] Secondly, this application provides an intelligent answer sheet typesetting device, which includes: The acquisition module is used to acquire the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions; The first determining module is used to perform segmentation and protection processing on the content data based on the semantic information to obtain a sequence of protected content units. The module includes: identifying one or more semantic units in the content data based on the semantic information; applying segmentation and protection rules corresponding to the type of the semantic unit to each semantic unit; and determining the content within the semantic unit as the protected content unit. The semantic unit includes at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate question content belonging to the same question group. The second determining module is used to determine the layout update range affected by the editing operation in response to the user's editing operation on the test question information; The first generation module is used to perform height measurement and layout calculation on the protected content unit sequence within the layout update range to generate page layout information; The second generation module is used to generate and render the answer sheet by calling the corresponding question type rendering adapter based on the page layout information and the preset marking mode.

[0013] Thirdly, this application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; When a processor executes a program stored in a memory, it implements the steps of the intelligent answer sheet layout method described in any embodiment of the first aspect.

[0014] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the intelligent answer sheet layout method as described in any embodiment of the first aspect.

[0015] The technical solutions provided in this application have the following advantages compared with the prior art: (1) By introducing semantic information to segment and protect the content data, the layout problems that damage the integrity of the content, such as broken tables, cross-page options, and separation of text and images, are fundamentally avoided, and the professionalism and readability of the answer sheet are significantly improved. (2) By responding to the user's editing operation on the test information, the layout update range affected by the editing operation is determined, and recalculation is performed only within the layout update range, realizing efficient incremental updates. This allows users to get immediate feedback when editing large answer sheets, and the operation is smooth and lag-free. The height measurement and layout calculation steps ensure the accuracy of the layout position. (3) By calling the corresponding question type rendering adapter, the question type rendering logic is decoupled from the core layout logic, making the system easy to expand and maintain, and able to flexibly support new question types and marking requirements. Intelligent, efficient, accurate and scalable automatic answer sheet layout is realized. Attached Figure Description

[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating a preferred embodiment of the intelligent answer sheet layout method of this application; Figure 2 This is a schematic diagram of a preferred embodiment of the intelligent answer sheet typesetting device of this application; Figure 3 This is a schematic diagram of a preferred embodiment of the electronic device of this application; The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0020] It should be noted that the descriptions of "first," "second," etc., in this application are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined as "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but only on the basis of being achievable by those skilled in the art. When the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed in this application.

[0021] Reference Figure 1 The diagram shown is a flowchart illustrating an embodiment of the intelligent answer sheet layout method of this application. The method is executed by an electronic device, which can be implemented by a software system and / or a hardware system. The intelligent answer sheet layout method includes: Step 101: Obtain the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions.

[0022] Test information refers to the collection of all questions and related data created by users that need to be formatted into an answer sheet.

[0023] Content data refers to the original information in the test questions that can be directly rendered and displayed. For example, the stem text and option text (A, B, C, D) of multiple-choice questions, the underlined text of fill-in-the-blank questions, the image URLs (Uniform Resource Locators) and image substitute text embedded in short-answer questions, and the cell text of tables, etc.

[0024] Semantic information refers to data used to describe the internal logical structure and layout constraints of content data. For example, it can identify whether a piece of content data belongs to a table, a group of multiple-choice options (i.e., all options of a multiple-choice question are considered as a whole), a mixed text and image layout (an image and its adjacent explanatory text are considered as a whole), or a question group (such as a reading comprehension material and its multiple sub-questions are considered as a related whole).

[0025] In some embodiments, user input (such as manually entered or pasted text, or uploaded images) can be received from the user interface of the answer sheet editor, or data can be imported from external files (such as Word documents or JSON files in a specific format). The received raw data is parsed to identify elements such as text, image links, and table structures, which are then used as content data. Simultaneously, based on preset rules or user specifications (such as setting it to a table via a toolbar button), different content data blocks are labeled with type tags. These tags and their relationships together constitute semantic information.

[0026] Step 102: Based on the semantic information, the content data is segmented and protected to obtain a sequence of protected content units.

[0027] Segmentation protection processing refers to the process of applying rules to content data based on semantic information to prevent segmentation that violates the logical integrity of the content during subsequent pagination and layout.

[0028] The protected content unit sequence refers to the list of content blocks that have been segmented and protected, arranged in the original order of the questions, and whose elements within each unit are subject to specific rules when paginated.

[0029] In some embodiments, the step of segmenting and protecting the content data based on the semantic information to obtain a protected content unit sequence includes: identifying one or more semantic units in the content data based on the semantic information; the semantic unit includes at least one of a table, a set of options for multiple-choice questions, an image and its associated text, a title and its subordinate question content belonging to the same question group; and, for each semantic unit, applying a segmentation protection rule corresponding to the type of the semantic unit to determine the content within the semantic unit as the protected content unit.

[0030] A semantic unit refers to a set of content in the test question data that, based on pre-defined logical relationship rules, should be treated as a whole or processed according to specific segmentation rules during subsequent typesetting and pagination. The definition of a semantic unit is based on semantic information, and its core characteristic is that its internal elements have strong relationships during typesetting and are not destroyed by simple mechanical height division.

[0031] In some embodiments, after obtaining the test question information, the structure and semantic information of the content data can be traversed and analyzed. Based on the preset type matching rules, fragments that conform to a specific pattern can be identified from the continuous content data stream and marked as a semantic unit.

[0032] Segmentation protection rules refer to the predefined constraints and processing strategies that must be followed during pagination layout calculations for different types of semantic units. These rules define how to handle scenarios where the remaining space on the current page is insufficient to accommodate the entire semantic unit.

[0033] A protected content unit refers to a content block that, after the application of segmentation protection rules, is treated by the system as an independent atomic unit that internally follows specific segmentation constraints in subsequent layout calculations.

[0034] In some embodiments, each identified semantic unit can be traversed. For each semantic unit, the system queries and loads the corresponding segmentation protection rule from a predefined rule base based on the type of its record (such as a table, option set, etc.).

[0035] In this embodiment, by identifying one or more semantic units in the content data based on the semantic information, and applying segmentation protection rules corresponding to the type of the semantic unit for each semantic unit, this method technically elevates the typesetting logic from a calculation based solely on physical height to intelligent decision-making based on the semantic structure of the content.

[0036] In some embodiments, applying a segmentation protection rule corresponding to the question type of the semantic unit for each semantic unit includes: S11, Obtain a predefined segmentation strategy library for each semantic unit type; the segmentation strategy library stores at least two segmentation strategy options and corresponding applicable conditions, the segmentation strategy options include the overall preservation strategy, the conditional segmentation strategy, and the minimum unit segmentation strategy.

[0037] A segmentation strategy library refers to a set of data structures or rules pre-configured for each specific type of semantic unit (such as a table or a set of options for a multiple-choice question).

[0038] The segmentation strategy options refer to the specific operational solutions available to the system when handling pagination issues at the end of a page for semantic units. The overall preservation strategy treats the entire semantic unit as an absolutely indivisible whole, either placing it completely on the current page or moving it entirely to the next page. The conditional segmentation strategy allows segmentation of semantic units according to certain logical rules when specific applicable conditions are met. The minimum unit segmentation strategy is a fallback strategy adopted when the applicable conditions of the previous two strategies are not met; it allows for forced segmentation based on the smallest content block, aiming to prevent the typesetting process from stalling.

[0039] The applicable conditions refer to the logical judgment rules that determine whether to adopt a certain segmentation strategy. The applicable conditions can be determined based on the numerical relationship between the remaining printable height of the current page and the height of the semantic unit or its key parts (such as the table header). For example, for a multiple-choice question's option set type semantic unit, the applicable condition for its overall retention strategy could be that the remaining height of the current page is ≥ the overall height of the option set; the applicable condition for its minimum unit segmentation strategy could be that the remaining height of the current page is < the height of any single option.

[0040] S12, calculate the page blank rate and semantic integrity score after applying different segmentation strategy options to the current semantic unit.

[0041] Page blank rate refers to the ratio of the height of the blank area that may be generated at the bottom of the current page after simulating the placement of the current semantic unit according to a certain segmentation strategy option, to the height of the entire page's printable area (or simply use the blank height).

[0042] Semantic integrity score is a numerical indicator used to quantitatively evaluate the degree to which the logical structure of a semantic unit is preserved or destroyed after it has been segmented according to a certain segmentation strategy.

[0043] In some embodiments, each segmentation strategy option obtained from the segmentation strategy library can be iterated sequentially. For each segmentation strategy option, its execution effect is simulated. First, based on the definition of the strategy and the attributes of the current semantic unit (such as table row height, number of options), it is calculated how the current semantic unit will be segmented if this strategy is applied (e.g., how much content remains on the current page, and how much content is moved to the next page). Next, based on the simulated segmentation results, two quantitative indicators are calculated: 1) Page white space ratio: calculated based on the remaining space of the current page after simulation. 2) Semantic integrity score: calculated according to a set of preset scoring rules, which assign different scores to different types of semantic units and different segmentation results (such as overall retention, segmentation at row boundaries, and segmentation within cells). A corresponding page white space ratio value and semantic integrity score value are calculated for each segmentation strategy option.

[0044] S13, based on preset weighting rules, the page blank rate and semantic integrity score are weighted and calculated to obtain a comprehensive score for each segmentation strategy option.

[0045] The preset weighting rules refer to predefined rules used to determine the relative importance of the two evaluation dimensions, page blank rate and semantic integrity score, in the final decision.

[0046] Weighted calculation refers to the mathematical operation process of linearly combining page blank rate and semantic integrity score according to their respective weights based on preset weight rules.

[0047] The overall score is a single numerical value obtained through weighted calculation, used to comprehensively evaluate the merits of a segmentation strategy option. The higher the overall score, the better the strategy performs in balancing space utilization and content integrity.

[0048] S14, Select the segmentation strategy option with the highest comprehensive score as the optimal segmentation strategy.

[0049] The optimal segmentation strategy refers to the segmentation strategy option that, after evaluation and calculation, best balances the goals of content integrity and page utilization in a specific context (for a specific current semantic unit and a specific remaining page space).

[0050] In this embodiment, the segmentation decision is upgraded from applying a single static rule to an intelligent decision-making process based on multi-strategy evaluation and quantitative optimization. By introducing a segmentation strategy library, quantitative calculation of page blank rate and semantic integrity score, and weighted calculation based on preset weight rules, this method can dynamically select the globally optimal solution from multiple candidate solutions for each semantic unit's specific layout context (current page remaining space). This avoids the rigid results that may be caused by a single rule (e.g., blindly pursuing completeness leading to a large number of blank pages, or blindly pursuing space saving severely damaging content readability), and maximizes page utilization efficiency while ensuring the logical coherence of the answer sheet content, generating more aesthetically pleasing and professional answer sheet documents.

[0051] Step 103: In response to the user's editing operation on the test question information, determine the layout update range affected by the editing operation.

[0052] Editing operations refer to the interactive actions by which users modify test information on the answer sheet editing interface. For example, inserting a new multiple-choice question between the third and fourth questions, deleting the fifth fill-in-the-blank question, or modifying the text content of the second short-answer question.

[0053] The layout update range refers to the area of ​​questions whose layout (including position, height, and page number) may need to be recalculated due to an editing operation. For example, when a user inserts a new question before question number N, the layout update range could be all questions from the new question to the end of the sequence, because the insertion operation will affect the position of all subsequent questions.

[0054] In some embodiments, determining the layout update range affected by the editing operation in response to a user's editing operation on the test question information includes: S21, determine the target question for the editing operation.

[0055] The target test question refers to the specific test question object that is directly affected by the editing operation.

[0056] S22, Starting from the target question, the subsequent questions are determined as the initial update range.

[0057] The initial update range refers to a continuous area of ​​test questions that may have imprecise starting boundaries, defined during the preliminary analysis of the impact of editing operations, based on the general principle that the layout of subsequent content may change due to changes in preceding content.

[0058] S23, based on the protected content unit sequence, adjust the boundary of the initial update range so that the starting boundary of the layout update range is aligned with the starting boundary of the protected content unit.

[0059] The starting boundary refers to the starting position of a range (initial update range or layout update range), that is, the index of the first protected content unit in the global sequence within that range.

[0060] Alignment refers to setting the starting boundary of the layout update range to be exactly the same as the starting position of a protected content unit, rather than setting it to the time position of a unit's content.

[0061] In this embodiment, by first determining a conservative initial update range and then aligning and adjusting its starting boundary based on the protected content unit sequence, it is ensured that the starting point of the layout update range is always located at the starting point of a complete and indivisible protected content unit. This fundamentally avoids layout errors that may result from improper definition of the local recalculation range.

[0062] Step 104: Within the layout update range, the height of the protected content unit sequence is measured and the layout is calculated to generate page layout information.

[0063] Height measurement refers to the process of determining the vertical space occupied by each content unit in a protected content unit sequence under specified typographic parameters (such as paper width, font, line spacing).

[0064] Layout calculation refers to the process of determining the precise position (coordinates) of each content unit on each page of the final answer sheet based on the height measurement results, pagination rules, and page size parameters.

[0065] Page layout information refers to the data structure that records the layout calculation results, describing the coordinates, size, and pagination of all content units on each page.

[0066] In some embodiments, within the layout update scope, height measurement of the protected content unit sequence includes: S31, for each protected content unit within the layout update range, construct its corresponding multidimensional measurement key, wherein the multidimensional measurement key is generated based at least on the content hash value, container width and style parameters of the content unit.

[0067] A multidimensional measurement key is a composite key value used to uniquely identify a protected content unit under a specific rendering configuration. This key value is generated by parameters from multiple dimensions, ensuring that the cache is only hit if all factors affecting the rendering height of that unit remain unchanged.

[0068] Content hash value refers to a fixed-length, unique string calculated by applying a hash function (such as MD5 or SHA-1) to the original content data (such as text, image URLs, and structural tags) contained in the protected content unit.

[0069] Container width refers to the maximum horizontal space size of the protected content unit that is allowed to be rendered on the page.

[0070] Style parameters refer to a set of attributes that affect the visual presentation of text and elements within a protected content unit.

[0071] In some embodiments, each protected content cell within the layout update scope can be systematically traversed. For each cell, all dimensional data required to generate the multidimensional measurement key are collected.

[0072] S32, query the cache to see if there is a cached height value that matches the multidimensional measurement key.

[0073] Cached height values ​​refer to height values ​​that have been previously measured and are associated with a multidimensional measurement key and stored in the cache.

[0074] In some embodiments, a multidimensional measurement key constructed for the currently protected content unit can be used as a query condition to perform a query operation in the cache data storage structure to find whether there is an entry whose key exactly matches the current multidimensional measurement key.

[0075] S33, if it does not exist, then perform the following operation: S331, detect and wait for the asynchronous resources contained in the content unit to finish loading; after the asynchronous resources are loaded, measure the actual rendering height of the content unit.

[0076] Asynchronous resources refer to external resources that are necessary for rendering protected content units, but whose loading time is uncertain or not immediate.

[0077] Actual rendering height refers to the vertical space occupied by the protected content unit in the browser or layout engine after asynchronous resources have been loaded and all styles have been applied.

[0078] In some embodiments, the content data of the currently protected content unit can be detected, all asynchronous resource references (such as image URLs) contained therein can be extracted, loading requests for these resources can be initiated, and the loading can be waited for all resources to be loaded.

[0079] S332, if the asynchronous resource fails to load within a preset time, a predefined placeholder resource is used to replace the failed asynchronous resource, and the height is measured based on the placeholder resource.

[0080] The preset time refers to the maximum waiting time threshold set by the system for loading asynchronous resources. If this time is exceeded, the loading is considered to have failed. For example, 5000 milliseconds.

[0081] A loading failure indicates that an asynchronous resource failed to load successfully within a preset time. Reasons may include network errors or the resource not existing.

[0082] Predefined placeholder resources refer to resources prepared in advance by the system to replace those displayed when asynchronous resource loading fails. These can be a local image of fixed size or a graphic placeholder.

[0083] S333, store the correspondence between the multidimensional measurement key and the actual rendering height in the cache.

[0084] In this embodiment, by constructing a multi-dimensional measurement key and querying the cache accordingly, previous measurement results can be intelligently reused, avoiding redundant calculations and significantly improving performance, especially during repeated editing. By detecting and waiting for asynchronous resources to load before performing measurements, the core technical challenge of inaccurate layout height calculations caused by asynchronous loading of resources such as images, leading to page layout errors, is fundamentally solved. By introducing a fault-tolerance mechanism that uses predefined placeholder resources after loading failures, the layout process can still proceed robustly even when some resources are unavailable, improving the system's availability and robustness.

[0085] In some embodiments, within the layout update range, performing layout calculations on the protected content unit sequence includes: S41, get the remaining layoutable height of the current page.

[0086] The current page refers to the virtual or actual page that the system is filling with protected content units during the sequential layout calculation process.

[0087] Remaining printable height refers to the remaining vertical space available for placing new content within the current page, from the bottom edge of the last printed element to the bottom edge of the printable area.

[0088] In some embodiments, it may be necessary to know how much space is left on the current page before starting to lay out the content within the layout update range, or before processing each new content unit. An internal state variable is maintained to record the remaining layable height of the current page.

[0089] S42, sequentially acquire the protected content units and their measured heights within the layout update range.

[0090] In some embodiments, each cell can be processed sequentially, starting from the beginning of the layout update range, following the original order of the protected content cell sequence. For each cell to be processed, the cell object itself and its associated measured height are obtained.

[0091] S43, determine whether the remaining layoutable height is less than the measured height of the protected content unit to be layout.

[0092] In some embodiments, the remaining available layout height can be compared with the measured height of the currently layout protected content unit to determine whether the remaining space on the current page is sufficient to fully accommodate the entire unit to be layout.

[0093] S44, if so, then according to the segmentation rules corresponding to the type of the protected content unit to be typed, move it as a whole to the next page for typed layout, or forcibly segment it on the current page.

[0094] The segmentation rules corresponding to the type refer to the segmentation protection rules associated with the type of the semantic unit (which constitutes the core of the protected content unit).

[0095] Forced splitting on the current page means allowing the content of the currently formatted unit to be cut vertically, with a portion placed in the remaining space of the current page and the remainder placed on the next page.

[0096] S45, Update the page layout information and the remaining layoutable height of the current page.

[0097] In some embodiments, the page layout information can be updated, that is, one or more new records can be added to the page layout information data structure.

[0098] In this embodiment, pagination triggering based on accurate space assessment is achieved by obtaining the remaining layoutable height of the current page and comparing it with the measured height.

[0099] Step 105: Based on the page layout information and the preset marking mode, call the corresponding question type rendering adapter to generate and render the answer sheet.

[0100] A question type rendering adapter is a software component specifically designed to convert page layout information for a particular question type into final renderable graphical instructions. Each adapter encapsulates the unique rendering logic for a specific question type. For example, the multiple-choice question type rendering adapter is responsible for rendering the question stem, option text, and the ○-shaped fill-in box before each option; the fill-in-the-blank question type rendering adapter is responsible for rendering the question stem text and drawing underlines in the blank areas.

[0101] Generating and rendering the answer sheet refers to the process of drawing the final answer sheet view in the user interface or output file (such as PDF) based on the element positions determined by the page layout information and the element styles determined by the marking mode.

[0102] In some embodiments, the corresponding question type rendering adapter instance can be obtained from a unified adapter factory or registry center based on the question type identifier corresponding to each content unit in the question information.

[0103] In some embodiments, the step of generating and rendering the answer sheet by calling the corresponding question type rendering adapter based on the page layout information and the preset marking mode includes: S51, based on the question type identifier in the question information, obtain the corresponding question type rendering adapter instance from the question type adapter factory.

[0104] Question type identifier refers to a string or enumeration value used to uniquely distinguish different question types.

[0105] A question type adapter factory refers to a software component or design pattern implementation that is specifically responsible for managing and providing question type rendering adapter instances.

[0106] A question type rendering adapter instance refers to a specific object that implements a unified rendering interface. This object encapsulates the logic of how to convert the content data and page layout information of a specific question type into specific drawing instructions.

[0107] In some embodiments, the type of rendering logic to be used can be determined based on the question type identifier in the question information, and the question type identifier corresponding to the unit can be read to obtain the corresponding question type rendering adapter instance from the question type adapter factory.

[0108] S52, according to the preset marking mode, obtain the corresponding marking mode adapter instance from the marking mode adapter factory.

[0109] The preset marking mode refers to the overall scheme that users select when creating or editing answer sheets, defining the scoring areas and standards of the answer sheets.

[0110] The marking mode adapter factory refers to a software component that is specifically responsible for managing and providing marking mode adapter instances. Its function is similar to that of the question type adapter factory, but it is designed for marking modes.

[0111] The marking mode adapter instance refers to a specific object that implements the unified interface. This object encapsulates the logic of how to generate common scoring elements (such as score boxes, admission ticket number filling areas, and absence mark boxes) that are unrelated to the question type under a specific preset marking mode.

[0112] In some embodiments, a preset marking mode can be read from the global configuration, and the corresponding marking mode adapter instance can be obtained from the marking mode adapter factory.

[0113] S53, invoke the rendering method of the question type rendering adapter instance and the generation method of the marking mode adapter instance, and generate the rendering instructions for the answer sheet according to the page layout information.

[0114] The rendering method refers to the function provided by the question type rendering adapter instance to perform the specific rendering operation for that question type.

[0115] The generation method refers to the function provided by the marking mode adapter instance to generate public elements related to marking.

[0116] Rendering instructions refer to a series of low-level commands or intermediate representations that describe specific graphics drawing operations (such as drawing text at a certain coordinate or drawing a rectangle in a certain area). These instructions are ultimately sent to the graphics rendering engine for execution to produce visual output.

[0117] The answer sheet refers to the final generated complete electronic or printed document that contains all the test questions, answer areas, and markings.

[0118] In this embodiment, by obtaining corresponding question type rendering adapter instances from the question type adapter factory and corresponding grading mode adapter instances from the grading mode adapter factory, the variable question type rendering logic and grading specification logic are separated from the stable core typesetting engine. This allows adding a new question type or grading mode to simply create a new adapter class and register it in the factory, without modifying any existing core code such as typesetting calculation, height measurement, and layout decisions. By calling a unified method of the adapter instance to generate rendering instructions, functions are combined in a standardized and pluggable manner, greatly improving the maintainability and scalability of the system, and significantly reducing the complexity and risk of function iteration and bug fixing, thus ensuring the long-term vitality of the system from an architectural perspective.

[0119] One of the core key points of the intelligent answer sheet layout method provided in this application is intelligent question segmentation based on semantic awareness.

[0120] Core principle: Abandoning the traditional mechanical logic of segmentation based solely on height, this approach establishes exclusive segmentation, recognition, and protection rules based on the semantic structural features of different content types in the answer sheet, such as tables, multiple-choice questions, and mixed text and images. Semantic integrity is used as the core criterion for segmentation, enabling intelligent and reasonable segmentation of test content. This fundamentally solves the problem of content truncation and separation, completely different from the height-based segmentation methods of existing technologies.

[0121] The specific implementation logic is as follows: First, the test content is analyzed into semantic units to identify indivisible or separable semantic units such as tables, option groups, image-text associations, and question groups; then, a dedicated segmentation strategy is set for different semantic units, such as retaining the table header and splitting by row for tables, splitting option groups as a whole, and binding and splitting image-text associations; finally, pagination is determined at the boundaries of semantic units based on the remaining page height to ensure the readability and integrity of the segmented content.

[0122] The second key point of the intelligent answer sheet layout method provided in this application lies in the answer sheet layout calculation based on incremental updates.

[0123] Core principle: Breaking through the existing layout calculation mode of full recalculation, we establish an incremental update mechanism of change identification, scope definition, and local recalculation. This mechanism accurately identifies the type of change in user operations and the affected scope, clears the cache of only the affected part, and recalculates the layout of the corresponding area. This significantly reduces invalid calculations, improves the response speed of editing operations, and adapts to the efficient editing needs of large answer sheets.

[0124] The specific implementation logic is as follows: First, identify the type of user operation change (single question modification, adding or deleting questions, specification switching, etc.) and calculate the corresponding affected layout range; second, only clear the measurement cache of the affected area and retain the cache results of the unchanged part; finally, start from the affected starting page and recalculate the layout locally, only updating the page data that has changed, to achieve incremental update and rendering of the layout.

[0125] The third key point of the intelligent answer sheet layout method provided in this application lies in the multi-dimensional and accurate measurement of the answer sheet content height.

[0126] Core principle: Construct a dual height measurement guarantee mechanism of image preloading + content hash caching to solve the measurement error problem caused by asynchronous image loading. At the same time, establish a multi-dimensional cache key-value system to ensure that the cache automatically expires after changes in content, style and specifications, so as to achieve accurate and real-time measurement of the answer sheet content height and provide reliable basic data for typesetting calculation.

[0127] The specific implementation logic is as follows: Before measurement, all image URLs in the test questions are extracted and preloaded in parallel. The loading status is monitored and timeout and failure fallback strategies are set. Measurement is performed only after all images have been loaded. At the same time, all factors affecting the height, such as test question ID, content hash, question type, container width, and style attributes, are collected to generate a unique cache key. The cache key is automatically updated when the content or configuration changes to avoid using expired measurement data.

[0128] The fourth key point of the intelligent answer sheet layout method provided in this application lies in the protection of the integrity of question groups based on overall association.

[0129] Core principle: Breaking away from the independent slicing processing mode of question group elements, an integrated management mechanism is established for question group overall height calculation, boundary judgment, and continuity detection. The question group title and content are treated as a whole for pagination judgment, and a minimum space threshold for title display is set to ensure the reading continuity and layout aesthetics of the question group, which conforms to the answer sheet layout specifications of educational examinations.

[0130] The specific implementation logic is as follows: Before pagination, calculate the overall height of the question group, including the title, questions, and scoring box; if the remaining space on the current page is less than the minimum display height of the title, move the entire question group to a new page; after pagination, check the dispersion of the question group content, and readjust it if it spans too many pages; at the same time, uniformly record and maintain the spacing of the question group on different pages to ensure consistent layout.

[0131] The fifth key point of the intelligent answer sheet layout method provided in this application lies in the adapter-based management of question types and marking modes.

[0132] Core principle: By introducing the adapter design pattern, a unified interface and registration mechanism are established for question type adapters and marking mode adapters, respectively. The rendering, editing, and segmentation logic of different question types, as well as the scoring boxes and scoring specification processing logic of different marking modes, are independently encapsulated, realizing the decoupled management of question types and marking modes, and significantly reducing the system's expansion and maintenance costs.

[0133] Specific implementation logic: Define unified interfaces for question type adapters and marking mode adapters, create independent adapter classes for each question type and marking mode, and implement the interface methods; build an adapter registry center and factory class, complete adapter registration when the system starts, and obtain the corresponding adapter from the factory and call the unified method when used; when adding a new question type / new mode, only a new adapter needs to be created and registered, without modifying the existing code.

[0134] The sixth key point of the intelligent answer sheet layout method provided in this application lies in the anomaly protection and boundary condition optimization in all scenarios.

[0135] Core principle: Establish a dual protection system of anomaly hierarchical processing + intelligent boundary judgment. Design exclusive degradation, protection and recovery strategies for various abnormal scenarios such as image loading failure, excessive content, and concurrent operations. At the same time, set multi-dimensional boundary judgment thresholds and optimize the boundary processing logic of pagination and layout. Completely solve the problems of abnormal crashes and unreasonable boundary layout in existing technologies, and improve system stability and layout quality.

[0136] The specific implementation logic is as follows: abnormal scenarios are classified and handled. If an image fails to load, a retry is performed and a placeholder image is replaced. If the content is too tall, intelligent segmentation and forced segmentation are performed as a fallback. Concurrent operations are optimized using operation locks and queues. At the same time, thresholds such as the minimum remaining space on the page and the minimum display space for question group titles are set. The blank rate and overflow ratio are intelligently judged and the segmentation strategy is adjusted reasonably to reduce blank pages and invalid layout.

[0137] Reference Figure 2 The diagram shown is a functional module schematic of the intelligent answer sheet typesetting device 100 of this application.

[0138] The intelligent answer sheet layout device 100 described in this application is installed in an electronic device. Depending on its functions, the intelligent answer sheet layout device 100 includes an acquisition module 110, a first determination module 120, a second determination module 130, a first generation module 140, and a second generation module 150. These modules can also be referred to as units, which are a series of computer program segments that can be executed by the processor of an electronic device and perform a fixed function, and are stored in the memory of the electronic device.

[0139] In this embodiment, the functions of each module / unit are as follows: The acquisition module 110 is used to acquire the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions; The first determining module 120 is used to perform segmentation and protection processing on the content data based on the semantic information to obtain a protected content unit sequence, including: identifying one or more semantic units in the content data based on the semantic information; applying segmentation and protection rules corresponding to the type of the semantic unit to each semantic unit; and determining the content within the semantic unit as the protected content unit. The semantic unit includes at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate test question content belonging to the same question group. The second determining module 130 is used to determine the layout update range affected by the editing operation in response to the user's editing operation on the test question information; The first generation module 140 is used to perform height measurement and layout calculation on the protected content unit sequence within the layout update range to generate page layout information; The second generation module 150 is used to generate and render the answer sheet by calling the corresponding question type rendering adapter based on the page layout information and the preset marking mode.

[0140] The specific implementation of the intelligent answer sheet typesetting device in this application is largely the same as the specific implementation of the intelligent answer sheet typesetting method described above, and will not be repeated here.

[0141] Reference Figure 3 The diagram shown is a schematic representation of a preferred embodiment of the electronic device of this application.

[0142] The electronic device includes a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. The memory 113 is used to store computer programs, such as intelligent answer sheet typesetting programs; In some embodiments, the processor 111 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 111 can be used to control the overall operation of the electronic device, such as performing data interaction or communication-related control and processing. In this embodiment, the processor 111 is used to run program code stored in the memory 113 or process data.

[0143] The communication interface 112 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The communication interface 112 may also be used to establish a communication connection between the electronic device and other electronic devices.

[0144] The memory 113 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 113 may be an internal storage unit of the electronic device, such as the hard disk or memory of the electronic device. In other embodiments, the memory 113 may also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. of the electronic device. Of course, the memory 113 may include both internal storage units and external storage devices of the electronic device. In this embodiment, the memory 113 can be used to store the operating system and various computer programs installed on the electronic device, such as the program code of a smart answer sheet typesetting program. In addition, the memory 113 can also be used to temporarily store various types of data that have been output or will be output.

[0145] Figure 3 Only an electronic device having a processor 111, a communication interface 112, a memory 113 and a communication bus 114 is shown. However, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0146] In one embodiment of this application, when the processor 111 executes the program stored in the memory 113, it implements the intelligent answer sheet layout method provided in any of the foregoing method embodiments, including: Obtain the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions; Based on the semantic information, the content data is segmented and protected to obtain a sequence of protected content units, including: based on the semantic information, identifying one or more semantic units in the content data; for each semantic unit, applying a segmentation and protection rule corresponding to the type of the semantic unit; and determining the content within the semantic unit as the protected content unit. The semantic unit includes at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate question content belonging to the same question group. In response to the user's editing operation on the test question information, determine the layout update range affected by the editing operation; Within the scope of the layout update, the height of the protected content unit sequence is measured and the layout is calculated to generate page layout information; Based on the page layout information and the preset marking mode, the corresponding question type rendering adapter is called to generate and render the answer sheet.

[0147] For a detailed explanation of the above steps, please refer to the above. Figure 1 A flowchart illustrating an embodiment of the intelligent answer sheet layout method.

[0148] Furthermore, this application also proposes a computer-readable storage medium that is both non-volatile and volatile. This computer-readable storage medium is any one or any combination of several of the following: hard disk, multimedia card, SD card, flash memory card, SMC, read-only memory (ROM), erasable programmable read-only memory (EPROM), portable compact disc read-only memory (CD-ROM), USB memory, etc. The computer-readable storage medium includes a data storage area and a program storage area. The program storage area stores an intelligent answer sheet layout program, which, when executed by a processor, performs the following operations: Obtain the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions; Based on the semantic information, the content data is segmented and protected to obtain a sequence of protected content units, including: based on the semantic information, identifying one or more semantic units in the content data; for each semantic unit, applying a segmentation and protection rule corresponding to the type of the semantic unit; and determining the content within the semantic unit as the protected content unit. The semantic unit includes at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate question content belonging to the same question group. In response to the user's editing operation on the test question information, determine the layout update range affected by the editing operation; Within the scope of the layout update, the height of the protected content unit sequence is measured and the layout is calculated to generate page layout information; Based on the page layout information and the preset marking mode, the corresponding question type rendering adapter is called to generate and render the answer sheet.

[0149] The specific implementation of the computer-readable storage medium in this application is largely the same as the specific implementation of the above-described intelligent answer sheet layout method, and will not be repeated here.

[0150] It should be noted that the sequence numbers of the embodiments in this application are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. Furthermore, the terms "including," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that includes a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Without further limitations, an element defined by the phrase "including a…" does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0151] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware simulation platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.

[0152] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for intelligent answer sheet layout, characterized in that, The method includes: Obtain the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions; Based on the semantic information, the content data is segmented and protected to obtain a sequence of protected content units, including: based on the semantic information, identifying one or more semantic units in the content data; for each semantic unit, applying a segmentation and protection rule corresponding to the type of the semantic unit; and determining the content within the semantic unit as the protected content unit. The semantic unit includes at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate question content belonging to the same question group. In response to the user's editing operation on the test question information, determine the layout update range affected by the editing operation; Within the scope of the layout update, the height of the protected content unit sequence is measured and the layout is calculated to generate page layout information; Based on the page layout information and the preset marking mode, the corresponding question type rendering adapter is called to generate and render the answer sheet.

2. The intelligent answer sheet layout method as described in claim 1, characterized in that, The step of applying segmentation protection rules corresponding to the question type of each semantic unit includes: Obtain a predefined segmentation strategy library for each semantic unit type; the segmentation strategy library stores at least two segmentation strategy options and corresponding applicable conditions, the segmentation strategy options include the overall preservation strategy, the conditional segmentation strategy, and the minimum unit segmentation strategy; Calculate the page blank rate and semantic integrity score after applying different segmentation strategy options to the current semantic unit; Based on preset weighting rules, the page blank rate and semantic integrity score are weighted and calculated to obtain a comprehensive score for each segmentation strategy option. The segmentation strategy with the highest overall score is selected as the optimal segmentation strategy.

3. The intelligent answer sheet layout method as described in claim 1, characterized in that, The step of responding to a user's editing operation on the test question information and determining the layout update range affected by the editing operation includes: Determine the target question for which the editing operation is performed; Starting with the target question, subsequent questions are defined as the initial update range; Based on the protected content unit sequence, the boundary of the initial update range is adjusted so that the starting boundary of the layout update range is aligned with the starting boundary of the protected content unit.

4. The intelligent answer sheet layout method as described in claim 1, characterized in that, Within the scope of the layout update, the height of the protected content unit sequence is measured, including: For each protected content unit within the layout update range, a corresponding multidimensional measurement key is constructed. The multidimensional measurement key is generated based at least on the content hash value, container width, and style parameters of the content unit. Check if there is a cached height value in the cache that matches the multidimensional measurement key; If it does not exist, perform the following operations: Detect and wait for the asynchronous resources contained within the content unit to finish loading; After the asynchronous resource loading is complete, measure the actual rendering height of the content unit; If the asynchronous resource fails to load within a preset time, a predefined placeholder resource is used to replace the failed asynchronous resource, and the height is measured based on the placeholder resource. The correspondence between the multidimensional measurement key and the actual rendering height is stored in the cache.

5. The intelligent answer sheet layout method as described in claim 4, characterized in that, Within the scope of the layout update, layout calculations are performed on the protected content unit sequence, including: Get the remaining layoutable height of the current page; Obtain the protected content units and their measured heights within the layout update range in sequence; Determine whether the remaining layoutable height is less than the measured height of the currently layoutable protected content unit; If so, then according to the segmentation rules corresponding to the type of the protected content unit to be typed, it is moved to the next page for typed as a whole, or it is forcibly segmented on the current page; Update the page layout information and the remaining layoutable height of the current page.

6. The intelligent answer sheet layout method as described in claim 1, characterized in that, The step of generating and rendering the answer sheet by calling the corresponding question type rendering adapter based on the page layout information and the preset marking mode includes: Based on the question type identifier in the question information, obtain the corresponding question type rendering adapter instance from the question type adapter factory; According to the preset marking mode, obtain the corresponding marking mode adapter instance from the marking mode adapter factory; The rendering method of the question type rendering adapter instance and the generation method of the marking mode adapter instance are invoked to generate the rendering instructions for the answer sheet based on the page layout information.

7. An intelligent answer sheet typesetting device, characterized in that, The device includes: The acquisition module is used to acquire the test question information to be formatted, wherein the test question information includes the content data and semantic information of the test questions; The first determining module is used to perform segmentation and protection processing on the content data based on the semantic information to obtain a sequence of protected content units. The module includes: identifying one or more semantic units in the content data based on the semantic information; applying segmentation and protection rules corresponding to the type of the semantic unit to each semantic unit; and determining the content within the semantic unit as the protected content unit. The semantic unit includes at least one of the following: a table, a set of options for multiple-choice questions, an image and its associated text, and a title and subordinate question content belonging to the same question group. The second determining module is used to determine the layout update range affected by the editing operation in response to the user's editing operation on the test question information; The first generation module is used to perform height measurement and layout calculation on the protected content unit sequence within the layout update range to generate page layout information; The second generation module is used to generate and render the answer sheet by calling the corresponding question type rendering adapter based on the page layout information and the preset marking mode.

8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor, when executing a program stored in memory, implements the intelligent answer sheet layout method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the intelligent answer sheet layout method as described in any one of claims 1 to 6.