<?php
	// Assets::add( 'select2' );
	Assets::add( 'tinymce' );
	Assets::add( 'dropzone' );
	Assets::add( 'questions.min.js' );
	Assets::add( 'questions.css' );
	AMIB::add_js_translation( trans( 'question.js-msgs' ) );
	AMIB::add_js_translation( trans( 'main.dz-js' ) );
?>
<?php $__env->startSection( 'head' ); ?>
	<script>
		var questions = <?php echo AMIB::json_encode( $questions );; ?>;
		var courseType = '<?php echo $course->type; ?>';
		var uploadUrl = "<?php echo route( 'att-upload' ); ?>";
		var deleteUrl = "<?php echo route( 'delete-question-ajax' ); ?>";
		var getQuestionDataUrl = "<?php echo route( 'get-question-data-ajax' ); ?>";
	</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection( 'content' ); ?>
	<h1><?php echo e($course->name); ?></h1>
	<div id="new-q-container">
		<?php echo HTML::link( '#', trans( 'question.new' ), array( 'class' => 'button add-new' ) ); ?>

		<?php echo HTML::link( '#', trans( 'question.import' ), array( 'class' => 'button import' ) ); ?>

	</div>

	<div id="questions"><!-- fbjs --></div>

	<script id="question-template" type="amib/template">
		<div class="question-row" data-question-id='%id%'>
			<div class="question-text"></div>
			<span class="lesson-name"></span>
			<span class="question-type"></span>
			<hr>
			<div class="question-meta">
				<a href="#" class="button edit">ویرایش</a>
				<a href="#" class="button delete">حذف</a>
			</div>
		</div>
	</script>

	<div id="add-edit-popup" class="white-popup mfp-hide">
		<h2 id="question-files"><?php echo trans( 'question.files' ); ?></h2>

		<?php echo $__env->make( 'inc.dropzone' , array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

		<?php echo Form::open( array( 'route' => 'add-edit-question-ajax' ) ); ?>

			<?php echo Form::hidden( 'question_id', null, array( 'id' => 'question_id' ) ); ?>

			<?php echo Form::hidden( 'ordering', '0', array( 'id' => 'ordering' ) ); ?>


			<h2><?php echo trans( 'question.new-title' ); ?></h2>
			<div class="ff tmce-container">
				<?php echo Form::textarea( 'text', null, array( 'id' => 'text' ) ); ?>

				<div class="buttons-container">
					<a href="#question-files" class="button add-image">ثبت تصویر</a>
				</div>
			</div>

			<div class="pure-g">
				<div class="ff pure-u-1 pure-u-md-1-2">
					<?php echo Form::label( 'lesson_id', trans( 'question.lesson_id' ) ); ?>

					<?php echo Form::select( 'lesson_id', $course_lessons_select ); ?>

				</div>

				<div class="ff pure-u-1 pure-u-md-1-2">
					<?php echo Form::label( 'type', trans( 'question.type' ) ); ?>

					<?php echo Form::select( 'type', $types_select, false, array( 'id' => 'type' ) ); ?>

				</div>
			</div>

			<div id="choices-container">
				<h2><?php echo trans( 'question.choices' ); ?></h2>
				<div id="choices" class="box"><!-- fbjs --></div>
				<div class="buttons-container">
					<?php echo HTML::link( '#', 'اضافه کردن گزینه', array( 'id' => 'add-choice', 'class' => 'button add' ) ); ?>

				</div>

				<script id="choice-template" type="amib/template">
					<div class="choice-row tmce-container">
						<label class="correct-label"><input type="radio" name="correct_answer"> <?php echo trans( 'question.correct-choice' ); ?></label>
						<textarea name="choice_texts[]"></textarea>
						<input name="choice_ids[]" type="hidden" value="0">
						<div class="buttons-container">
							<a href="#" class="button delete">حذف</a>
							<a href="#question-files" class="button add-image">ثبت تصویر</a>
						</div>
					</div>
				</script>
			</div>

			<div>
				<div class="progress"><div></div></div>
				<div class="error-container"></div>
				<hr>
				<?php echo Form::submit( trans( 'main.save' ) ); ?>

			</div>
		<?php echo Form::close(); ?>

	</div>

	<div id="import-popup" class="white-popup mfp-hide mfp-narrow mfp-with-anim">
		<h2><?php echo trans( 'question.import' ); ?></h2>
		<a href="img/questions-sample.xlsx" class="button" target="_BLANK"><?php echo trans( 'question.sample-import-file' ); ?></a>
		<hr>
		<?php echo Form::open( array( 'url' => route( 'import-questions-ajax', array( $course->id ) ), 'files' => true ) ); ?>

			<?php echo Form::label( 'excel-file', trans( 'question.import-file' ) ); ?>

			<?php echo Form::file( 'excel-file' ); ?>

			<hr>
			<div class="progress"><div></div></div>
			<?php echo Form::submit( trans( 'question.import' ) ); ?>

		<?php echo Form::close(); ?>

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