[23/12/06] Tabulated survey at topic head

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply

Rating:

Excellent!
29
73%
Very Good
4
10%
Good
3
8%
Fair
1
3%
Poor
3
8%
 
Total votes: 40

Extensions Robot
Extensions Robot
Extensions Robot
Posts: 28080
Joined: Sat Aug 16, 2003 7:36 am

[23/12/06] Tabulated survey at topic head

Post by Extensions Robot »

MOD Name: Tabulated survey at topic head
Author: asinshesq
MOD Description: Allow users who are entitled to post polls to design surveys that will appear at the top of a topic. Users will be able to respond to the survey by clicking a button...each user response will appear at the topic head

MOD Version: 1.0.19 (Updated 12/23/06)
Tested on phpBB Version: 2.0.21

Download File: tabulated_survey_at_topic_head_1-0-19.zip
mods overview page: View
File Size: 122565 Bytes



Support for this MOD needs to be asked within this topic. The phpBB Teams are not responsible or required to give anyone support for this MOD. By installing this MOD, the phpBB Support Team or phpBB MODifications Team may not be able to provide support.

This MOD has only been tested by the phpBB MOD Team with the phpBB version listed in the topic. It may not work in any other versions of phpBB.
Last edited by Extensions Robot on Mon Apr 30, 2007 12:30 am, edited 1 time in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)

TerraFrost
Former Team Member
Posts: 5957
Joined: Sun Dec 26, 2004 3:40 am
Location: Austin, TX

Post by TerraFrost »

MOD Validated/Released

Notes:
Create surveys with new threads.

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Thanks for completing the validation, TerraFrost.

This is a pretty powerful mod (IMHO ;) ). It lets any user who is allowed to post a poll design a survey of up to 8 questions that will appear at the top of a topic (like a poll does). As users answer the questions, their names appear on the left column and their individual answers appear on columns to the right with totals at the bottom where appropriate.

The person designing the survey gets to the screen that allows him to design a survey by clicking a link titled "Click here to access or hide survey design box" that appears under the post window whenever a person who is allowed to post a poll is posting a new topic or editing the first post of a topic. In designing the survey, a form allows the designing user to specify:
  • The name of the survey (sometimes this would be an overall question or text that introduces the real questions)
  • which group or groups are supposed to answer the survey
  • whether users who answer the survey should be shown in the left column or left out
  • whether the answers to the survey (the rows in the survey) should be shown alphabetically by the username column, alphabetically (or reverse alphabetically) by the first answer column or in the order in which users submitted the answers
  • whether the users in the group answering the survey who have NOT already answered the survey should be listed as non-responders (I think of this as a 'Hall of Shame')
  • the column widths for the username column and for each question column (if you leave these blank the browser will just do whatever it thinks makes sense, which usually looks pretty good)
In addition, for each question, the admin specifies:
  • how the users will input the answer (small text blank, large text blank, text area, checkbox/radio buttons or drop down menu, and if checkbox/radio buttons or drop down menu the various possible selections for the user to pick from)
  • whether the responses for the question should be totalled and if so, how they should be totalled (by number of users responding, by the sum of the numbers the users put in their responses, by average of the numbers the users put in their responses or by the total number of responses that match text the designer of the survey specifies)
  • the maximum number of users that can respond to a particular question before additional users are no longer asked that question
The survey can be something really simple like "who is coming to the charity event" or it can be something much more complex. For example, the survey could be about a large pot luck dinner where the questions basically divvy up responsiblity for who brings what...you could have yes/no questions like "I'll bring a meat course that feeds 10 people (maximum 3 families should bring this)" and "I'll bring dessert for 5 people (maximum 5 families should bring this)" and "I'll bring assorted vegetables for 15 people (maximum 4 families should bring this)"; once the maximum number of users have already said yes to one of those questions the remaining users will no longer be asked it. Or of course you could have the questions elicit textual responses so that you know exactly what each person is planning to bring.

When the survey is designed and posted, it appears at the head of the topic and each user in the groups that have been designated to take the survey will see a button labeled "Fill out Survey" that he can click. When he clicks that button, a new form opens up that asks him the questions (he inputs the questions in text blanks, radio buttons, drop downs, etc as specified by the designer of the survey).

If a user has already responded, the button he sees is not longer "Fill in Survey' but instead is "Change your answers', which allows the user to change his answers.

The survey is tabulated as people answer it so that everyone can see at a glance each user who has responded (assuming the designer does not choose to hide the responders) and what his answers are (and there are totals for any questions the survey specified to be totalled).

I've included a few screenshots in the mod zip file (in a 'screeenshots' directory inside the 'contrib' folder) so you can see what this looks like in action (though they are a bit out of date since I've added a few features since I took those shots)...
Last edited by asinshesq on Tue Jan 03, 2006 12:27 am, edited 13 times in total.

AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

Hey Alan,

Amazing bit of work you'd done here!


Installed with a little bit more effort than I'd hoped for (mainly due to changes on my end) but went smooth enough. Not sure I would agree with the 'Installation Level: Easy', but, oh'well.

A few things I noticed:

Probably my biggest "yuck" issue with this MOD is the fact that you have a "People who haven't yet answered". What happens when I have a forum with 100,000 people and I select "all users" can access it. Hmm, not pretty.


Probably the biggest "hmmm??" issue is one I'm sure you know about. It sure won't be easy to solve. That is, at the moment a user can insert multiple times. You than provide a 'Change Your Answers' button. This, of course, isn't going to change all of the submissions for the user. Again, no easy way to fix this without a major bit of work, that I can see, but it's still probably an issue to address in some way-future version.

Nice job with the SQL. Seems about as non-bloating as it's going to get.


Lastly, (and shame on whoever validated this MOD).... you have hard-coded ENGLISH within .tpl files. This is a major no-no ;) You have within (posting_body.tpl) the following hard-coded: "Click here to access or hide survey design box". This is something the MOD validators should have caught before it went public, but you should probably fix this for international users.

Alan, kick ass job on this. I'm glad you wrote it and not me. Way too much work for me these days :mrgreen:

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Thanks for those kind words. And it was way to much work for me too ;) A couple of responses:
AbelaJohnB wrote: ...Probably my biggest "yuck" issue with this MOD is the fact that you have a "People who haven't yet answered". What happens when I have a forum with 100,000 people and I select "all users" can access it. Hmm, not pretty...

The user designing and posting the survey gets to choose whether to display the 'Hall of Shame' of users who haven't responded. Remember that the list will only include members of the group or groups that are supposed to answer the questions. On my board, we usually use the Hall of Shame so that we instantly know who we need to bug about not answering yet :roll:

Since I usually use that feature, I have it set 'selected' by default. That's of course easy enough to change if you want:

Code: Select all

OPEN
posting.php

FIND
		$select_nonresponders_no = '';
		$select_nonresponders_yes = 'selected';

REPLACE WITH
		$select_nonresponders_no = 'selected';
		$select_nonresponders_yes = '';
Or, if you really don't want any poster to be able to include the list, it would be easy enough to go through posting.php and disable that feature. Personally, I think this is quite useful, but the one thing I just simply ran out of steam on is that I really should have tried to make the list occupy 3 or 4 or 5 columns instead of sticking everyone in a single column.
...Probably the biggest "hmmm??" issue is one I'm sure you know about. It sure won't be easy to solve. That is, at the moment a user can insert multiple times. You than provide a 'Change Your Answers' button. This, of course, isn't going to change all of the submissions for the user. Again, no easy way to fix this without a major bit of work, that I can see, but it's still probably an issue to address in some way-future version...

Interesting you say this. How can a user multiple insert? Once the user has answered the survey, the next time he goes to the topic he no longer has an option to 'Fill in Survey' but instead only has an option to 'Change your answers'. So a user should never be able to double up his entry in the results.

Having said that, I did notice initially during testing that an occassional user ended up with two entries rather than one in the results of a survey. I assumed this was the same problem as phpbb's native double post problem, and I addressed that by adding some javascript code in the template that is supposed to disable a user's ability to'submit' his answers once he has already submitted them. Are you saying you've found a way around the protection and it is still possible for users to inadvertently (or advertently ;) ) double post their initial answers? If so, how does that happen. I can certainly add some otherwise duplicative code checking for whether the person's answers already appear in the db each time that a set of new answers gets inserted into the db.

As I am typing this, it occurs to me that a user could have the survey answer form open in two separate windows at the same time. In that case I imagine if the user filled out and submitted both forms you would have that problem. Is that what you are talking about? Do you think it would be worthwhile for me to add code to guard against that?
...Nice job with the SQL. Seems about as non-bloating as it's going to get....

Thanks, but the truth is that I got lambasted (properly I think) at devshed for my approach. By concatenating different things in a single field (e.g. all 8 answers), I've made things pretty inflexible and when I need to add new features it is more difficult to do it (and less efficient) than it would have been if I had kept each little piece in its own field. In my defense, I'm still pretty new to all of this (I had never heard of mysql or php until a year ago) and I simply didn't know any better :roll:
...Lastly, (and shame on whoever validated this MOD).... you have hard-coded ENGLISH within .tpl files. This is a major no-no ;) You have within (posting_body.tpl) the following hard-coded: "Click here to access or hide survey design box". This is something the MOD validators should have caught before it went public, but you should probably fix this for international users....

Yikes, I am usually pretty careful with putting language in the right place. I'll pick that up in the next version. Did you find any other places where I blew it?

Thanks again for your extremely helpful input.

AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

asinshesq wrote: Interesting you say this. How can a user multiple insert? Once the user has answered the survey, the next time he goes to the topic he no longer has an option to 'Fill in Survey' but instead only has an option to 'Change your answers' .... I addressed that by adding some javascript code in the template that is supposed to disable a user's ability to'submit' his answers once he has already submitted them .... Are you saying you've found a way around the protection and it is still possible for users to inadvertently (or advertently ;) ) double post their initial answers? If so, how does that happen. I can certainly add some otherwise duplicative code checking for whether the person's answers already appear in the db each time that a set of new answers gets inserted into the db.


Yeah, I would do a quick method like this:
Just before the INSERT statement, do a SELECT statement, matching the user_id and the survey_id and maybe even the thread_id too (??) to see if an entry already exists. Than it's a simple IF/ELSE. This is probably the easiest way to solve this issue.
asinshesq wrote: As I am typing this, it occurs to me that a user could have the survey answer form open in two separate windows at the same time. In that case I imagine if the user filled out and submitted both forms you would have that problem. Is that what you are talking about? Do you think it would be worthwhile for me to add code to guard against that?


For me, it was a matter of going back one page, than resubmitting it. ;)
asinshesq wrote:
...Nice job with the SQL. Seems about as non-bloating as it's going to get....

Thanks, but the truth is that I got lambasted (properly I think) at devshed for my approach.


Hmm, I can take another look at it... I was tired and ready for bed when I first looked at the sql. But, as I recall, it was good enough for most standards :D
asinshesq wrote:
...Lastly, (and shame on whoever validated this MOD).... you have hard-coded ENGLISH within .tpl files. This is a major no-no ;) You have within (posting_body.tpl) the following hard-coded: "Click here to access or hide survey design box". This is something the MOD validators should have caught before it went public, but you should probably fix this for international users....

Yikes, I am usually pretty careful with putting language in the right place. I'll pick that up in the next version. Did you find any other places where I blew it?


That was probably the biggest boo-boo I found. I did not spend any time looking for sql injection and such security issues. It looked interesting and I felt like giving it a try. The forementioned issues are just what I came across while installing it :)
asinshesq wrote: Thanks again for your extremely helpful input.


You are most welcome! Again, a hell of a lot more work than I'd have ever done. Outstanding! :mrgreen:

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

AbelaJohnB wrote: ...For me, it was a matter of going back one page, than resubmitting it. ;)


Right, same thing as having two windows open ... in either case the template is open with a hidden field signaling that the user has not yet answered the survey so that this is an initial response rather than an updated changed response. Thanks for pointing that out...I'll probably post a simple fix later today if I have a chance to do it.
AbelaJohnB wrote: ...Hmm, I can take another look at it... I was tired and ready for bed when I first looked at the sql. But, as I recall, it was good enough for most standards :D

The sql by itself is fine. What the gurus didn't like was my 'clever' idea of packing up to eight questions or answers into a single field separated by '|'. Works perfectly for the basic setup, but their criticism (correct I think) is that if I want to add new features in the future that becomes more challenging (and the code required to do it becomes slower) than would be the case if I kept each field simple. I ran into a perfect example of the fairness of their criticism when I added the feature that allows the designer of the survey to specify that responses could be sorted by the answer given in a particular column (so that for example I could have it sort the yes's in one place followed by the no's). In order to do that given the way I had stored the answers, I had to use code that in effect unpacks the answers in order to sort them...more coding energy (and inherently less efficient) than would have been the case if I had simply been able to add an 'ORDER BY' line in the query.
AbelaJohnB wrote: ...Lastly, (and shame on whoever validated this MOD).... you have hard-coded ENGLISH within .tpl files. This is a major no-no ;) You have within (posting_body.tpl) the following hard-coded: "Click here to access or hide survey design box". This is something the MOD validators should have caught before it went public, but you should probably fix this for international users....
asinshesq wrote:Yikes, I am usually pretty careful with putting language in the right place. I'll pick that up in the next version. Did you find any other places where I blew it?


That was probably the biggest boo-boo I found. I did not spend any time looking for sql injection and such security issues. It looked interesting and I felt like giving it a try. The forementioned issues are just what I came across while installing it :)

This was (I think) the first validation this validator had done and he was very very careful on sql injection and security issues (we had a number of discussions about that). And to be fair he was really trying to get a second opinion overall but people were really tied up and I was steadily pressuring him to go ahead and release it (my bad). And the text in the template was a bit subtle anyway since I had in fact already added the {L_...} entry in the template but simply forgot to take out the text and move it to lang_eng with an assignment in posting.php.

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

announcing version 1.0.7...

Post by asinshesq »

OK, I just added a new option that allows the designer of the survey to decide whether the answers should be displayed with one, two or three spaces between them. This is especially useful for surveys where people answer with answers that are more than one line long...I like single space for simple surveys where all questions are one line since that looks very organized but I like double or triple space for surveys where answers take up more than one line. Example: Suppose you start a survey asking for people's addresses and other contact info in order to use the mod to create an address list that will appear at the topic head...that kind of list needs to be double spaced or triple spaced between answers in order to look reasonably neat.

And as long as I was doing another version, I took the time to follow the suggestions that AbelaJohnB had given in previous posts. Here's an upgrade script if you want to have the latest and greatest (it does install with easymod).

I plan to submit that for validation in about a week (so that I can reflect any problems that anyone might come up with before then).

[edit: code omitted since you can download the upgrade script from a link in this post: http://www.phpbb.com/phpBB/viewtopic.ph ... 31#1566631 ]
Last edited by asinshesq on Mon May 09, 2005 11:43 am, edited 4 times in total.

helluvaguy
Registered User
Posts: 155
Joined: Fri Sep 07, 2001 12:06 pm

Post by helluvaguy »

This mod sounds very interesting, but to fully understand I would like to ask a few questions.
  1. Is the permission solely linked to the permission to create and participate in votes? So everybody who is allowed to start a vote can start a survey?
    If this is so, would it be a better idea to make it something you can grant permissions independently of the votes.
  2. The way it is now, could there be a survey AND a vote or is it only one of them per topic?
  3. Is a survey marked like [Survey] in the vieforum.php?

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

helluvaguy wrote: ...Is the permission solely linked to the permission to create and participate in votes? So everybody who is allowed to start a vote can start a survey? If this is so, would it be a better idea to make it something you can grant permissions independently of the votes....


I chose to tie rights to the right to create a poll since it's hard for me to see the difference. A survey IS a poll ... just a much more powerful one than the one that comes with phpbb. But if you want to tie it to something else it is easy enough to hack. For example, you could really easily allow only admins to use it. (Again, I don't see why you would want to tie to anything other than poll creation rights since this is effectively a poll.)
helluvaguy wrote: ...The way it is now, could there be a survey AND a vote or is it only one of them per topic?


Yes, you could have both but here again I think that would be a bit nonsensical...the survey is a poll so anything you wanted to ask in the poll you could ask in the survey instead. And yes, you can make it anonymous if you want (there is an option to NOT list the responders).
helluvaguy wrote: ...Is a survey marked like [Survey] in the vieforum.php?[/list]


No it's not. I will consider adding that kind of a marking in some future version. Shouldn't be too hard to do.

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

helluvaguy wrote: ...Is a survey marked like [Survey] in the vieforum.php?[/list]


I liked your suggestion so much that I went ahead and folded it into the upgrade to 1.0.7 script I posted above. For anyone who already installed the upgrade to 1.0.7 script I posted last night before I made this change, here are the only changes needed to implement helluvaguy's suggestion:

Code: Select all

OPEN
viewforum.php

FIND
		if( $topic_rowset[$i]['topic_vote'] )
		{
			$topic_type .= $lang['Topic_Poll'] . ' ';
		}

AFTER, ADD		
		if( $topic_rowset[$i]['topic_survey'] )
		{
			$topic_type .= $lang['Topic_Survey'] . ' ';
		}
		
OPEN
lang_english/lang_main.php

FIND
// end mod survey at topic head

BEFORE, ADD
$lang['Topic_Survey'] = '<b>[ Survey ]</b>';
FYI, I also folded into the upgrade to 1.0.7 script posted above the following totally nonsubstantive change to posting.php just to get rid of unnecessary parenthesis:

Code: Select all

#
#-----[ FIND ]------------------------------------------
#
if( ( $mode == 'newtopic' || ( $post_data['first_post']) ) && $is_auth['auth_pollcreate'] )

#
#-----[ REPLACE WITH ]------------------------------------------
#
if( ( $mode == 'newtopic' || $post_data['first_post'] ) && $is_auth['auth_pollcreate'] ) 
Last edited by asinshesq on Mon Apr 25, 2005 12:56 pm, edited 1 time in total.

helluvaguy
Registered User
Posts: 155
Joined: Fri Sep 07, 2001 12:06 pm

Post by helluvaguy »

asinshesq wrote:
helluvaguy wrote:...Is the permission solely linked to the permission to create and participate in votes? So everybody who is allowed to start a vote can start a survey? If this is so, would it be a better idea to make it something you can grant permissions independently of the votes....


I chose to tie rights to the right to create a poll since it's hard for me to see the difference. A survey IS a poll ... just a much more powerful one than the one that comes with phpbb. But if you want to tie it to something else it is easy enough to hack. For example, you could really easily allow only admins to use it. (Again, I don't see why you would want to tie to anything other than poll creation rights since this is effectively a poll.)

I would agree that there might not be a big differnce in a vote and a survey. But as you yourself pointed out its more powerful.
Due to the experience I had with my users, I have those who are "frightend" by an extra option to choose from on their way to post a topic, and those who are "dumb as hell" and (unintentionally) mess everything up. So in my case I would prefer to let only see Mods the oportunity for such a survey.

But for now I just try to integrate it in my forum and see how it's doing in full action.

I'm glad you liked the idea about the [Survey] marking well enough to build it in. Thank you.

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

helluvaguy wrote: ...I would agree that there might not be a big differnce in a vote and a survey. But as you yourself pointed out its more powerful.
Due to the experience I had with my users, I have those who are "frightend" by an extra option to choose from on their way to post a topic, and those who are "dumb as hell" and (unintentionally) mess everything up. So in my case I would prefer to let only see Mods the oportunity for such a survey...


OK, that one is easy. Here's what to do to posting.php if you want only admins and mods to be able to post surveys:

Code: Select all

FIND
if( ( $mode == 'newtopic' || $post_data['first_post'] ) && $is_auth['auth_pollcreate'] )

REPLACE WITH
if( ( $mode == 'newtopic' || $post_data['first_post'] ) && $userdata['user_level'] >= ADMIN )
[note that if you haven't yet used the upgrade script I posted above (which now deletes a couple of unecessary parenthesis as I mentioned in my last post before this one) the FIND will be slightly different]

helluvaguy
Registered User
Posts: 155
Joined: Fri Sep 07, 2001 12:06 pm

Post by helluvaguy »

Code: Select all

REPLACE WITH
if( ( $mode == 'newtopic' || $post_data['first_post'] ) && $userdata['user_level'] >= ADMIN )
For some reason, if I do this I can't choose groops, because they are not visible as aren't the questions. Any idea why?

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

helluvaguy wrote:

Code: Select all

REPLACE WITH
if( ( $mode == 'newtopic' || $post_data['first_post'] ) && $userdata['user_level'] >= ADMIN )
For some reason, if I do this I can't choose groops, because they are not visible as aren't the questions. Any idea why?


Do you mean that you properly see the link but when you click it you don't see the full survey form? If so, try another new post and see if the problem continues.

Post Reply

Return to “[2.0.x] MOD Database Releases”