<?php
	Assets::add( 'begin-pdf.min.js' );
	Assets::add( 'begin-pdf.css' );
	Assets::add( 'momentjs' );
	AMIB::add_js_translation( trans( 'begin.js-msgs' ) );
?>

<?php $__env->startSection( 'head' ); ?>
	<script>
		var questionPivots = <?php echo AMIB::json_encode( $exam_user->QuestionPivots ); ?>;
		var exam_type = '<?php echo $exam_user->type; ?>';
		var saveUrl = '<?php echo route( "save-exam-results", array( $exam_user->id ) ); ?>';
		var serverTime = <?php echo time(); ?>;
		var serverStartTime = <?php echo $exam_user->start_timestamp; ?>;
		var endTime = <?php echo $exam_user->start_timestamp + $exam->minutes * 60; ?>;
		var login_token = '<?php echo $exam_user->login_token; ?>';
	</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection( 'content' ); ?>
	<div id="begin-top-bar">
		<div class="cc">
			<span id="start-time">
				<?php echo trans( 'begin.start_timestamp' ); ?> :
				<?php echo unix_to_pdate_time( $exam_user->start_timestamp ); ?>

			</span>

			<?php if( $exam_user->type == 'exam' ): ?>
				<span id="remaining">...</span>
			<?php endif; ?>

			<span id="support">
				شماره پشتیبانی:
				<?php echo e(Setting::get( 'phone' )); ?>

			</span>
		</div>
	</div>

	<div id="main-content" class="cc">
		<h1><?php echo e($exam->name); ?></h1>
		<center>
			<a href="<?php echo $exam->get_pdf(); ?>" class="button" target="_BLANK">برای مشاهده سوالات اینجا کلیک کنید</a>
			<hr>
		</center>
		<div id="begin-container">
			<?php
				$ctexts = array( '', 'الف', 'ب', 'ج', 'د' );

				foreach( $exam_user->QuestionPivots as $i => $qp ) {

					if( $i % 10 == 0 ) echo '<div class="qcol"><div class="qcol-inner">';

					$qnum = en2fa( $qp->question_id );
					echo "<div class='q' data-qp-id='{$qp->id}'>";
					echo "<span class='n'>{$qnum}.</span>";

					foreach( range( 1, 4 ) as $choice ) {
						$ctext = $ctexts[ $choice ];
						$selected = ( $choice == $qp->answer ? 'checked' : '' );
						echo "<label><input {$selected} name='a-{$qp->question_id}' value='{$choice}' type='radio'><i>{$ctext}</i></label>";
					}

					echo "</div>";

					if( $i % 10 == 9 ) echo "</div></div>\n";
				}

				if( $i % 10 !== 9 ) echo "</div></div>\n";
			?>
		</div>

		<div id="meta">
			<div id="stats"><!-- fbjs --></div>
			<?php echo HTML::link( '#', trans( $exam_user->type == 'exam' ? 'exam.finalize' : 'exam.finalize-poll' ), array( 'id' => 'finalize', 'class' => 'button', 'data-href' => route( 'finalize-exam', array( $exam_user->id ) ) ) ); ?>

		</div>
	</div>
<?php $__env->stopSection(); ?>