@extends('student/home')
@section('content')
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">Submit Answers on Learning Topic</h3>

         </div>

<div class="video" align="center">
            <iframe width="660" height="475" src="//www.youtube.com/embed/DOUzMU3R8wE" frameborder="0" allowfullscreen></iframe>
        </div>

         <div class="card-body">
            @if (Session::has('message'))
            <div id="alert-msg" class="alert alert-success alert-dismissible">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">�</button>
                {{ Session::get('message') }}
            </div>
            @endif
             {{ Form::open(['method' => 'GET']) }}
            <div class="form-group">
              {!! Form::label('topic', 'Topic:') !!}
              {!! Form::select('topicList', $items , $filter, ['class' => 'form-control', 'id' => 'topicList', 'onchange' => 'this.form.submit();']) !!}
             {{ Form::close() }}
            <!--
              {!! Form::label('topic', 'Topic:') !!}
              {!! Form::select('topic', $items , null, ['class' => 'form-control', 'onchange' => 'doSomething(this)']) !!}
            -->
            </div>

            @php ($complete = true)
            <div class="row">

                <div class="col-md-12">
                  {!! Form::label('tit1', 'Result of Each Task:') !!}

                  @if ($valid=='0')
                   <a class="btn btn-success" href="{{ URL::to('/student/results/create/'.$filter)}}"><i class="fa fa-plus"></i>&nbsp;Submit a Task Result</a>
                   @endif
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="text-center">
                                <th>Task No.</th>
                                <th>Description</th>
                                <th>Status</th>
                                <th>Duration</th>
                                <th>Evidence</th>
                                <th>Comment</th>
                                <th>Action</th>

                            </tr>
                        </thead>
                        <tbody>
                            @foreach($entities as $entity)
                            <tr>
                                <td class="text-center">{{ $entity['taskno'] }}</td>
                                <td>{{ $entity['desc'] }}</td>
                                @if ($valid != '0')
                                  @php ($complete = false)
                                  <td colspan="5" color="red"><b><i>Task result was already validated</i></b></td>
                                @elseif ($entity['status']=='')
                                  @php ($complete = false)
                                  <td colspan="5" color="red"><b><i>Not yet uploaded</i></b></td>
                                @else
                                <td>{{ $entity['status'] }}</td>
                                <td>{{ $entity['duration'] }} minutes</td>
                                <td class="text-center"><img src="{{ asset('storage/'.$entity['imgFile']) }}" width="120"/></td>
                                <td>{{ $entity['comment'] }}</td>
                                <td class="text-center">
                                    <form method="POST" action="{{ URL::to('/student/results/'.$entity['id']) }}">
                                        {{ csrf_field() }}
                                        <input type="hidden" name="_method" value="DELETE" />
                                        <input type="hidden" name="topic" value="{{ $filter }}" />
                                        <div class="btn-group">
                                            <!--<a class="btn btn-info" href="{{ URL::to('/student/results/'.$entity['id']) }}"><i class="fa fa-eye"></i></a>
                                            -->
                                            <a class="btn btn-success" href="{{ URL::to('/student/results/'.$entity['id'].'/edit') }}"><i class="fa fa-pencil-alt"></i></a>
                                            <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i></button>
                                        </div>
                                    </form>
                                </td>
                                @endif
                            </tr>
                            @endforeach
                        </tbody>
                    </table>


                </div>
            </div>
            <div class="row">
            </div>

{{ Form::open(['route'=>'results.store', 'files'=>true]) }}
<input type="hidden" name="action" value="validate" />
<input type="hidden" name="topic" value="{{ $filter }}" />
<input type="hidden" name="projname" value="{{ $currtopic['foldername'] }}" />

<div class="row">
	{!! Form::label('titw2', 'Assignment Answer Submission') !!}
</div>

            <div class="row">
                <div class="col-md-12">
                 {{ Form::radio('option', 'github' ,  $option=='github',  ['onchange' => 'this.form.submit();']) }}
                  {!! Form::label('tit55', "by GitHub Link: ") !!}
<br/>
@if (($valid=='0') && ($option=='github'))
        <p><b>The link must be <font color='RED'>PUBLIC</font> access. Format : https://github.com/{{ '<username>' }}/{{ $currtopic['foldername'] }}/archive/master.zip</b></p>
        {{ Form::text('githublink','https://github.com/', ['class'=>'form-control']) }}
@endif

                </div>
            </div>

<p></p>


            <div class="row">
                <div class="col-md-12">
                 {{ Form::radio('option', 'zipfile' ,  $option=='zipfile',  ['onchange' => 'this.form.submit();']) }}
                  {!! Form::label('tit55', "by Zip File of Android Project Folder: ") !!}
<br/>
@if (($valid=='0') && ($option=='zipfile'))
	<p><b><font color='RED'>File must have ZIP extension (*.zip), don't submit RAR file.</font></b> The zip file must contain project folder <b>{{ "<".$currtopic['foldername'].">" }}</b></p>
        {{ Form::file('zipfile', ['class'=>'form-control']) }}
@endif

                </div>
            </div>


<p></p>


            <div class="row">

                <div class="col-md-12">
		 {{ Form::radio('option', 'files' , $option=='files', ['onchange' => 'this.form.submit();']) }}
                  {!! Form::label('tit2', 'by Multi Files:') !!}
@if ($option=='files')
                  @if ($valid=='0')
                  <a class="btn btn-info" href="{{ URL::to('/student/lfiles/create/'.$filter)}}"><i class="fa fa-plus"></i>&nbsp;Submit a Learning File</a>
                  @endif
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="text-center">
                                <th>No.</th>
                                <th>File Name</th>
                                <th>Folder Path</th>
                                <th>Description</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($lfiles as $index => $lfile)
                            <tr>
                                <td class="text-center">{{ $index +1 }}</td>
                                <td>{{ $lfile['fileName'] }}</td>
                                <td>{{ $lfile['path'] }}</td>
                                <td>{{ $lfile['desc'] }}</td>

                                @if ($valid!='0')
                                  @php ($complete = false)
                                  <td colspan="2" color="red"><b><i>Task result was already validated</i></b></td>
                                @elseif ($lfile['rscfile']=='')
                                  @php ($complete = false)
                                  <td colspan="2" color="red"><b><i>Not yet submitted</i></b></td>
                                @else
                                <td class="text-center">
                                  <span class="btn btn-warning"><i class="fa fa-check-circle"></i></span>
                                </td>

                                <td class="text-center">
                                        <div class="btn-group">
                                            <!--<a class="btn btn-info" href="{{ URL::to('/student/results/'.$entity['id']) }}"><i class="fa fa-eye"></i></a>
                                            -->
                                            <a class="btn btn-danger" href="{{ URL::to('/student/lfiles/delete/'.$lfile['id'].'/'.$filter) }}"><i class="fa fa-trash"></i></a>
                                       </div>
                                </td>
                                @endif
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
@endif
                </div>
            </div>
<p></p>

<div class="row"><br/></div>
                <div class="col-md-12">
@if ($valid=='0')
	@if ($complete)
			<i class="fa fa-check-square"></i>
                        {{ Form::submit('Validate This Learning', ['class' => 'btn btn-danger', 'name' => 'submitbutton']) }}
	@else
		<span class="btn btn-block" ><i class="fa fa-frown"></i>&nbsp;Submission is Not Complete</a>
	@endif
@else
	<span class="btn btn-block" ><i class="fa fa-smile"></i>&nbsp;Validation is Success</a>
@endif
	        </div>
            </div>

{{ Form::close() }}

<div class="row"><br/></div>


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



@endsection
