<?php
// +----------------------------------------------------------------------+
// | PHP version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2005 Snapshot Inc.                                |
// +----------------------------------------------------------------------+
// | License                                                              |
// | GNU General Public License                                           |
// +----------------------------------------------------------------------+
// | Authors: Mai Kawasaki                                                |
// +----------------------------------------------------------------------+
//
// $Id: ConfirmAction.class.php,v 1.1 2005/06/20 09:31:26 snapshot Exp $
//
// Description:
// 2005/05/18
//


/** 
*	ConfirmAction.class.php
*	Mai Kawasaki
*	2005/05/18
*/
require_once(OPT_DIR.'u-learning/config.php');
require_once(OPT_DIR.'u-learning/action/SecureStudentAction.class.php');
require_once(OPT_DIR.'u-learning/data/Admin.class.php');
require_once(OPT_DIR.'u-learning/data/AdminExam.class.php');
require_once(OPT_DIR.'u-learning/data/AdminQuestion.class.php');
require_once(OPT_DIR.'u-learning/data/AdminChoice.class.php');
require_once(OPT_DIR.'u-learning/data/StudentExam.class.php');
require_once(OPT_DIR.'u-learning/data/StudentQuestion.class.php');
require_once(OPT_DIR.'u-learning/data/StudentChoice.class.php');

/** 
*	ConfirmAction
*/
class ConfirmAction extends SecureStudentAction {
    function execute (&$controller, &$request, &$user) {
	
		// ブラウザの判別
		$type = $this->getUserAgentType();
		$request->setAttribute('type', $type);	
	
		$DB = $request->getAttribute('DB');
		$rid = $request->getParameter('rid');	
		// 教員情報取得
		$request->setAttribute('admin', new Admin($user->getAttribute('aid'), $DB));
	
		// 回答状況を取得
        $sed= new StudentExamDetail($rid, $DB);
        $sed->setQuestions();
        $request->setAttribute('sed', $sed);
		$sql_count = "select count(rid) as answer"
				." from user_choice"
				." where rid=".$rid;
		$count_student = $DB->GetOne($sql_count);

		$exam_admin = unserialize($_SESSION['exam_admin']);
		$exam_admin->setQuestions($DB);

		$request->setAttribute('exam_admin', $exam_admin);
		$request->setAttribute('count', unserialize($_SESSION['count']));
		$request->setAttribute('rid', $rid);
		$request->setAttribute('count_student', $count_student);		
	
		return VIEW_SUCCESS;
    }
	
}

?>