Algorithm-how to use PHP to implement the following requirements (the options for multiple choice questions are randomly changed and the comments are automatically adjusted)

Source: Internet
Author: User
The options of multiple choice questions are randomly changed each time they are displayed. The scenario is as follows: {code...} the above shows that the options do not change. after the options are randomly changed, how can users see the following results? Change 1: {code ...} change 2: {code ...} I have been thinking about this problem for a long time, and I also try to write... the options of multiple choice questions are randomly changed each time they are displayed. The scenario is as follows:

Here is the question Title (content: the length of the AB and AC segments may be ?) Option A: AB greater than AC (correct answer by default) Option B: AB less than AC Option C: equal length option D: Not sure user comment 1: Answer A has A question, because AB and AC .... intersection D ..., therefore, select B. User Comment 2: Select A or B. User Comment 3: None, D.

The above shows that the options do not change. after the options are randomly changed, how can users see the following results?
Change 1:

Here is the question Title (content: the length of the AB and AC segments may be ?) Option A: equal length Option B: AB greater than AC (correct answer by default) Option C: uncertain option D: AB less than AC user comment 1: Answer B has A question, because AB and AC .... intersection D ..., select D. User Comment 2: Select B or D. User Comment 3: none of them are correct, C. User Comment 4: CD error, B error, A error.

Change 2:

Here is the question Title (content: the length of the AB and AC segments may be ?) Option A: Not sure Option B: AB smaller than AC Option C: AB greater than AC (default correct answer) option D: length equal user comment 1: Answer C has A question, because AB and AC .... intersection D ..., therefore, select B. User Comment 2: C and B are incorrect. User Comment 3: none of them,. User Comment 4: AB error, C error, and D error.

I have been thinking about this problem for a long time, and I have tried to write some algorithms, but the processing results are not satisfactory. I 'd like to ask for help!
In fact, the problem can be simplified to how to extract the comment content option.

AnswerCThere is a problem, because AB and AC... intersection D..., so you should selectB.
SelectC,BNo.
None of them,A.
ABError,CAlso wrong,DYes.

Or are there other alternatives?

Reply content:

The options of multiple choice questions are randomly changed each time they are displayed. The scenario is as follows:

Here is the question Title (content: the length of the AB and AC segments may be ?) Option A: AB greater than AC (correct answer by default) Option B: AB less than AC Option C: equal length option D: Not sure user comment 1: Answer A has A question, because AB and AC .... intersection D ..., therefore, select B. User Comment 2: Select A or B. User Comment 3: None, D.

The above shows that the options do not change. after the options are randomly changed, how can users see the following results?
Change 1:

Here is the question Title (content: the length of the AB and AC segments may be ?) Option A: equal length Option B: AB greater than AC (correct answer by default) Option C: uncertain option D: AB less than AC user comment 1: Answer B has A question, because AB and AC .... intersection D ..., select D. User Comment 2: Select B or D. User Comment 3: none of them are correct, C. User Comment 4: CD error, B error, A error.

Change 2:

Here is the question Title (content: the length of the AB and AC segments may be ?) Option A: Not sure Option B: AB smaller than AC Option C: AB greater than AC (default correct answer) option D: length equal user comment 1: Answer C has A question, because AB and AC .... intersection D ..., therefore, select B. User Comment 2: C and B are incorrect. User Comment 3: none of them,. User Comment 4: AB error, C error, and D error.

I have been thinking about this problem for a long time, and I have tried to write some algorithms, but the processing results are not satisfactory. I 'd like to ask for help!
In fact, the problem can be simplified to how to extract the comment content option.

AnswerCThere is a problem, because AB and AC... intersection D..., so you should selectB.
SelectC,BNo.
None of them,A.
ABError,CAlso wrong,DYes.

Or are there other alternatives?

After analyzing this problem, we find that the most critical point is to point the option in the comment to the option currently displayed. If you extract and analyze comments using ABCD, the experience will be poor. for example, USA will become USB. of course you can take this case out for special processing, but there will always be cases that cannot be processed.

Since we only need to match comments and options, we can provide A flexible method, such as @ A and @ B, note that the essence of this solution is to identify the options that the user wants to point out during input. Therefore, you need to make some assistance when the user inputs, such as replacing the option ID internally before committing, otherwise, the system will return to the above "extraction", which will lead to misjudgment. (Me@apple.com> me@dpple.com ......)

Of course, this method also has its drawbacks, that is, it is not in line with user cognition, that is, the user may not necessarily recognize it, or even the user does not know that the option to be referenced still needs to adopt this "abnormal" method, therefore, the interaction also requires some guidance to inform the user of the correct method of referencing options. You can even make some hard judgments. for example, when ABCD appears in the comment content, you may be prompted with the following light: "Do you have mentioned the option in the question? if so, you need XXXX ".

In addition, there is a more extreme way, because obfuscation comes from ABCD, we can directly remove this obfuscation, because we answer questions on the web page, you can directly use the control for interaction, you do not need to use the code to represent the answer as on paper, so you can use this form:

Do you think I'm handsome?

  • ⊙ Shuai burst
  • Min bu Shuai

Then the comment will become

This question is so shameless that it is only "handsome" and "not handsome". what should I do if I want to say "a little handsome?

Look, there is no worries at all.

The last sentence is purely installation-forced. ignore it: some problems do not have to be solved by programs. the power of design is often used to get twice the result with half the effort.

You can set a symbol for the answer tag. For example, Weibo circles people. @ Xxxxxxx you can set a similar symbol, for example, # c indicates the answer C

$ Arr = array ('a' => 'uncertain ',' B '=>' AB is less than ac', 'C' => 'AB is greater than AC (correct answer by default) ', 'D' => 'equal length',); uasort ($ arr, function () {return mt_rand );}); $ arr_keys = array_keys ($ arr); $ arr_new_keys = array_flip ($ arr_keys); array_walk ($ arr_new_keys, function (& $ value) {$ value = chr ($ value + 65) ;}); $ chr_a = 'a'; foreach ($ arr as $ key =>$ value) {echo $ chr_a ++. ". ". $ value."
";}Extract ($ arr_new_keys); echo < User Comment 2: $ C or $ B is incorrect.
User Comment 3: none of them are correct, $.
User Comment 4: $ A $ B error, $ C error, $ D error.
EOT;

The focus of this question, as mentioned above, is to establish a certain relationship between the comment and the answer, then, if such a contact does not pass through the special conventions, it is not reliable to determine whether the comment content contains the corresponding characters or words. Add@XXThe form of the comment is connected with the option, and it is strange to use it.

In my opinion, since the user needs to clearly distinguish each option from the comments corresponding to each option, it is better to change the way of thinking so that when users comment, directly select to comment on an option, which is easy to implement. you can add a comment button that requires a hover to trigger after each option, and then open a comment window below for users to enter.

In terms of comment presentation, you can use the unused option itself to let the user click the option. below, a series of comments about this option are directly displayed. for specific implementation forms, refer to SF'sShow commentsClick again to fold the comment.

The specific implementation form behind the above answers is only for a clearer description of ideas and for reference only. There are many ways to make answers random, so I will not repeat them here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.