Skip to content

Commit 2d74949

Browse files
committed
Completed attendance
1 parent 7ef547e commit 2d74949

File tree

2 files changed

+50
-64
lines changed

2 files changed

+50
-64
lines changed

DigiKaksha/app/Http/Controllers/CoursesController.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use App\User;
55
use App\Group;
66
use App\Course;
7+
use App\attendance;
78
use Illuminate\Http\Request;
89

910
class CoursesController extends Controller
@@ -96,7 +97,46 @@ public function store(Request $request)
9697
public function show($id)
9798
{
9899
$course = Course::find($id);
100+
if(auth()->user()->user_level > 1){
99101
return view('courses/show')->with('course', $course);
102+
}
103+
else{
104+
$classId = 0;
105+
$flag=0;
106+
$groups= auth()->user()->groups;
107+
foreach($groups as $group){
108+
if($flag==1)
109+
break;
110+
foreach($group->courses as $co)
111+
{
112+
if($co->id == $id){
113+
$classId = $group->id;
114+
$flag=1;
115+
break;
116+
}
117+
}
118+
}
119+
$roll=auth()->user()->roll_no;
120+
$attendances = attendance::where('course_id', $id)->where('group_id',$classId)->get();
121+
$markedAttendances = [];
122+
$present =0;
123+
$total=0;
124+
foreach($attendances as $att){
125+
$total++;
126+
$thisAtt = new \stdClass;
127+
$thisAtt->date = $att->date;
128+
$thisAtt->taker= $att->taker;
129+
$presentStudents = explode(" ", $att->present);
130+
if(array_search($roll,$presentStudents) === false){
131+
$thisAtt->present = false;
132+
}else{
133+
$present++;
134+
$thisAtt->present = true;
135+
}
136+
array_push($markedAttendances,$thisAtt);
137+
}
138+
return view('courses/show',compact('course','markedAttendances','present','total'));
139+
}
100140
}
101141

102142
/**

DigiKaksha/resources/views/courses/show.blade.php

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@
744744
<div class="row">
745745
<div class="col">
746746
<h5 class="card-title text-uppercase text-muted mb-0 text-white">Attendance</h5>
747-
<span class="h2 font-weight-bold mb-0 text-white">8/10</span>
747+
<span class="h2 font-weight-bold mb-0 text-white">{{$present}}/{{$total}}</span>
748748
</div>
749749
<div class="col-auto">
750750
<div class="icon icon-shape bg-white text-dark rounded-circle shadow">
@@ -753,7 +753,7 @@
753753
</div>
754754
</div>
755755
<p class="mt-3 mb-0 text-sm">
756-
<span class="text-white mr-2">80.00%</span>
756+
<span class="text-white mr-2">{{$present*100/$total}}%</span>
757757
<span class="text-nowrap text-light">Required 75%</span>
758758
</p>
759759
</div>
@@ -900,86 +900,32 @@
900900
</tr>
901901
</thead>
902902
<tbody>
903+
@foreach($markedAttendances as $att)
904+
@if($att->present)
903905
<tr class="table-success">
904-
<th>
905-
<div class="custom-control custom-checkbox">
906-
<input class="custom-control-input" id="table-check-all" type="checkbox">
907-
<label class="custom-control-label" for="table-check-all"></label>
908-
</div>
909-
</th>
910-
<td class="table-user">
911-
<b>abhishek</b>
912-
</td>
913-
<td>
914-
<span class="text-muted">10/09/2018</span>
915-
</td>
916-
<td>
917-
<a href="#!" class="font-weight-bold">None</a>
918-
</td>
919-
<td>
920-
Present
921-
</td>
922-
</tr>
923-
<tr class="table-success">
924-
<th>
925-
<div class="custom-control custom-checkbox">
926-
<input class="custom-control-input" id="table-check-all" type="checkbox">
927-
<label class="custom-control-label" for="table-check-all"></label>
928-
</div>
929-
</th>
930-
<td class="table-user">
931-
<b>abhishek</b>
932-
</td>
933-
<td>
934-
<span class="text-muted">10/09/2018</span>
935-
</td>
936-
<td>
937-
<a href="#!" class="font-weight-bold">15 mins late</a>
938-
</td>
939-
<td>
940-
Present
941-
</td>
942-
</tr>
906+
@else
943907
<tr class="table-warning">
908+
@endif
944909
<th>
945910
<div class="custom-control custom-checkbox">
946911
<input class="custom-control-input" id="table-check-all" type="checkbox">
947912
<label class="custom-control-label" for="table-check-all"></label>
948913
</div>
949914
</th>
950915
<td class="table-user">
951-
<b>abhishek</b>
916+
<b>{{$att->taker}}</b>
952917
</td>
953918
<td>
954-
<span class="text-muted">10/09/2018</span>
919+
<span class="text-muted">{{$att->date}}</span>
955920
</td>
956921
<td>
957922
<a href="#!" class="font-weight-bold">None</a>
958923
</td>
959924
<td>
960-
Absent
925+
@if($att->present)Present @else Absent @endif
961926
</td>
962927
</tr>
963-
<tr class="table-success">
964-
<th>
965-
<div class="custom-control custom-checkbox">
966-
<input class="custom-control-input" id="table-check-all" type="checkbox">
967-
<label class="custom-control-label" for="table-check-all"></label>
968-
</div>
969-
</th>
970-
<td class="table-user">
971-
<b>abhishek</b>
972-
</td>
973-
<td>
974-
<span class="text-muted">10/09/2018</span>
975-
</td>
976-
<td>
977-
<a href="#!" class="font-weight-bold">None</a>
978-
</td>
979-
<td>
980-
Present
981-
</td>
982-
</tr>
928+
@endforeach
983929
</tbody>
984930
</table>
985931
</div>

0 commit comments

Comments
 (0)