<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <xi:include href="macros.html" />
<?python
from enquete.OpenFlashChart import *
from genshi.core import *
import urllib
?>
  <head>
    <title>アンケート集計</title>
    <script type="text/javascript" src="../js/swfobject.js"></script>
	<script type="text/javascript">
		function eventHandler(actionName) {
			f = document.forms['questionlist'];
			document.getElementById('actionName').value = actionName;
			if(actionName == "enquetelist"){
				location.href="${href.enquete()}";
				return;
			}
			f.submit();
		}
	</script>
  </head>
  <body>
	<form name="questionlist" action="" method="post">
	<div style="padding-left:40px">
		<B>タイトル：${title}</B><P/>
		<input type="hidden" name="idx"/>
		<input type="hidden" id="actionName"  name="actionName"/>
	</div>
	<div style="padding-left:40px">
		<input type="button" name="enquetelist" value="戻る"  onclick="eventHandler('enquetelist');" />
		<table width="90%"  class="list">
			<thead>
				<tr>
					<th>No.</th>
					<th>設問</th>
					<th colspan="2">結果</th>
				</tr>
			</thead>
			<tbody>
				<py:for each="idx, question in enumerate(question_list)">
<?python
mod = idx % 2
style = ''
if mod==0:
	style = 'even'
else:
	style = 'odd'
?>
					<tr class="${style}">
						<td width="40">${idx+1}</td>
						<td>${question['question_title']}</td>
<?python
if(question['question_id'] in chart_map):
	url = ("""../chrome/enquete/swf/open-flash-chart.swf?data=%s""") % (urllib.quote(chart_map[question['question_id']]))
else:
	url = ''

if(question['type'] == 4 or question['type'] == 5):
	graph = False
else:
	graph = True
?>
<py:choose test="graph">
<py:when test="False">
						<td colspan="2">
							<table class="list">
								<py:for each="idx2, answer in enumerate(answer_map[question['question_id']])">

								<tr py:if="question['question_id']==answer['question_id'] and answer['answer']!=''">
									<td><pre>${answer['answer']}</pre></td>
								</tr>
								</py:for>
							</table>
						</td>
</py:when>
<py:otherwise>
						<td bgcolor="#F8F8D8" align="center">
	<py:choose test="url">
		<py:when test="''">
			NO DATA
		</py:when>
		<py:otherwise>
			<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="200" id="wiki_activity_chart" align="middle">
			<param name="allowScriptAccess" value="sameDomain" />
			<param name="movie" value="${unescape(url)}" />
			<param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />
			<embed src="${unescape(url)}" quality="high" bgcolor="#FFFFFF" width="400" height="200" name="wiki_activity_chart" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
			</object>
		</py:otherwise>
	</py:choose>
						</td>
						<td>
							<table class="list" py:if="answer_map.has_key(question['question_id'])">
								<py:for each="idx2, answer in enumerate(answer_map[question['question_id']])">

								<tr py:if="question['question_id']==answer['question_id']">
									<td>${answer['answer']}</td>
									<td>${answer['count']}</td>
								</tr>
								</py:for>
							</table>
						</td>
</py:otherwise>
</py:choose>
					</tr>
				</py:for>
			</tbody>
		</table>
	</div>
	</form>
  </body>
</html>
