<!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
 typename = {1:"単一選択(ラジオボタン)", 2:"単一選択(コンボボックス)", 3:"複数選択(チェックボックス)", 4:"フリー入力(１行)", 5:"フリー入力(複数行)"}
?>
  <head>
    <title>アンケートの編集</title>
	<script type="text/javascript">
		function eventHandler(actionName) {
			f = document.forms['questionlist'];
			document.getElementById('actionName').value = actionName;
			if(actionName == "add"){
				f.action="${href.enquete('editdetail')}";
			} else if(actionName == "edit"){
				f.action="${href.enquete('editdetail')}";
			} else if(actionName == "delete"){
				if(!confirm('削除してもよろしいですか？')){
					return false;
				}
				f.action="${href.enquete('edit')}";
			} else if(actionName == "enquetelist"){
				location.href="${href.enquete()}";
				return;
			}
			f.submit();
		}
	</script>
  </head>
  <body>
	<form name="questionlist" action="" method="post">
	<div>
		<B>タイトル：${title}</B><P/>
		<input type="button" name="add" value="追加"  onclick="javascript:eventHandler('add');" />
		<input type="button" name="edit" value="編集"  onclick="javascript:eventHandler('edit');" />
		<input type="button" name="delete" value="削除"  onclick="javascript:eventHandler('delete');" />
		<input type="button" name="enquetelist" value="戻る"  onclick="javascript:eventHandler('enquetelist');" />
		<input type="hidden" name="idx"/>
		<input type="hidden" id="actionName"  name="actionName"/>
	</div>
	<div>
		<table width="90%"  class="list">
			<thead>
				<tr>
					<th>No.</th>
					<th>設問</th>
					<th>設問タイプ</th>
					<th>明細</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"><input type="radio"  name="question_id"  value="${question['question_id']}" checked="${idx==0 or None}"/>${idx+1}</td>
						<td>${question['question_title']}</td>
						<td>${typename[question['type']]}</td>
						<td><pre>${question['detail']}</pre></td>
					</tr>
				</py:for>
			</tbody>
		</table>
		<input type="hidden" name="enquete_id" value="${enquete_id}" />
	</div>
	</form>
  </body>
</html>
