Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Poll Mod v2.0.8

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Davio Posted - 30 October 2006 : 21:22:07
Poll Mod Version: 2.0.8
Current Author: Davio
Original Author: Slemieux
Last Modified: October 30, 2006
For Snitz Version: 3.4.06

Description:
This version is a new and upgraded version from the pervious ones. With new features and lots of bug fixes. View the list of changes I have made in the list below. I hope everyone enjoys the new poll mod as much as I enjoyed working on it (yeah right).
Thanks for your patience.

This update is mainly bug fixes and made compatible with Snitz FOrums 3.4.06.

Ease of Installation (1-Easy, 10-Hard): 8

Downloads:
3.4 Version
Main Link: http://www.snitzbitz.com/mods/details.asp?Version=All&mid=76
Updated Files Only: http://www.snitzbitz.com/mods/details.asp?Version=All&mid=76

Demo: http://www.dsilvera.com/forum/


Version 2.0.8 (October 3, 2006)
  • Updated files with latest forum version, 3.4.06.

  • Fixed bug in pop_poll.asp that allowed everyone to vote in a members only poll. (Ref.: Topic #62378)

  • Fixed bug in pop_poll.asp where vote results where not updated after a user voted. (Ref.: Topic #62378)

  • Fixed bug in inc_poll.asp where clicking on the View Results button did not take you to the results. (Ref.: Topic #62406)
Modified Files: pop_poll.asp, inc_poll.asp (for bug fixes only)


Version 2.0.7.01 (November 30, 2003)
  • Fixed bug when you use a quote in the poll answers, it comes out as 2 quotes instead.
Modified Files: post_info.asp


Version 2.0.7 (October 25, 2003)
  • Fixed bug when you delete a poll the poll data is not removed from the poll tables in the database.
Modified Files: pop_delete.asp

INSTALLATION/UPGRADE:
Please read the readme.html file that is included. It also includes a FAQ section to common questions that you might ask about the mod.

SUPPORT:
If you have any problems please post them in the Help: MOD Implementation forum. DO NOT ASK FOR HELP OR POST YOUR ERROR MESSAGES IN THIS TOPIC!!


Poll Mod Add-On!
Also check out the Site Poll Mod. It allows you to put your featured forum poll on your website.
http://forum.snitz.com/forum/topic.asp?TOPIC_ID=40335<
15   L A T E S T    R E P L I E S    (Newest First)
ruirib Posted - 30 April 2009 : 18:01:02
Althought not needed, a clustered index for POLL_ID in table Polls won't hurt and then another clustered on for POLL_ID,Order in Answers. Don't think you will have that many polls, so this should be enough...
SiSL Posted - 30 April 2009 : 14:07:18
I think have to add good indexes to that too :P like my previous problem :)

PS: I'm such a mess code-writer, I guess it is like coding but not able to express what you did after :p Anarchic :)
SiSL Posted - 30 April 2009 : 14:01:07
quote:
Originally posted by ruirib

ANSWER_ORDER should not be nullable.



Could be changed to that too :)
ruirib Posted - 30 April 2009 : 14:00:01
ANSWER_ORDER should not be nullable.
SiSL Posted - 30 April 2009 : 13:59:49
Okay, went through this, this might give an idea about it :) I showed in RED where I commented out
SiSL Posted - 30 April 2009 : 13:56:38
POST_INFO.asp

'############################ Poll Mod ##############################
		if Request.Form("poll") = "1" then
			strSql = "SELECT " & strTablePrefix & "TOPICS.TOPIC_ID "
			strSql = strSql & "FROM " & strTablePrefix & "TOPICS "
			strSql = strSql & "WHERE " & strTablePrefix & "TOPICS.T_ISPOLL = " & 1 & " "
			strSql = strSql & "ORDER BY " & strTablePrefix & "TOPICS.T_DATE DESC"
			set rsPollID = my_Conn.Execute (strSql)
			
			PollID = rsPollID("TOPIC_ID")
			
			rsPollID.close
			set rsPollID = nothing		
			
			'## Forum_SQL - Add new poll to Polls Table
			strSql = "INSERT INTO " & strTablePrefix & "POLLS (CAT_ID"
			strSql = strSql & ", FORUM_ID"
			strSql = strSql & ", TOPIC_ID"
			strSql = strSql & ", P_WHOVOTES"
			'for i = 1 to ubound(txtAns)
			'	strSql = strSql & ", ANSWER" & CStr(i)
			'	strSql = strSql & ", COUNT" & CStr(i)
			'next
			strSql = strSql & ") VALUES ("
			strSql = strSql & Cat_ID
			strSql = strSql & ", " & Forum_ID
			strSql = strSql & ", " & PollID
			strSql = strSql & ", '" & chkString(Request.Form("WhoVotes"),"SQLString") & "'"
			'for i = 1 to ubound(txtAns)
			'	strSql = strSql & ", '" & chkString(txtAns(i),"") & "'"
			'	strSql = strSql & ", " & 0
			'next
			strSql = strSql & ")"
			
			strSql = strSql & ""
			For i=1 to UBound(txtAns)
				if Trim(txtAns(i)) <> "" Then
					strSql = strSql & ";INSERT INTO " & strTablePrefix & "POLL_ANSWERS (POLL_ID, ANSWER_TEXT, ANSWER_ORDER, ANSWER_COUNT) VALUES ("
					strSql = strSql & PollID & ", '" &  chkString(txtAns(i),"SQLString") & "'," & i & ", " & 0 & ")"
				Else
					exit for
				End If
			next
			my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
		end if
   '####################################################################


Also in POST_INFO.ASP

'############################ Poll Mod ###################################
		if Request.Form("poll") = "1" then
			'### Update poll answers and counts
			strSql = "SELECT ANSWER_COUNT FROM " & strTablePrefix & "POLL_ANSWERS WHERE POLL_ID=" & Topic_ID & " ORDER BY ANSWER_ORDER ASC"
			set rs=my_Conn.Execute(strSql)
			if not rs.EOF Then
				tumPolls = rs.GetRows
				toplamPAnswers = UBound(tumPolls,2) + 1
			Else
				toplamPAnswers = 0
			End If
			rs.Close
			set rs=nothing
			
			strSql = "UPDATE " & strTablePrefix & "POLLS "
			strSql = strSql & " SET P_WHOVOTES = '" & chkString(Request.Form("WhoVotes"),"SQLString") & "', "
			strSql = strSql & " 		CAT_ID = " & cLng(aryForum(0)) & ", "
			strSql = strSql & "		FORUM_ID = " & cLng(aryForum(1)) & " "
			'for i = 1 to CInt(Request.Form("count"))
			'	strSql = strSql & "ANSWER" & CStr(i) & " = '" & chkString(txtAns(i),"") & "'"
			'	if txtAns(i) = "" or chkString(Request.Form("resetpoll"),"SQLString") = "1" then
			'		strSql = strSql & ", COUNT" & CStr(i) & " = " & 0
			'	end if
			'	if ubound(txtAns) <> i then
			'		strSql = strSql & ", "
			'	end if
			'next
			strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
			my_Conn.Execute(strSql),,adCmdText + adExecuteNoRecords
			
			strSQL = "DELETE FROM " & strTablePrefix & "POLL_ANSWERS WHERE POLL_ID = " & Topic_ID
			my_Conn.Execute(strSQL)
			strSQL = ""
			for i=1 to CInt(Request.Form("count"))
			if Trim(chkString(txtAns(i),"")) <> "" Then
				strSQL = strSQL & "INSERT INTO " & strTablePrefix & "POLL_ANSWERS (POLL_ID, ANSWER_TEXT, ANSWER_ORDER, ANSWER_COUNT) VALUES ("
				strSQL = strSQL & Topic_ID & ", "
				strSQL = strSQL & "'" & chkString(txtAns(i),"SQLString") & "', "
				strSQL = strSQL & i & ","
				if chkString(Request.Form("resetpoll"),"SQLString") = "1" then
					strSQL = strSQL & 0
				Else
					if i <= toplamPAnswers Then
						z = i-1
						strSQL = strSQL & tumPolls(0,z)
						
					Else
						strSQL = strSQL & 0
					End If	
				End If
			Else
				Exit for					
			End If
			strSql = strSql & ");"
			next
			
			my_Conn.Execute(strSql),,adCmdText + adExecuteNoRecords
			if Request.Form("resetpoll") = "1" then
				'### Delete poll votes from POLL_VOTES table for this topic
				strSql = "DELETE FROM " & strTablePrefix & "POLL_VOTES "
				strSql = strSql & "WHERE " & strTablePrefix & "POLL_VOTES.TOPIC_ID = " & Topic_ID
				my_Conn.Execute(strSql),,adCmdText + adExecuteNoRecords
			end if
		end if
	'#########################################################################



SiSL Posted - 30 April 2009 : 13:54:07
POST.ASP

' ############################## Poll Mod ################################
	if Request.QueryString("poll") = "1" then
		'### Get poll from POLLS table
		strSql = "SELECT " & strTablePrefix & "POLLS.P_WHOVOTES "
		' CAREFUL FOR COMMAS
		'for i = 1 to 15
		'	strSql = strSql & strTablePrefix & "POLLS.ANSWER" & CStr(i) & ", "
		'	strSql = strSql & strTablePrefix & "POLLS.COUNT" & CStr(i)
		'	if i <> 15 then
		'		strSql = strSql & ", "
		'	end if
		'next
		strSql = strSql & " FROM " & strTablePrefix & "POLLS"
		strSql = strSql & " WHERE " & strTablePrefix & "POLLS.TOPIC_ID = " & strRqTopicID
		set rsPoll = my_Conn.Execute (strSql)
		
		if rsPoll.EOF or rsPoll.BOF then
			Go_Result "You are trying to edit a topic that is not a poll"
		else
			strWhoVotes = rsPoll("P_WHOVOTES")
			' I think I also removed something from here?
		end if
		rsPoll.Close
		set rsPoll = nothing
		
		strSql = "SELECT ANSWER_TEXT "
		strSql = strSql & " FROM " & strTablePrefix & "POLL_ANSWERS "
		strSql = strSql & " WHERE POLL_ID = " & strRqTopicID & " ORDER BY ANSWER_ORDER ASC"
		set rsPoll = my_Conn.Execute (strSql)
		
		if rsPoll.EOF or rsPoll.BOF then
			Go_Result "You are trying to edit a topic that is not a poll"
		else
			nTotal = 0
			ReDim txtAns(15)
			tumPollAnswers = rsPoll.GetRows
			For i=0 to UBound(tumPollAnswers,2)
				z = i+1
				txtAns(z) = tumPollAnswers(0,i)
				nTotal = nTotal + 1
			Next
			
			if CInt(strMaxVotes) > nTotal then
				nCount = strMaxVotes
			else
				nCount = nTotal
			end if
		end if
		rsPoll.Close
		set rsPoll = nothing
		
	end if
' ############################################################
SiSL Posted - 30 April 2009 : 13:49:41
Ok, here goes

topic.asp, I changed as following:

DB as following DB Name: strTablePrefix & "POLL_ANSWERS"


POLL_ID (int, not null)
ANSWER_TEXT (nvarchar(255), null)
ANSWER_ORDER (int, not null)
COUNT (default value=0, int, not null)

This is SQL Server version, using GetRows, would be nice if someone know how to apply it to Access and such.




	'############## Poll Mod ##################
	IsPoll = rsTopic("T_ISPOLL")
	Forum_Polls = rsTopic("F_POLLS")
	Poll_Status = rsTopic("T_POLLSTATUS")
	
	if IsPoll = 1 then
		
		strSql = "SELECT P.P_LASTVOTE, P.P_WHOVOTES"
		' Also removed commas , careful on that
                'For i = 1 To 15
		'	strSql = strSql & ", P.ANSWER" & CStr(i)
		'	strSql = strSql & ", P.COUNT" & CStr(i)
		'Next
		strSql = strSql & " FROM " & strTablePrefix & "POLLS P"
		strSql = strSql & " WHERE P.TOPIC_ID = " & Topic_ID

		set rsPoll = Server.CreateObject("ADODB.Recordset")
		rsPoll.Open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
		
		if not(rsPoll.EOF) or not(rsPoll.BOF) then
			Last_Vote = rsPoll("P_LASTVOTE")
			strWhoVotes = rsPoll("P_WHOVOTES")
			rsPoll.Close
			set rsPoll = nothing
			
			strSQL = "SELECT ANSWER_TEXT, ANSWER_COUNT FROM " & strTablePrefix & "POLL_ANSWERS WHERE POLL_ID=" & Topic_ID
			set rsPoll = Server.CreateObject("ADODB.Recordset")
			rsPoll.Open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
			if not rsPoll.EOF or rsPoll.BOF Then
				tumPoll = rsPoll.GetRows
				For i=0 to UBound(tumPoll,2)
					z = i+1
					vAnswers(z) = tumPoll(0,i)
					vCount(z) = tumPoll(1,i)
					
				Next
			End If
		
		end if
		
		rsPoll.Close
		set rsPoll = nothing
		end if
		if IsPoll = 1 then
			pollLink = "poll=1&"
			
		else
			pollLink = ""
		end if
	'##########################################



Also in another Poll mod marked places inside I changed a few lines starting with if to end...

if nNumber <> -1 then
				'## Forum_SQL - 
				strSql = "UPDATE " & strTablePrefix & "POLLS "
				strSql = strSql & " SET  P_LASTVOTE = '" & DateToStr(strForumTimeAdjust) & "'"
				strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
			
				my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
				
				strSql = "UPDATE " & strTablePrefix & "POLL_ANSWERS "
				strSql = strSql & "  SET ANSWER_COUNT = ANSWER_COUNT+1"
				strSql = strSql & " WHERE POLL_ID = " & Topic_ID & " AND ANSWER_ORDER = " & nNumber
			
				my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
				
				Voted = true
				
				'## Forum_SQL -
				strSql = "SELECT " & strTablePrefix & "POLLS.P_LASTVOTE"
				'For i = 1 To 15
				'	strSql = strSql & ", " & strTablePrefix & "POLLS.ANSWER" & CStr(i) 
				'	strSql = strSql & ", " & strTablePrefix & "POLLS.COUNT" & CStr(i)
				'Next
				strSql = strSql & " FROM " & strTablePrefix & "POLLS"
				strSql = strSql & " WHERE " & strTablePrefix & "POLLS.TOPIC_ID = " & Topic_ID
				
				set rsPoll = Server.CreateObject("ADODB.Recordset")
				rsPoll.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
				
				Last_Vote = rsPoll("P_LASTVOTE")
				rsPoll.Close
				set rsPoll = nothing
				strSQL = "SELECT ANSWER_TEXT, ANSWER_COUNT FROM " & strTablePrefix & "POLL_ANSWERS WHERE POLL_ID=" & Topic_ID
				set rsPoll = Server.CreateObject("ADODB.Recordset")
				rsPoll.Open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
				if not rsPoll.EOF or rsPoll.BOF Then
				tumPoll = rsPoll.GetRows
				For i=0 to UBound(tumPoll,2)
					z = i+1
					vAnswers(z) = tumPoll(0,i)
					vCount(z) = tumPoll(1,i)
					
				Next
			End If
				
				rsPoll.Close
				set rsPoll = nothing
			
				Call UpdateVote("0", MemberID, Topic_ID, Forum_ID, Cat_ID)
			end if
ruirib Posted - 30 April 2009 : 12:45:20
Indeed, archiving just means archiving the topic.
SiSL Posted - 30 April 2009 : 12:40:08
quote:
Originally posted by modifichicci

Don't forget the archive function as well...



I dont think Archieve would have anything to do with other tables, since Poll ID is unique and equals to Topic Id.
ruirib Posted - 30 April 2009 : 11:04:59
I could have written a nice little SQL Server script for migration, if you had told me so. Not hard, using cursors. Can't say the same for Access and MySQL, cause it would needed to be done using asp.
ruirib Posted - 30 April 2009 : 10:59:25
Watch out the indexing, if you have a few polls...
modifichicci Posted - 30 April 2009 : 10:44:02
Don't forget the archive function as well...
SiSL Posted - 30 April 2009 : 09:52:56
quote:
Originally posted by ruirib

Yeah, guess you can have order and poll_id as the primary key for the POLL_ANSWER table. The poll mod code will have to be redone for this, of course. "Hardest" thing will be the form to create a poll, since the number of answers will now be variable. Probably using a list instead of fixed text fields would be a better option.



I still limit it to 15, like + and - signs... (I dont find it reasonable or logical to allow unlimited number of polls) So on For Next, if it sees an empty answer, exits for... And limits the poll like that.

However, database will be a lot lighter...
IMO, hardest (well, not hardest, but still need work) part would be "updating" records...

So I went a way to Take all counts of Poll -> Delete answers entirely -> Insert again mode (for empty responses or old stuff not to remain there) and not sure if there is faster way to do that...

I think it works fine on my test server now, also updated pop_delete for that as well (but for Category or Forum deletions, I need to work on it more, but heck, I dont delete cats or forums that much eheh) Most likely I can not make it into a mod, since my poll mod is also modded a lot, but principles remains same.
ruirib Posted - 30 April 2009 : 09:33:56
Yeah, guess you can have order and poll_id as the primary key for the POLL_ANSWER table. The poll mod code will have to be redone for this, of course. "Hardest" thing will be the form to create a poll, since the number of answers will now be variable. Probably using a list instead of fixed text fields would be a better option.

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000 Version 3.4.07