Embodiment
The present invention is by fundamental element and relation character by the setting questionnaire, and will comprise that the definition of these fundamental elements such as constant, variable, action stored by database, when the user need customize questionnaire surely, questionnaire request according to user's submission, the questionnaire rule of utilizing these fundamental elements and relation character to set up to meet described logic rules is formed required rule bag by these questionnaires rules then.In intelligent Questionnaire systems, introduced regulation engine, with in the test paper process to the parsing of rule, and complicated matching process transfers to rules engines processes, to improve rule match efficient.
So-called regulation engine is a kind of assembly that is embedded in the application program, its task is that the current data object of submitting to engine is tested and compared with the business rule that is carried in the engine, activate those and meet business rule under the current data state, according to the actuating logic of stating in the business rule, trigger operation corresponding in the application program.The advantage of regulation engine is the matching efficiency height, such as, Rete (pattern match fast) algorithm is easy to adapt to rule and changes, and is easy to develop client's operation interface.
In order to make those skilled in the art person understand the present invention program better, the present invention is described in further detail below in conjunction with drawings and embodiments.
The theory diagram of a preferred embodiment of reference the present invention's intelligence shown in Figure 2 Questionnaire systems:
In this embodiment, the present invention's intelligence Questionnaire systems comprises: questionnaire interactive unit 20, rule bag storage unit 21, regulation engine unit 23, issue handling unit 24.Wherein, rule bag storage unit 21 is used for the storage rule bag, and the corresponding questionnaire of each rule bag comprises at least one rule; Questionnaire interactive unit 20 provides user interface, obtains questionnaire and the answer data that the user submits to by described user interface; Regulation engine unit 23 is used for the questionnaire that obtains according to questionnaire interactive unit 20 and loads the rule bag of described questionnaire correspondence from rule bag storage unit 21, and triggers action in the described rule bag according to described answer data; Issue handling unit 24 is used for the concrete processing procedure of the action of executing rule engine unit 23 triggerings.
The layer of structure of questionnaire as shown in Figure 3, a questionnaire comprises one or more problems by its numbering and version number's unique identification in each questionnaire, a plurality of options are arranged under each problem.The description of dependence between in rule bag storage unit 21, having preserved to questionnaire, problem, option, these data are configured according to the custom questionnaire interface by the user, and these configuration datas are used for dynamically generating questionnaire.Generative process for questionnaire will be described in detail later.
Regulation engine unit 23 adopts the fundamental mechanism of regulation engine, the data object of submitting to engine is retrieved, according to the current property value of these objects and the relation between them, find qualified rule the rule bag of the questionnaire of submitting to from the respective user that is loaded into engine, create the execution example of these rules.These examples will be carried out according to the priority of each example when engine is received execution command successively.
Regulation engine inside is made of following several sections: the work internal memory is used to deposit the set of data objects of being quoted by engine; Rule is carried out formation, is used to deposit the rule that is activated and carries out example; The static rule district, be used to deposit the business rule that all are loaded, these rules will be according to certain data structure organization, after the data in the workspace change, engine needs rapid in the object present situation in the workspace, and the rule that regulation rule is carried out in the formation is carried out example.
Regulation engine unit 23 can adopt the regulation engine assembly based on Java or C++ program language environment, certainly, also can adopt other regulation engine assembly.
In this embodiment, regulation engine unit 23 comprises loading subelement 231, coupling subelement 232, triggers subelement 233.Wherein, load questionnaire that subelement 231 is used for obtaining according to the questionnaire interactive unit loads the questionnaire correspondence from rule bag storage unit rule bag; Coupling subelement 232 is used for the condition according to the described rule bag of the data object coupling definition of test paper; Trigger the action that subelement 233 is used to trigger the condition correspondence of described coupling.
Fig. 4 shows the processing procedure of the present invention's intelligence Questionnaire systems to questionnaire, may further comprise the steps:
Step 41, questionnaire interactive unit are obtained the questionnaire (questionnaire comprises problem, and problem comprises option) that the user submits to by user interface;
Step 42, regulation engine unit load the rule bag of current questionnaire correspondence from rule bag storage unit according to the questionnaire of submitting to;
Step 43, return loading result to the questionnaire interactive unit;
Step 44, user are by questionnaire interactive unit input answer data;
Step 45, regulation engine unit are according to the set of data objects of answering the questions in a test paper, the condition that defines in the matched rule bag, and according to the condition triggering corresponding action (visit data object or service object's method) of mating, can be to jump to N road exercise question, also can be to open certain specific service page etc.;
The concrete processing procedure of the action that triggers is carried out in step 46, regulation engine cell call issue handling unit;
Step 47, regulation engine unit will descend one problem to return to the questionnaire interactive unit, and it is mutual to carry out a new round.
When described questionnaire has a plurality of problem, need to repeat above-mentioned steps 44 to step 46, to finish the processing of all problems.
After step 48, all problems are finished dealing with, final execution result is returned to the questionnaire interactive unit.
For this questionnaire that forms with regular packet mode, the present invention also provides corresponding development approach and development system, to develop questionnaire flexible and convenient to use, solve the problem of using questionnaire to introduce the data object difficulty, make and be easy to as questionnaire such as the same common component use, when carrying out the system integration or need existing new data-objects of introducing or service object as rule factor, do not need to revise code logic, only need do the just development and change of supporting business well of the better simply configuration of relative exploitation.
The flow process of a preferred embodiment of reference questionnaire development approach of the present invention shown in Figure 5 may further comprise the steps:
The logic rules of action triggers instep 501, the content of determining questionnaire and the test paper process;
The content of described questionnaire comprises: problem, option, the rule of also comprise questionnaire information, setting on each level of questionnaire etc.The layer of structure of questionnaire has a detailed description in front, does not repeat them here.
Step 502, utilize predefined questionnaire fundamental element and relation character to set up the questionnaire rule that meets described logic rules.
The fundamental element of questionnaire comprises: data object, service object, constant, variable, action.Offer the miscellaneous service system and use in order to make questionnaire can be used as common component, that is to say will with professional combination, introduced the data and the service object of miscellaneous service, i.e. variable, variable, action etc. in the present invention.In the time of for example can imagining the definition questionnaire, can determine the information that the client is basic substantially before the exploitation, comprise name, sex, telephone number, these public informations can define as the dynamic displaying contents of questionnaire and redirect logical option in advance.At first utilize described relation character to define the condition between described fundamental element and meet the action that described condition triggers by the user; Just can form the questionnaire rule then by these conditions and action.One group of questionnaire rule is formed a rule bag, and this rule bag has intactly been described the strictly all rules of this questionnaire.
The questionnaire rule that step 503, utilization are set up generates questionnaire.
Utilize the inventive method, can set up the questionnaire rule that meets required logic rules by the user according to questionnaire fundamental element and relation character when questionnaire is developed, these questionnaire rules have been formed a complete questionnaire.As seen, utilize the present invention, only need the user to understand questionnaire fundamental element and the relation character that offers the user, just can make the user customize required questionnaire simply, easily.
Fig. 6 shows the relation of questionnaire and questionnaire rule among the present invention:
Rule condition and qualified action have been described in the questionnaire rule, the general corresponding a plurality of rules of questionnaire, the set of rule is exactly the rule bag.For the ease of management, questionnaire and rule bag are administrative relationships one to one, are about to the relevant questionnaire rule of a questionnaire and all concentrate on a rule and wrap and manage.Variable and constant and relation character all are to form conditions of elements, they be combined to form complete questionnaire rule description.
For example, the partial content of the questionnaire rule of describing with the .drl formatted file is as follows:
import?com.test.examples.Person;
import?com.test.examples.Pension;
rule″Find?the?retired?person″
when
(Person.sex==″f″,Person.age>60)||Person.sex==″m″,Person.age>55)
then
sendPension(personID,200);
end
Above-mentioned file content is explained as follows by non-null:
1) introduce a data object, data object has comprised people's information, as sex, age;
2) introduce a service object, the service object has comprised method sendPension, and the effect of this method is to send retired pay according to user ID;
3) rule: seek pensioner people;
4) if condition satisfies;
5) sex (sex) be " man " (f), the age (age) greater than 60 years old or sex be " woman " (m), the age was greater than 55 years old;
6) condition satisfies;
7) provide retired pay, the recipient is numbered (personID), and providing the amount of money is (200);
8) rule finishes.
Contrast Fig. 6, the sex in the above-mentioned file (sex), age all are variablees, and " man " is (m), " woman " be constant (f), and "==", ">" all belong to conditional relator.
In order to make the user utilize the own required questionnaire of the inventive method exploitation better, the language that the description document of questionnaire rule is used can be translated as interpretative code, in database, preserve in variable, constant, condition, the action, preserve the source relation binding and the corresponding client language of these information, present to the descriptive statement of user's customization by configuration interface, thereby make general user not need to understand the fundamental element and the relation character of the questionnaire that the developer sets, can carry out the configuration of questionnaire rule simply, easily.
As seen, in the present invention, the binding rule engine has solved data object, service object's introducing problem.
Regulation engine is supported primary rule language, usually support the use of Import statement, the spitting image of the import statement in the Java language, its implication is " introducing ", promptly as long as the object that in rule, uses, specify complete path and class name, regulation engine is introduced required class automatically from the Java bag of identical name.Describe for example below:
For example, set up following rule:
import?com.test.examples.Person;
rule″Find?the?retired?person″
when
(Person.sex==″f″,Person.age>60)||(Person.sex==″m″,Person.age>65)
then
nextQuestion(6);
end
Wherein, com.test.examples.Person is a data object, and it has comprised test paper user's personal information, comprises sex, age etc.Because this object has been arranged, so just can quote relevant information in the condition.Like this, when the user's who answers questionnaire sex (sex) be " man " (f), the age (age) greater than 60 years old or sex be " woman " (m), age is greater than 55 years old the time, just jump to the 6th topic, purpose is the information according to the user here, according to default track channeling conduct test paper.
Above-mentioned rule is expanded, is set up following rule:
import?com.test.examples.Person;
import?com.test.examples.Pension;
rule″Find?the?retired?person″
when
(Person.sex==″f″,Person.age>60)||(Person.sex==″m″,Person.age>65)
then
sendPension(personID,pension(Person.age));
end
The difference of the rule of setting up with the front is, in this rule, com.test.examples.pension is a service object, and it has comprised two new methods availalbes, promptly calculates the gold that moves back that provide according to people's age.Wherein, the purpose of pension (Person.age) is to calculate the retired pay that obtain according to the retired's age; SendPension (personID, pension (Person.age)) is the account number transmission retired pay according to the retired.
As seen from the above description, regulation engine provides primary language description to support dynamic expansion, dynamically resolves when operation, and need not must be through compiling before operation as coding.As seen, utilize the present invention in the questionnaire performance history, can expand action, variable and constant easily, improved the expansion of questionnaire and integrated efficient greatly.
When system reads out problem that questionnaire, questionnaire comprise, during at the information such as option of each problem, can be initialized as questionnaire or test paper according to the different application scene from database.Questionnaire is as the definition of showing content, can change the content of revising questionnaire according to the result of user's setting, for example the formulation of the quantity of exercise question, newly-increased option, questionnaire logic control rule etc.Test paper then is used for carrying out mutual with the user and preserving interactive information, and the interactive information with the user when test paper finishes is saved in the database.
Because the information of test paper usually needs to preserve a period of time so that long-run analysis, but development along with business, the content of problem generally has corresponding variation, in order to guarantee certain continuation, convenient management to questionnaire, in the time of can also being saved in a corresponding questionnaire, the rule bag that comprises one group of questionnaire rule in the database, set the version number of this rule bag.When after the content of user's modification questionnaire it being saved in database, be that amended questionnaire is set new version number.
The version corresponding relation between questionnaire and the problem has been preserved in version management, can guarantee that historical data can correctly show and analyze, and the questionnaire of redaction can be showed new content again, has adapted to current service needed admirably.
For example, a questionnaire A, have 1,2,3,4,5 problems, used the questioned problem option in 3 of pinpointing the problems a period of time of after because professional variation, make the option of problem also need to change, if but directly on original questionnaire, revise, the test paper information that can cause originally having stored possibly can't normally show, because original definition changes, this moment is if guarantee old data and can normally show, and questionnaire is backward showed with new definition again, then the questionnaire to redetermination produces a new version number, for example old questionnaire correspondence be 1.0 problem 3, new questionnaire correspondence be 1.1 problem 3, the option difference of problem 3, the questionnaire definition of old like this The data 1.0 versions is showed, new questionnaire adopts the questionnaire definition of 1.1 versions to show, the data of each version are to questionnaire that should version, has guaranteed that questionnaire data total energy is normal to show.
With reference to Fig. 7, Fig. 7 shows the theory diagram of questionnaire development device first embodiment of the present invention:
In this embodiment, questionnaire development device of the present invention comprises:database 70,questionnaire unit 71, rule are set upunit 72, rule bag storage unit 73.Wherein,database 70 is used to store the fundamental element and the relation character of the questionnaire of setting, the rule of also having stored corresponding questionnaire;Questionnaire unit 71 provides user interface, is used to obtain the questionnaire information of user's input, and described questionnaire information comprises the logic rules of action triggers in the content of questionnaire and the test paper process; Rule is set upunit 72 and is used for obtaining corresponding fundamental element and relation character according to described questionnaire information fromdatabase 70, and utilizes described fundamental element and relation character to set up the questionnaire rule that meets described logic rules; Rulebag storage unit 73 is used to preserve the rule bag of being made up of described questionnaire rule, the corresponding questionnaire of each rule bag.
Rule is set upunit 72 and comprised:condition enactment subelement 721 and rule generate subelement 722.Wherein,condition enactment subelement 721 is used for defining the condition between described fundamental element and meeting the action that described condition triggers according to described relation character; Rule generatessubelement 722 and forms described questionnaire rule according to described condition and described action.
Fig. 8 shows the interaction flow of each unit in the questionnaire development device of the present invention shown in Figure 7, may further comprise the steps:
Step 81, questionnaire unit obtain the questionnaire request that the user submits to;
The essential information of questionnaire is obtained in step 82, questionnaire unit from the questionnaire request that the user submits to, and extracts problem information and option information;
Step 83, questionnaire unit requests rule are set up the unit and are carried out the configuration of questionnaire rule;
Step 84, rule are set up the unit obtains corresponding object, variable, constant, relation character and action from database according to the essential information of questionnaire definition;
Step 85, rule are set up the unit and are returned user's configuration interface to the questionnaire unit, and the definition that will obtain corresponding object, variable, constant, relation character and action at this configuration interface from database shows the user;
Step 86, user carry out the configuration of questionnaire rule by configuration interface;
Step 87, rule are set up the unit user configured questionnaire rule are saved in the database;
Step 88, rule are set up the configuration generation questionnaire rule file of unit according to the user;
Step 89, rule are set up the unit questionnaire rule file that generates are saved in the rule bag storage unit;
Step 90, rule are set up the user configuration interface of unit in the questionnaire unit and are returned configuration successful message (this step is an optional step).
At the conditional relationship that can utilize on the configuration interface user between relation character definition object, variable, constant, and set symbol is should the action that condition triggers;
Examples of configurations on user's configuration interface is as follows:
Rule 1
Condition 1 sex=man and age>60
Or condition 2 sex=men and age>65
The result
Send retired pay
Preserve following related content in the database:
com.test.examples.Person;
com.test.examples.Pension;
rule″Find?the?retired?person″
(Person.sex==″f″,Person.age>60)||Person.sex==″m″,Person.age>55)
sendPension(personID,200);
The rule file that generates comprises following content:
import?com.test.examples.Persion
import?com.test.examples.Pension;
rule″Find?the?retired?person″
when
(Person.sex==″f″,Person.age>60)||Person.sex==″m″,Person.age>55)
Then
sendPension(personID,200);
end
With reference to Fig. 9, Fig. 9 is the theory diagram of questionnaire development device second embodiment of the present invention:
With embodiment illustrated in fig. 7 different be, in this embodiment, set up betweenunit 72 and the rulebag storage unit 73 in rule and also to be provided with version number's adding device 74 that the rule bag that is used to described questionnaire rule to form adds version number.The interpolation process of version number and mode are existing in the description of the inventive method in front to be introduced in detail, does not repeat them here.
Though described the present invention by embodiment, those of ordinary skills know, the present invention has many distortion and variation and do not break away from spirit of the present invention, wish that appended claim comprises these distortion and variation and do not break away from spirit of the present invention.