已经有新版本,免去繁琐的修改~
https://discuz.dismall.com/thread-613241-1-1.html
请不要安装本主题内的~
一个能让会员发调查问卷帖的功能,也可以实现简单的答题记分功能。
修改步骤比较烦琐,建议大家在本地测试通过后再安装。
1楼,2楼为主要安装步骤,3楼为可选修改,4楼是简单的使用帮助。
升级数据库:
- CREATE TABLE `cdb_question` (
- `tid` int(10) unsigned NOT NULL,
- `exp` int(10) NOT NULL default '0',
- `price` mediumint(8) NOT NULL default '0',
- `persons` mediumint(8) NOT NULL default '20',
- `stop` tinyint(1) NOT NULL default '0',
- `submitmore` tinyint(1) NOT NULL default '0',
- PRIMARY KEY (`tid`)
- ) ENGINE=MyISAM;
- CREATE TABLE `cdb_questionoption` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `tid` int(10) unsigned NOT NULL,
- `type` text NOT NULL default '',
- `check` mediumtext NOT NULL default '',
- `question` mediumtext NOT NULL default '',
- `key` mediumtext NOT NULL default '',
- `open` tinyint(1) NOT NULL default '1',
- `mark` mediumint(8) NOT NULL default '0',
- `answermust` tinyint(1) NOT NULL default '1',
- `answeruser` mediumtext NOT NULL default '',
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM;
- CREATE TABLE `cdb_questionlog` (
- `uid` int(10) unsigned NOT NULL default '0',
- `username` varchar(255) NOT NULL default '',
- `dateline` int(10) NOT NULL default '0',
- `tid` int(10) unsigned NOT NULL,
- `id` int(10) unsigned NOT NULL default '0',
- `answer` mediumtext NOT NULL default '',
- `mark` mediumint(8) NOT NULL default '0',
- KEY (`uid`)
- ) TYPE=MyISAM;
- ALTER TABLE `cdb_usergroups` ADD `allowpostquestion` tinyint(1) NOT NULL default '1';
- ALTER TABLE `cdb_usergroups` ADD `submit` tinyint(1) NOT NULL default '1';
- ALTER TABLE `cdb_usergroups` ADD `maxpriceq` mediumint(8) NOT NULL default '0';
- ALTER TABLE `cdb_usergroups` ADD `maxpersons` mediumint(8) NOT NULL default '25';
复制代码
打开admincp.lang.php
找到:
- 'usergroups_special_activity' => '允许发起活动:',
复制代码
在上面加:
- 'forums_thread_question' => '问卷主题',
- 'usergroups_special_question' => '允许发起问卷:',
- 'usergroups_special_question_comment' => '选择“是”允许在论坛发布问卷主题',
- 'usergroups_special_maxprice' => '最大奖励积分:',
- 'usergroups_special_maxprice_comment' => '设置提交问卷奖励积分的最大值,禁止设置积分请设置为0',
- 'usergroups_special_maxpersons' => '问卷最大调查人数:',
- 'usergroups_special_maxpersons_comment' => '最大调查人数,超过该人数时问卷将被停止',
- 'usergroups_special_submit' => '允许重复提交问卷:',
- 'usergroups_special_submit_comment' => '选择“是”允许同一个人提交同一份问卷多次',
复制代码
打开admin/groups.inc.php
找到:
- showsetting('usergroups_special_activity', 'allowpostactivitynew', $group['allowpostactivity'], 'radio');
复制代码
在上面加:
- showsetting('usergroups_special_question', 'allowpostquestionnew', $group['allowpostquestion'], 'radio');
- showsetting('usergroups_special_submit', 'submitnew', $group['submit'], 'radio');
- showsetting('usergroups_special_maxprice', 'maxpriceqnew', $group['maxpriceq'], 'text');
- showsetting('usergroups_special_maxpersons', 'maxpersonsnew', $group['maxpersons'], 'text');
复制代码
找到:
- grouptitle='$grouptitlenew',
复制代码
在后面加:
- submit='$submitnew',maxpriceq='$maxpriceqnew',maxpersons='$maxpersonsnew',allowpostquestion='$allowpostquestionnew',
复制代码
打开admin/forums.inc.php
找到:
- $forum['allowpostspecial'] = sprintf('%04b', $forum['allowpostspecial']);
- for($i = 1; $i <= 4; $i++) {
- $checkpostspecial[$i] = $forum['allowpostspecial'][4 - $i] ? 'checked' : '';
- }
复制代码
替换成:
- $forum['allowpostspecial'] = sprintf('%05b', $forum['allowpostspecial']);
- for($i = 1; $i <= 5; $i++) {
- $checkpostspecial[$i] = $forum['allowpostspecial'][5 - $i] ? 'checked' : '';
- }
复制代码
找到:
- .'<br><input class="checkbox" type="checkbox" name="allowpostspecialnew[4]" value="1" '.$checkpostspecial[4].'>'.$lang['forums_thread_activity']
复制代码
在后面加:
- .'<br><input class="checkbox" type="checkbox" name="allowpostspecialnew[5]" value="1" '.$checkpostspecial[5].'>'.$lang['forums_thread_question']
复制代码
找到:
- $allowpostspecialnew = bindec(intval($allowpostspecialnew[4]).intval($allowpostspecialnew[3]).intval($allowpostspecialnew[2]).intval($allowpostspecialnew[1]));
复制代码
替换成:
- $allowpostspecialnew = bindec(intval($allowpostspecialnew[5]).intval($allowpostspecialnew[4]).intval($allowpostspecialnew[3]).intval($allowpostspecialnew[2]).intval($allowpostspecialnew[1]));
复制代码
在post.php,viewthread.php,forumdisplay.php(forumdisplay.php的修改有点不同,自己看着改)做同样的修改:
找到:
- $allowpostpoll = $allowpost && $allowpostpoll && substr(sprintf('%04b', $forum['allowpostspecial']), -1, 1);
- $allowposttrade = $allowpost && $allowposttrade && substr(sprintf('%04b', $forum['allowpostspecial']), -2, 1);
- $allowpostreward = $allowpost && $allowpostreward && substr(sprintf('%04b', $forum['allowpostspecial']), -3, 1) && isset($extcredits[$creditstrans]);
- $allowpostactivity = $allowpost && $allowpostactivity && substr(sprintf('%04b', $forum['allowpostspecial']), -4, 1);
复制代码
替换成:
- $allowpostpoll = $allowpost && $allowpostpoll && substr(sprintf('%05b', $forum['allowpostspecial']), -1, 1);
- $allowposttrade = $allowpost && $allowposttrade && substr(sprintf('%05b', $forum['allowpostspecial']), -2, 1);
- $allowpostreward = $allowpost && $allowpostreward && substr(sprintf('%05b', $forum['allowpostspecial']), -3, 1) && isset($extcredits[$creditstrans]);
- $allowpostactivity = $allowpost && $allowpostactivity && substr(sprintf('%05b', $forum['allowpostspecial']), -4, 1);
- $allowpostquestion = $allowpost && $allowpostquestion && substr(sprintf('%05b', $forum['allowpostspecial']), -5, 1) && isset($extcredits[$creditstrans]);
复制代码
在forumdisplay.htm,viewthread.htm中做同样的修改
找到:
- <!--{if ($allowposttrade && $ec_id) || $allowpostpoll || $allowpostreward || $allowpostactivity || !$discuz_uid}-->
- <div class="popupmenu_popup newspecialmenu" id="newspecialheader_menu" style="display: none">
- <table cellpadding="4" cellspacing="0" border="0" width="100%">
- <!--{if $allowpostpoll || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&poll=yes">{lang thread_poll}</a></div></td></tr><!--{/if}-->
- <!--{if ($allowposttrade && $ec_id) || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&trade=yes">{lang thread_trade}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostreward || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&reward=yes">{lang thread_reward}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostactivity || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&activity=yes">{lang thread_activity}</a></div></td></tr><!--{/if}-->
- </table></div>
复制代码
替换成:
- <!--{if ($allowposttrade && $ec_id) || $allowpostquestion || $allowpostpoll || $allowpostreward || $allowpostactivity || !$discuz_uid}-->
- <div class="popupmenu_popup newspecialmenu" id="newspecialheader_menu" style="display: none">
- <table cellpadding="4" cellspacing="0" border="0" width="100%">
- <!--{if $allowpostpoll || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&poll=yes">{lang thread_poll}</a></div></td></tr><!--{/if}-->
- <!--{if ($allowposttrade && $ec_id) || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&trade=yes">{lang thread_trade}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostreward || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&reward=yes">{lang thread_reward}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostactivity || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&activity=yes">{lang thread_activity}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostquestion || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&question=yes">问卷</a></div></td></tr><!--{/if}-->
- </table></div>
复制代码
找到:
- <!--{if ($allowposttrade && $ec_id) || $allowpostpoll || $allowpostreward || $allowpostactivity || !$discuz_uid}-->
- <div class="popupmenu_popup newspecialmenu" id="newspecialfooter_menu" style="display: none">
- <table cellpadding="4" cellspacing="0" border="0" width="100%">
- <!--{if $allowpostpoll || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&poll=yes">{lang thread_poll}</a></div></td></tr><!--{/if}-->
- <!--{if ($allowposttrade && $ec_id) || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&trade=yes">{lang thread_trade}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostreward || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&reward=yes">{lang thread_reward}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostactivity || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&activity=yes">{lang thread_activity}</a></div></td></tr><!--{/if}-->
- </table></div>
复制代码
替换成:
- <!--{if ($allowposttrade && $ec_id) || $allowpostquestion || $allowpostpoll || $allowpostreward || $allowpostactivity || !$discuz_uid}-->
- <div class="popupmenu_popup newspecialmenu" id="newspecialfooter_menu" style="display: none">
- <table cellpadding="4" cellspacing="0" border="0" width="100%">
- <!--{if $allowpostpoll || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&poll=yes">{lang thread_poll}</a></div></td></tr><!--{/if}-->
- <!--{if ($allowposttrade && $ec_id) || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&trade=yes">{lang thread_trade}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostreward || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&reward=yes">{lang thread_reward}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostactivity || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&activity=yes">{lang thread_activity}</a></div></td></tr><!--{/if}-->
- <!--{if $allowpostquestion || !$discuz_uid}--><tr><td class="popupmenu_option"><div class="newspecial"><a href="post.php?action=newthread&fid=$fid&extra=$extra&question=yes">问卷</a></div></td></tr><!--{/if}-->
- </table></div>
复制代码
打开forumdisplay.php
找到:
- $filteradd = 'AND special = 4';
复制代码
在下面加:
- } elseif($filter == 'question') {
- $forumdisplayadd .= "&filter=$filter";
- $filteradd = 'AND special = 5';
复制代码
找到:(多余的吗?)
- $showpoll = $showtrade = $showreward = $showactivity = 0;
复制代码
替换成:
- $showpoll = $showtrade = $showreward = $showactivity = $showquestion = 1;
复制代码
打开forumdisplay.htm
找到:
- <!--{if $thread['special'] == 4}-->
- <img src="{IMGDIR}/activitysmall.gif" alt="{lang thread_activity}" />
- <!--{/if}-->
复制代码
在下面加:
- <!--{if $thread['special'] == 5}-->
- <img src="{IMGDIR}/questionsmall.gif" alt="问卷" />
- <!--{/if}-->
复制代码
找到:
- <!--{if $showactivity}--><!--{if $filter == 'activity'}--><span class="bold">{lang thread_activity}</span><!--{else}--><a href="forumdisplay.php?fid=$fid&filter=activity">{lang thread_activity}</a><!--{/if}--><!--{/if}-->
复制代码
在下面加:
- <!--{if $showquestion}--><!--{if $filter == 'question'}--><span class="bold">问卷</span><!--{else}--><a href="forumdisplay.php?fid=$fid&filter=question">问卷</a><!--{/if}--><!--{/if}-->
复制代码
打开post_newthread.htm
找到:
- <!--{if isset($reward) && $allowpostreward}-->
复制代码
替换成:
- <!--{elseif isset($reward) && $allowpostreward}-->
复制代码
并在上面加:
- <!--{if isset($question) && $allowpostquestion}-->
- <input type="hidden" name="question" value="yes">
- <tr><td class="altbg1"><span class="bold">问卷有效天数</span></td><td class="altbg2"><input type="text" name="exp" value="0" size="6" tabindex="4"> <span class="smalltxt"> ({lang post_zero_is_nopermission})</span></td></tr>
- <tr><td class="altbg1"><span class="bold">问卷参与奖励积分</span></td><td class="altbg2"><input type="text" name="qprice" value="0" size="6" tabindex="4"> <span class="smalltxt"> (最高 $maxpriceq {$extcredits[$creditstrans][unit]})</span></td></tr>
- <tr><td class="altbg1"><span class="bold">最大调查人数</span></td><td class="altbg2"><input type="text" name="mpersons" value="$maxpersons" size="6" tabindex="4"> <span class="smalltxt"> (最多 $maxpersons 人次)</span></td></tr>
- <tr>
- <td class="altbg1" valign="top"><span class="bold">问卷选项</span><br>有权限参与投票的会员均可参与问卷调查<br><br>
- <input class="checkbox" type="checkbox" name="stop" value="1"> 暂停问卷<br>
- <input class="checkbox" type="checkbox" name="allowsubmit" value="1" <!--{if !$submit}-->disabled<!--{/if}-->> 允许重复提交<br>
- </td><td class="altbg2">
-
- <table cellspacing="1" cellpadding="6" width="100%" align="center" style="background: {BGBORDER}">
- <tr class="altbg1"><td colspan="2">
- <span class="bold">增加新选项</span> <a id="addqueslink" href="###" onclick="newnode = $('quesbodyhidden').firstChild.cloneNode(true); $('quesbody').appendChild(newnode)">[+]</a> <a id="addqueslink" href="###" onclick="$('quesbody').childNodes.length > 1 && $('quesbody').lastChild ? $('quesbody').removeChild($('quesbody').lastChild) : 0;">[-]</a>
- </td></tr>
- <tbody id="quesbodyhidden" style="display:none"><tr class="altbg1"><td width="100%">
- <select name="qtype[]"><option value="1">单选题目</option><option value="2">多选题目</option><option value="3">文字简答题</option><option value="4">文字叙述题</option></select>
- 分数: <input type="text" name="mark[]" size="10" value="0">
- <select name="amust[]"><option value="1">必答题</option><option value="0">选答题</option></select>
- 公开结果: <input type="checkbox" name="open[]" value="1" checked><br>
- <textarea rows="3" name="qoptions[]" style="width: 120px; word-break: break-all" tabindex="5"></textarea>
- <textarea rows="3" name="question[]" style="width: 250px; word-break: break-all" tabindex="5"></textarea>
- <textarea rows="3" name="answer[]" style="width: 320px; word-break: break-all" tabindex="5"></textarea>
- </td></tr></tbody>
- <tbody id="quesbody"><tr class="altbg1"><td width="100%">
- <select name="qtype[]"><option value="1">单选题目</option><option value="2">多选题目</option><option value="3">文字简答题</option><option value="4">文字叙述题</option></select>
- <span alt="仅用于在问卷中计算得分,不影响实际积分">分数:</span> <input type="text" name="mark[]" size="10" value="0">
- <select name="amust[]"><option value="1">必答题</option><option value="0">选答题</option></select>
- 公开结果: <input type="checkbox" name="open[]" value="1" checked><br>
- <textarea rows="3" name="qoptions[]" style="width: 120px; word-break: break-all" tabindex="5">请填写单选和多选类型题目的选项,一行一个选项</textarea>
- <textarea rows="3" name="question[]" style="width: 250px; word-break: break-all" tabindex="5">请填写你要描述的问题,这将有利于被调查人理解你的问题</textarea>
- <textarea rows="3" name="answer[]" style="width: 320px; word-break: break-all" tabindex="5">请填写你的答案,如果是选择题,请填写选项所在的行列数字,多选题请用半角','分割多个数字,一旦被调查人的答案与此相符将获得该题的分数</textarea>
- </td></tr></tbody>
- </table>
- </td>
- </tr>
复制代码
打开include/newthread.inc.php
找到:
在下面加:
- } elseif(isset($question)) {
- $special = 5;
复制代码
找到:
- } elseif($special == 4 && $allowpostactivity) {
- if(empty($starttimefrom[$activitytime])) {
复制代码
在上面加:
- } elseif($special == 5 && $allowpostquestion) {
- $q=array();
- $q['type']=$qtype;
- $q['mark']=$mark;
- $q['must']=$amust;
- $q['open']=$open;
- $q['options']=$qoptions;
- $q['question']=$question;
- $q['answer']=$answer;
- if($qprice > $maxpriceq)showmessage('积分不能过大,请返回');
- if(!$mpersons || $mpersons > $maxpersons)showmessage('最大限制人数不能过多或为空,请返回');
复制代码
找到:
- } elseif($special == 4 && $allowpostactivity) {
- $db->query("INSERT INTO {$tablepre}activities (tid, uid, cost, starttimefrom, starttimeto, place, class, gender, number, expiration)
复制代码
在上面加:
- } elseif($special == 5 && $allowpostquestion) {
- $exp=$exp*86400+$timestamp;
- $i=0;
- foreach ($q as $key => $v1) {
- foreach ($v1 as $value) {
- $i++;
- /*if(!$q[$key][$value] && $key=='answer')
- showmessage($q[$key][$value]);*/
- }
- }
- $i=($i/7);
- for($j = 1; $j <= $i; $j++) {
- //showmessage($q[$key][$j]);
- $db->query("INSERT INTO {$tablepre}questionoption (`tid`, `type`, `check`, `question`, `key`, `open`,`mark`,`answermust`)
- VALUES ('$tid', '$qtype[$j]', '$qoptions[$j]', '$question[$j]', '$answer[$j]', '$open[$j]', '$mark[$j]', '$amust[$j]')");
- }
- $db->query("INSERT INTO {$tablepre}question (tid, exp, price, persons, stop, submitmore)
- VALUES ('$tid', '$exp', '$qprice', '$mpersons', '$stop', '$allowsubmit')");
复制代码
[ 本帖最后由 sw08 于 2007-5-5 21:30 编辑 ] |