<?php
// +----------------------------------------------------------------------+
// | PHP version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2005 Snapshot Inc.                                |
// +----------------------------------------------------------------------+
// | License                                                              |
// | GNU General Public License                                           |
// +----------------------------------------------------------------------+
// | Authors: Mai Kawasaki                                                |
// +----------------------------------------------------------------------+
//
// $Id: List_success.php,v 1.1 2005/06/20 09:31:25 snapshot Exp $
//
// Description:
// 2005/05/18
//
include (BASE_DIR.'templates/m_header.tpl');
$time = time();
?>
<div align="center">
	 <?= htmlspecialchars($template['subject']->name) ?>
</div>
<hr>

<div>
	■テスト一覧■
</div>
<div>
<marquee>リンクのないテストは、締め切りを過ぎたテスト、または受験済で再受験不可のテストです。</marquee>
<?php 
if(count($template['exams_admin']) == 0){
?>
		<p>まだテストはありません。</p>
<?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;	
	}
	if(!$not_link)	{
?><br>
<a href="<?= htmlspecialchars(TemplateUtils::createLink('Exam','Start', array('aid'=>$template['admin']->aid, "eid" => $exam_admin->eid))) ?>"><?= htmlspecialchars($exam_admin->name) ?></a>
<?php 
	}	else{
?><br>
		<?= htmlspecialchars($exam_admin->name) ?>	  
<?php 
	}
	// 配信から1週間以内
	if($time < strtotime( $exam_admin->publish_time) + 604800){
?>
<font color="red"><blink>new!</blink></font>
<?php 
	}
?>	  
	  <br>
└ 配信：<?= date("Y年m月d日", strtotime( $exam_admin->publish_time)) ?><br>
　 締切：<?php 	
	if(!is_null($exam_admin->deadline_time) && $exam_admin->deadline_time != '') { ?>
<?= date("Y年m月d日", strtotime( $exam_admin->deadline_time)) ?>
<?php 
	} else{
?>なし
<?php 
	}
?> 
	<br>
　 受験：<?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 != ''){
				if ($count > 0){
?><br>　 　　　<?php
				}
?><?= date("Y年m月d日", strtotime( $exam_student->reply_date)) ?> <?= $exam_student->points ?>点<?php
				$count ++;
			
			} else{
				$on_the_way = true;
			}
		}
	}
	if($on_the_way){
?>	
		<font color="red">受験中</font>
<?php
	}
	else if($unexam){
?>
		<font color="red">未受験</font>
<?php
	}
}
?>
<br>
</div>
<?php
	if($template['is_next']){
?>		
<br>
		<div>
			<a href="<?= htmlspecialchars(TemplateUtils::createLink('Subject','List', array('aid'=>$template['admin']->aid, 'page'=>$template['page']+1, 'sid'=>$template['subject']->sid))) ?>" >もっと前のテスト &gt;&gt;</a>
		</div>
<?php
	}
	if($template['is_back']){
?>		
<br>
		<div>
			<a href="<?= htmlspecialchars(TemplateUtils::createLink('Subject','List', array('aid'=>$template['admin']->aid, 'page'=>$template['page']-1, 'sid'=>$template['subject']->sid))) ?>" >&lt;&lt; もっと後のテスト</a>
		</div>
<?php
	}
?>		

<br>
<div>
	<a href="<?= htmlspecialchars(TemplateUtils::createLink('Top','Index', array('aid'=>$template['admin']->aid))) ?>">TOPへ</a>
</div>
<?php
include (BASE_DIR.'templates/m_footer.tpl');
?>


