A kind of examination question batch method for uploading of the online education website based on SSH
Technical field
The invention belongs to software reliability field, in the online education website specifically based on SSH exploitation, a kind of intelligently parsing method when backstage batch uploads examination question.
Background technology
Along with the development of network technology, online education pattern is also constantly popularized, and in order to consolidate knowledge point, can have corresponding examination question after each chapters and sections, examination question adds at server end.On traditional examination question, arq mode has two kinds, and one uploads one by one, namely adds with inscribing by filling in topic information one; Another kind of pattern is that batch is uploaded, this kind of pattern is divided into again two kinds, the first is that excel uploads mode, namely the various piece of exercise question put into excel form according to the rule provided in advance and upload onto the server, the second is that word uploads mode, the i.e. satisfactory word document of edit format, and upload.Obviously, upload mode efficiencies one by one low, seldom use now; On batch, crossing excel uploads mode and does not meet the edit pattern of most of examination question, electronics examination question is generally edit with word, so word to upload mode more general in examination question method for uploading, but there is a problem in which, namely need to carry out Edit Document according to fixing rule, have very high requirement to the form of document, if certain part in document is undesirable, server then can be caused cannot to resolve this part and upload failure, greatly have impact on work efficiency.
Summary of the invention
The present invention is the weak point that prior art exists, a kind of examination question batch method for uploading of the online education website based on SSH is proposed, upload on the basis of mode at word, do not need the form specifying to upload document, just can intelligence, examination question exactly in parse documents, complete uploading operation, thus reduce the workload of editorial staff, raise the efficiency.
The present invention is that technical solution problem adopts following technical scheme:
The examination question batch method for uploading of a kind of online education website based on SSH of the present invention, comprises exam pool and server in described online education website, is characterized in, described examination question batch method for uploading carries out as follows:
Step 1, in word document inediting four kinds of examination question types, to comprise: multiple-choice question, fill a vacancy topic, True-False and question-and-answer problem;
Described multiple-choice question comprises selects stem and option;
Described topic of filling a vacancy comprises fill a vacancy topic stem and special character; Described special character comprises underscore and parenthesis;
Described True-False comprises True-False stem and end parenthesis;
Described question-and-answer problem comprises question-and-answer problem stem;
Step 2, described server stores four kinds of interpretive models, comprising: the first interpretive model, the second interpretive model, the 3rd interpretive model and the 4th interpretive model;
Described first interpretive model be by letter and punctuation mark combination headed by or by bracket and letter combination headed by or letter and space headed by form, expression multiple-choice question option;
Described second interpretive model is bracket with multiple space and sentence tail is punctuation mark or comprises underscore and sentence tail is the form of punctuation mark, represents topic stem of filling a vacancy;
Described 3rd interpretive model is using the bracket with multiple space as the form of sentence tail, represents True-False stem;
Described 4th kind of interpretive model is letter or with the combination of letter and punctuation mark or with the form of combination of bracket and letter, represents that the option of multiple-choice question is alphabetical;
Step 3, described word document is uploaded in described online education website;
Step 4, described server read described word document and carry out staging treating, obtain n paragraph also successively stored in array arr [n];
Step 5, definition loop variable i and j, option-argument C, separator W, examination question type chained list T, examination question stem chained list S, examination question option chained list L and identifier flag; Flag=1 represents multiple-choice question, flag=2 represents topic of filling a vacancy, flag=3 represents True-False, flag=4 represents question-and-answer problem in definition;
Step 6, initialization i=1;
Step 7, described server read arr [i], and judge whether i=1 sets up, if set up, then by arr [i] stored in described examination question stem chained list S; And perform step 8, otherwise, perform step 11;
Step 8, whether arr [i] is topic stem of filling a vacancy to utilize described second interpretive model to judge; Topic stem, then flag=2 if fill a vacancy; And perform step 10; Otherwise, perform step 9;
Step 9, whether arr [i] is True-False stem, if True-False stem, then makes flag=3 to utilize the 3rd interpretive model to judge; Otherwise, make flag=4;
Step 10, by i+1 assignment to after i, return step 7 and perform, until after i > n, perform step 19;
Step 11, whether arr [i] is the option of multiple-choice question to utilize the first interpretive model to judge, if so, then makes flag=1, and performs step 12; Otherwise, perform step 17;
Step 12, according to space, arr [i] to be split, obtain m paragraph dia [m];
Step 13, initialization j=1;
Step 14, whether a jth paragraph dia [j] is the option letter of multiple-choice question to utilize the 4th interpretive model to judge; If so, then separator W is added in option-argument C together with a jth paragraph dia [j]; Otherwise, a jth paragraph dia [j] is added in option-argument C;
Step 15, by j+1 assignment to after j, return step 14 and perform, until j > m;
Step 16, by i+1 assignment to after i, return step 7 and perform, until after i > n, perform step 19;
Step 17, by flag stored in examination question type chained list T, and judge whether flag=1 sets up, if set up, then by option-argument C stored in described examination question option chained list L, otherwise, by null value stored in described examination question option chained list L;
Step 18, by arr [i] stored in described examination question stem chained list S, and return step 8 and perform;
Step 19, traversal examination question type chained list T, examination question stem chained list S and examination question option chained list L, obtain the type of each examination question, stem and option and respectively stored in described exam pool, thus the batch completing examination question is uploaded.
Compared with prior art, beneficial effect of the present invention is:
1, the present invention is by reading document to server, obtains all paragraphs, whether mates the interpretive model defined according to paragraph, carry out True-False object type, and be stored into inside database; Thus overcome the low efficiency problem uploaded one by one in classic method, decrease the time of uploading examination question, overcome the problem that excel uploads the inconvenience of mode inediting simultaneously, solve existing word and upload the problem that document in mode must observe certain rule, resolve document intelligently, improve efficiency.
2, the present invention is by summing up the feature of all topic types, defines comprehensive interpretive model, judges which pattern each paragraph mates, thus True-False object type exactly, achieve intelligence, exactly parse documents.
3, the present invention is by comprising the paragraph of multiple option as separator segmentation using space, obtain paragraph array, and judge that whether each paragraph is the letter part of option by interpretive model, thus make corresponding process, and then obtain correct option portion, solve multiple option in word document and be placed on the situation occurring space in the situation of a paragraph and single option, ensure that the correctness of parsing.
Embodiment
Comprise exam pool and server in online education website in the present embodiment, a kind of examination question batch method for uploading of the online education website based on SSH is: first, define four kinds of interpretive models; Secondly, upload document and obtain all paragraphs; Then, judge examination question type by interpretive model, if True-False, resolve multiple-choice question option portion; Again, the type of per pass examination question, stem, option (if having) are put in corresponding chained list, finally travel through chained list and be stored into database.Specifically, be carry out as follows:
Step 1, in word document inediting four kinds of examination question types, to comprise: multiple-choice question, fill a vacancy topic, True-False and question-and-answer problem;
Multiple-choice question comprises selects stem and option;
Topic of filling a vacancy comprises fill a vacancy topic stem and special character; Special character comprises underscore and parenthesis;
True-False comprises True-False stem and end parenthesis;
Question-and-answer problem comprises question-and-answer problem stem;
Step 2, server stores four kinds of interpretive models, comprising: the first interpretive model, the second interpretive model, the 3rd interpretive model and the 4th interpretive model;
First interpretive model be by letter and punctuation mark combination headed by or by bracket and letter combination headed by or letter and space headed by form, expression multiple-choice question option;
Second interpretive model is bracket with multiple space and sentence tail is punctuation mark or comprises underscore and sentence tail is the form of punctuation mark, represents topic stem of filling a vacancy;
3rd interpretive model is using the bracket with multiple space as the form of sentence tail, represents True-False stem;
4th kind of interpretive model is letter or with the combination of letter and punctuation mark or with the form of the combination of bracket and letter, represents that the option of multiple-choice question is alphabetical;
By analysis, the option of multiple-choice question is with shape as " A. ", " A, ", " A) " and " (A) " four kinds of forms beginnings, and therefore the first interpretive model is used for judging the option of multiple-choice question; The form of shape as " () " or " _ _ _ _ _ " can be comprised, so can utilize the second interpretive model to judge whether is be topic stem of filling a vacancy in topic of filling a vacancy; True-False is with shape as the form of " () " ends up, so, the 3rd interpretive model can be utilized to judge whether True-False; And the 4th kind of interpretive model can be explained in step 12.
Step 3, word document is uploaded in online education website;
Step 4, server read word document and carry out staging treating, obtain n paragraph also successively stored in array arr [n];
Step 5, definition loop variable i and j, option-argument C, separator W, examination question type chained list T, examination question stem chained list S, examination question option chained list L and identifier flag; Flag=1 represents multiple-choice question, flag=2 represents topic of filling a vacancy, flag=3 represents True-False, flag=4 represents question-and-answer problem in definition;
The respective option of multiple-choice question is connected by separator W and stored in option-argument C, when reading examination question and show from exam pool, splits option-argument C just can obtain the respective option by separator W.
Step 6, initialization i=1;
Step 7, server read arr [i], and judge whether i=1 sets up, if set up, then by arr [i] stored in examination question stem chained list S; And perform step 8, otherwise, perform step 11;
First paragraph of Word document must be the stem part of the first topic, thus can directly the first paragraph stored in examination question stem chained list, and judge its type, as step 8, shown in 9; If not the first paragraph, then may be the stem of multiple-choice question option portion or one examination question, so will judge, as shown in step 11.
Step 8, whether arr [i] is topic stem of filling a vacancy to utilize the second interpretive model to judge; Topic stem, then flag=2 if fill a vacancy; And perform step 10; Otherwise, perform step 9;
Step 9, whether arr [i] is True-False stem, if True-False stem, then makes flag=3 to utilize the 3rd interpretive model to judge; Otherwise, make flag=4;
Step 10, by i+1 assignment to after i, return step 7 and perform, until after i > n, perform step 19;
Step 11, whether arr [i] is the option of multiple-choice question to utilize the first interpretive model to judge, if so, then makes flag=1, and performs step 12; Otherwise, perform step 17;
Step 12, according to space, arr [i] to be split, obtain m paragraph dia [m];
Multiple option may be comprised because of in a paragraph, be split by space again between the respective option, so split array arr [i] by space, obtain multiple paragraph, and process accordingly.
Step 13, initialization j=1;
Step 14, whether a jth paragraph dia [j] is the option letter of multiple-choice question to utilize the 4th interpretive model to judge; If so, then separator W is added in option-argument C together with a jth paragraph dia [j]; Otherwise, a jth paragraph dia [j] is added in option-argument C;
Because space may be had in an option, so can not simply multiple paragraph be connected together, but do corresponding process by the option letter that judgement is an option.The 4th kind of interpretive model in step 2 judges option letter, if dia [j] is if " A) ", " (A ", " (A) ", " A, ", " A. " are as beginning or a just letter using shape, then think option letter, then separator W and dia [j] is together added to option-argument C, otherwise dia [j] is not option letter, but the content part of an option, then directly add dia [j] to option-argument C.Such as, in following examination question
Some row in 11. taking-up relations, and the relational calculus of the tuple of cancellation repetition is called ()
A. column operations B. project C. concatenation operation D. Selecting operation is got
The paragraph array obtained after utilizing space to split is { [A. gets column operations], [B], [. project], [C. concatenation operation], [D.], [Selecting operation] }, by the 4th kind of interpretive model, known [A. gets column operations], [B], [C. concatenation operation] and [D.] are option letters, and [. project] and [Selecting operation] is not, get column operations WB. project WC. concatenation operation WD. Selecting operation so the option-argument C obtained is WA., thus correctly resolve the respective option.
Step 15, by j+1 assignment to after j, return step 14 and perform, until j > m;
Step 16, by i+1 assignment to after i, return step 7 and perform, until after i > n, perform step 19;
Step 17, by flag stored in examination question type chained list T, and judge whether flag=1 sets up, if set up, then by option-argument C stored in examination question option chained list L, otherwise, by null value stored in examination question option chained list L;
If this examination question is multiple-choice question, then option-argument is put into option chained list L, otherwise, null value is put into option chained list L, to ensure the various piece correctly obtaining each examination question when traveling through three chained lists in step 19 simultaneously.
Step 18, by arr [i] stored in examination question stem chained list S, and return step 8 and perform;
Step 19, traversal examination question type chained list T, examination question stem chained list S and examination question option chained list L, obtain the type of each examination question, stem and option respectively and stored in exam pool, thus the batch completing examination question is uploaded, overcome the low efficiency problem uploaded one by one in classic method, decrease the time of uploading examination question, overcome the problem that excel uploads the inconvenience of mode inediting simultaneously, solve existing word and upload the problem that document in mode must observe certain rule.