<?php
// +----------------------------------------------------------------------+
// | PHP version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2005 Snapshot Inc.                                |
// +----------------------------------------------------------------------+
// | License                                                              |
// | GNU General Public License                                           |
// +----------------------------------------------------------------------+
// | Authors: Mai Kawasaki                                                |
// +----------------------------------------------------------------------+
//
// $Id: List_success_pc.php,v 1.1 2005/06/20 09:31:25 snapshot Exp $
//
// Description:
// 2005/05/18
//
include (BASE_DIR.'templates/pc_header.php');
$time = time();
?>

<div id="main">

<!--　科目名　-->
	<div id="navi1">
		<h1>
			 <?= htmlspecialchars($template['subject']->name) ?>
		</h1>
	</div>
<!--　テスト一覧　-->

	<div id="main_block">
		<h2>
			テスト一覧
		</h2>
		<p>
			リンクのないテストは、締め切りを過ぎたテスト、または受験済で再受験不可のテストです。
		</p>
<?php 
if(count($template['exams_admin']) == 0){
?>
		<p>まだテストはありません。</p>
<?php 	
}

?>
		<ul>
<?php
foreach ($template['exams_admin'] as $exam_admin) {
	// リンクフラグ
	$not_link = false;
	// 締め切りチェック
	if((is_null($exam_admin->deadline_time) || $exam_admin->deadline_time == '') 
		|| ((!is_null($exam_admin->deadline_time) && $exam_admin->deadline_time != '') && $time < strtotime( $exam_admin->deadline_time))){
		// 再受験チェック
		if($exam_admin->retry == '1'){
			$not_link = false;
		} else{
			foreach ($template['exams_student'] as $exam_student) {
				if($exam_student->eid == $exam_admin->eid && ( !is_null($exam_student->reply_date) && $exam_student->reply_date != '')){
					$not_link = true;
					break;
				}
			}
		}
	} else{
			$not_link = true;	
	}
?>
		<li>
<?php	
	if(!$not_link)	{
?>
		<a href="<?= htmlspecialchars(TemplateUtils::createLink('Exam','Start', array('aid'=>$template['admin']->aid, "eid" => $exam_admin->eid))) ?>"><?= htmlspecialchars($exam_admin->name) ?></a>
<?php 
	}	else{
?>
		<?= htmlspecialchars($exam_admin->name) ?>	  
<?php 
	}
	// 配信から1週間以内
	if($time < strtotime( $exam_admin->publish_time) + 604800){
?>
		<font color="red"><blink>new!</blink></font>
<?php 
	}
?>	  
		<div class="exam_info">
			<table>
				<tr>
					<th>配信：</th>
					<td><?= date("Y年m月d日", strtotime( $exam_admin->publish_time)) ?></td>
				</tr>
				<tr>
					<th>締切：</ht>
					<td>
<?php 	
	if(!is_null($exam_admin->deadline_time) && $exam_admin->deadline_time != '') { 
?>
						<?= date("Y年m月d日", strtotime( $exam_admin->deadline_time)) ?>
<?php 
	} else{
?> 
	なし
<?php 
	}
?> 
					</td>
				</tr>
				<tr>
					<th>受験：</th>
					<td>
<?php 
	$unexam = true;
	$on_the_way = false;
	$count = 0;
	foreach ($template['exams_student'] as $exam_student) {
		if($exam_student->eid == $exam_admin->eid){
			$unexam = false;
			if (!is_null($exam_student->reply_date) && $exam_student->reply_date != ''){
?>
						<div>
							<?= date("Y年m月d日", strtotime( $exam_student->reply_date)) ?> <?= $exam_student->points ?>点
						</div>
<?php
				$count ++;
			
			} else{
				$on_the_way = true;
			}
		}
	}
	if($on_the_way){
?>	
						<font color="red">受験中</font>
<?php
	}
	else if($unexam){
?>
						<font color="red">未受験</font>
<?php
	}
?>	
					</td>
				</tr>
			</table>
			</div>	<!-- exam_info -->
		</li>
<?php	
}
?>
		</ul>
<?php
	if($template['is_next']){
?>		
		<div class="div_right">
			<a href="<?= htmlspecialchars(TemplateUtils::createLink('Subject','List', array('aid'=>$template['admin']->aid, 'page'=>$template['page']+1, 'sid'=>$template['subject']->sid))) ?>" class="operation">もっと前のテスト &gt;&gt;</a>
		</div>
<?php
	}
	if($template['is_back']){
?>		
		<div>
			<a href="<?= htmlspecialchars(TemplateUtils::createLink('Subject','List', array('aid'=>$template['admin']->aid, 'page'=>$template['page']-1, 'sid'=>$template['subject']->sid))) ?>" class="operation">&lt;&lt; もっと後のテスト</a>
		</div>
<?php
	}
?>		
	</div><!-- main_block -->
	<div id="main_block">
		<a href="<?= htmlspecialchars(TemplateUtils::createURL('Top','Index', array('aid'=>$template['admin']->aid))) ?>" class="operation">戻る</a>
	</div>

</div><!-- main -->
<?php
include (BASE_DIR.'templates/pc_footer.php');
?>

