Error in order when adding a question to a survey page

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/7/2012 4:59:10 AM
Gravatar
Total Posts 52

Error in order when adding a question to a survey page

Hello,

I have found a small error when adding a question to a survey page. If you add, for example, three questions to a survey page then the "QuestionOrder" field will have the values: 0,1,2. Then if you delete then question number 1 then "QuestionOrder" field will contain the values 1,2. Then if you add a new field then "QuestionOrder" values will be: 0,2,2. If we repeat the steps, deleting the first question and adding a new one we end up with the questions with order "2". This will happen if we repeat it with any number of questions. Now if we try to sort the questions we will find some strange behavior, specifically, if we move up the las question we will see that it is moved to the top.

This is not a big deal since the step for making the error happen are no very common, the problem comes in from the procedure mp_SurveyQuestions_Insert, the way it sets the order is selecting the count of records. The simpler solution will be replacing the count with a max plus one:

SELECT@pageQuestionCount = Max(QuestionOrder)+1
FROM mp_SurveyQuestions
WHERE PageGuid = @PageGuid

The same problem occurs un the survey pages.

6/8/2012 6:12:41 PM
Gravatar
Total Posts 52

Re: Error in order when adding a question to a survey page

The solution in my previous post has an error when there are not any previous questions. The right code should by:

SELECT@pageQuestionCount = COALESCE(Max(QuestionOrder),-1)+1
FROM mp_SurveyQuestions
WHERE PageGuid = @PageGuid

6/11/2012 7:07:05 AM
Gravatar
Total Posts 18439

Re: Error in order when adding a question to a survey page

Thanks! I will make this change and push it to the source code repository later today.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.