Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sujitdhaka's avatar

Optional Subject GPA deduct from total GPA

{{ app_data('site_title') }}

.card-body> div[class*="col-"]{ margin-bottom: 15px; float: left; } .h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { margin-bottom: .1rem; font-family: inherit; font-weight: 900; line-height: 1.1; color: inherit; } #customers td, #customers th { border: 1px solid #000; padding: 5px 12px; text-align: center; } body { margin: 0px; width: 21cm; height: 29.7cm; font-family: my_kalpurush; font-size: 16px; } customers td, #customers th { border: 1px solid #000; padding: 5px; text-align: center; } .print_page { width: 21cm; height: 29.7cm; margin: auto; page-break-after: always; border: 1px solid #000; } @media print{ .card{ border:0px; } } body { background: rgb(204,204,204); } page { background: white; display: block; margin: 0 auto; margin-bottom: 0.5cm; box-shadow: 0 0 0.5cm rgba(0,0,0,0.5); } page[size="A4"] { width: 21cm; height: 29.7cm; } page[size="A4"][layout="landscape"] { width: 29.7cm; height: 21cm; } page[size="A3"] { width: 29.7cm; height: 42cm; } page[size="A3"][layout="landscape"] { width: 42cm; height: 29.7cm; } page[size="A5"] { width: 14.8cm; height: 21cm; } page[size="A5"][layout="landscape"] { width: 21cm; height: 14.8cm; } @media print { body, page { margin: 0; box-shadow: 0; } }

@foreach($students AS $data) 
    <div class="col-md-" style="width: 800px;margin: auto;">
    <div class="card" style="border: 0px;">
        <div class="card-body" style="padding-bottom:0px;padding-top:0px;">
            <div class="card-body card-block" style="padding-bottom:0px;padding-top:0px;">
                <div class="col-md-" style="width: 140px;padding-top:10px">
                    <img src="{{ asset('uploads/images/'.app_data('logo')) }}" alt="Logo">
                </div>
                <div class="col-md-" style="width: 445px;text-align: center;">
                    <h3>Kalakopa K.P. High School</h3>
                    <h5>Established - 1936</h5>
                    Dhaka, Bangladesh,  EIIN- 108294
                 <br> E:[email protected] , www.kalakopakpschool.edu.bd
                    <br>
                    <h4><u>Academic Transcript</u></h4>
                    
                </div>
                <div class="col-md-" style="width: 93px;border: 1px solid #ddd;padding-top: 98px;padding: 4px;margin-top: 42px;">
                    <img width="80px" src="{{ asset('uploads/images/'.$data->photo) }}">
                </div>
                        <style>

#customers { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; border-collapse: collapse; width: 100%; }

#customers td, #customers th { border:1px solid #8aa798; padding: 5px; }

#customers tr:nth-child(even){background-color: #FFF;}

#customers tr:hover {background-color: #FFF;}

#customers th { padding-top: 5px; padding-bottom: 5px; text-align: left; background-color: #FFF; color:#000; } .card-body { width: 20.6cm; height: 35.7cm; BORDER-BOTTOM: 2PX SOLID #DDD; } .h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { margin-bottom: .1rem; font-family: inherit; font-weight: 900; line-height: 1.1; text-align: center; color: inherit; } .h3, h3 { font-size: 1.75rem; }

{{ get_exam($exam_id) }} - {{ get_academic_year(app_data('academic_year')) }}

Student Name Class Section Roll Group {{ $data->sname_bangla }} {{ get_class_name($class_id) }} {{ get_section_name($section_id) }} {{ $data->roll }} {{ $data->group }} Subjects Name Total Marks Creative MCQ Practical Obtained Marks Grade Point

@php $student_id = $data->student_id; $subjects = App\Subject::select('','subjects.creative_mark AS creative_mark','marks.creative_mark AS get_creative_mark','subjects.mcq_mark AS mcq_mark','marks.mcq_mark AS get_mcq_mark','subjects.practical_mark AS practical_mark','marks.practical_mark AS get_practical_mark','subjects.id AS subject_id') ->leftJoin('marks',function($join) use ($class_id, $section_id, $student_id, $exam_id) { $join->on('marks.subject_id','=','subjects.id'); $join->where('marks.class_id','=',$class_id); $join->where('marks.section_id','=',$section_id); $join->where('marks.student_id','=',$student_id); $join->where('marks.exam_id','=',$exam_id); }) ->where('subjects.class_id', $class_id) ->where(function($subjects) use ($data){ $subjects->where('group', $data->group)->orWhereNull('group'); }) ->orderBy('subjects.id','ASC') ->get(); $total = 0; $total_point = 0; @endphp @php $student_id = $data->student_id; $presents = App\Present::select('','presents.working_day AS working_day','attendencs.working_day AS get_working_day','presents.id AS present_id') //*$presents = App\Present::select('','presents.working_day AS working_day','attendencs.working_day AS get_working_day') ->rightJoin('attendencs',function($join) use ($class_id, $section_id, $student_id, $exam_id) { $join->on('attendencs.present_id','=','presents.id'); $join->where('attendencs.class_id','=',$class_id); $join->where('attendencs.section_id','=',$section_id); $join->where('attendencs.student_id','=',$student_id); $join->where('attendencs.exam_id','=',$exam_id); }) ->where('presents.section_id', $section_id)

            ->get();
        
@endphp
@php
    $total_fail = array();
    $creative_fail = '';
    $mcq_fail = '';
    $total = [];
    $point = [];
@endphp
@if($class_id != 8)
<tr>
    <td><b>{{ $subjects[0]->subject_name }}</b></td>
    <td>{{ $subjects[0]->creative_mark + $subjects[0]->mcq_mark }}</td>
    <td>{{ $subjects[0]->get_creative_mark }} @php $b1_sub_fail = ($subjects[0]->get_creative_mark < $subjects[0]->creative_pass_mark) ? 'F' : ''  @endphp</td>
    <td>{{ $subjects[0]->get_mcq_mark }} @php $b1_mcq_fail = ($subjects[0]->get_mcq_mark < $subjects[0]->mcq_pass_mark) ? 'F' : ''; @endphp</td>
    <td></td>
    <td>@php echo $b1_total =  $subjects[0]->get_creative_mark + $subjects[0]->get_mcq_mark; $total[] = $b1_total; @endphp</td>
    <td>
        
    </td>
    <td></td>
</tr>
<tr>
    <td><b>{{ $subjects[1]->subject_name }}</b></td>
    <td>{{ $subjects[1]->creative_mark + $subjects[0]->mcq_mark }}</td>
    <td>{{ $subjects[1]->get_creative_mark }} @php $b2_sub_fail = ($subjects[1]->get_creative_mark < $subjects[1]->creative_pass_mark) ? 'F' : ''  @endphp</td>
    <td>{{ $subjects[1]->get_mcq_mark }} @php $b2_mcq_fail = ($subjects[1]->get_mcq_mark < $subjects[1]->mcq_pass_mark) ? 'F' : ''; @endphp</td>
    <td></td>
    <td>@php echo $b2_total =  $subjects[1]->get_creative_mark + $subjects[1]->get_mcq_mark; $total[] = $b2_total; @endphp</td>
    <td>
        @php
           if(in_array('F',[$b1_sub_fail,$b1_mcq_fail,$b2_sub_fail,$b2_mcq_fail])){
                echo 'F';
           }else{
                echo get_grade($b1_total + $b2_total, $subjects[0]->creative_mark + $subjects[0]->mcq_mark + $subjects[1]->creative_mark + $subjects[1]->mcq_mark);
           }
        @endphp
    </td>
    <td>
        @php
           if(in_array('F',[$b1_sub_fail,$b1_mcq_fail,$b2_sub_fail,$b2_mcq_fail])){
                echo $point[] = '0.00';
           }else{
                echo $point[] = get_point($b1_total + $b2_total, $subjects[0]->creative_mark + $subjects[0]->mcq_mark + $subjects[1]->creative_mark + $subjects[1]->mcq_mark);
           }
        @endphp
    </td>
</tr>

<tr>
    <td><b>{{ $subjects[2]->subject_name }}</b></td>
    <td>{{ $subjects[2]->creative_mark}}</td>
    <td>{{ $subjects[2]->get_creative_mark }} @php $e1_sub_fail = ($subjects[2]->get_creative_mark < $subjects[2]->creative_pass_mark) ? 'F' : ''  @endphp</td>
    <td></td>
    <td></td>
    <td>@php echo $e1_total =  $subjects[2]->get_creative_mark; $total[] = $e1_total; @endphp</td>
    <td>
        
    </td>
    <td></td>
</tr>

<tr>
    <td><b>{{ $subjects[3]->subject_name }}</b></td>
    <td>{{ $subjects[3]->creative_mark}}</td>
    <td>{{ $subjects[3]->get_creative_mark }} @php $e2_sub_fail = ($subjects[3]->get_creative_mark < $subjects[3]->creative_pass_mark) ? 'F' : ''  @endphp</td>
    <td></td>
    <td></td>
    <td>@php echo $e2_total =  $subjects[3]->get_creative_mark; $total[] = $e2_total; @endphp</td>
    <td>
        @php
           if(in_array('F',[$e1_sub_fail,$e2_sub_fail])){
                echo 'F';
           }else{
                echo get_grade($e1_total + $e2_total, $subjects[2]->creative_mark + $subjects[3]->creative_mark);
           }
        @endphp
    </td>
    <td>
         @php
           if(in_array('F',[$e1_sub_fail,$e2_sub_fail])){
                echo $point[] = '0.00';
           }else{
                echo $point[] = get_point($e1_total + $e2_total, $subjects[2]->creative_mark + $subjects[3]->creative_mark);
           }
        @endphp
    </td>
</tr>
@endif

@foreach($subjects AS $key => $data)
@if(!in_array($key, [0,1,2,3]))
@php
    $creative_fail = '';
    $mcq_fail = '';
    $pra_fail = '';
@endphp
{{ $data->subject_name }}
<td>{{ $data->creative_mark + $data->mcq_mark + $data->practical_mark }}</td>
<td>{{ $data->get_creative_mark }} @php $creative_fail = ($data->get_creative_mark < $data->creative_pass_mark) ? 'F' : ''  @endphp</td>
@if(($data->mcq_mark != '')) @php $mcq_fail = ($data->get_mcq_mark < $data->mcq_pass_mark) ? 'F' : ''; echo $data->get_mcq_mark; @endphp @endif @if(($data->practical_mark != '')) @php $pra_fail = ($data->get_practical_mark < $data->practical_pass_mark) ? 'F' : ''; echo $data->get_practical_mark; @endphp @endif @php $total[] = $data->get_creative_mark + $data->get_mcq_mark + $data->get_practical_mark; echo $data->get_creative_mark + $data->get_mcq_mark + $data->get_practical_mark; @endphp @php
   if(in_array('F',[$creative_fail,$mcq_fail,$pra_fail])){
        echo 'F';
   }else{
        echo get_grade($data->get_creative_mark + $data->get_mcq_mark + $data->get_practical_mark, $data->creative_mark + $data->mcq_mark + $data->practical_mark);
   }
   
   @endphp
@php
   if(in_array('F',[$creative_fail,$mcq_fail,$pra_fail])){
        echo $point[] = '0.00';
   }else{
        echo $point[] = get_point($data->get_creative_mark + $data->get_mcq_mark + $data->get_practical_mark, $data->creative_mark + $data->mcq_mark + $data->practical_mark);
   }
   
   @endphp
  </td> 
@endif

@endforeach

<td><b> Optional Subject Without GPA
   </b></td><td colspan="3" style=" BACKGROUND: #efd7d7;"><b>Total Obtained Marks</b> </td>

@if($student_id=9997) {{ $optinal=$data->get_creative_mark+$data->get_mcq_mark+$data->get_practical_mark }} @else {{NA}} @endif

GPA Grade Fail Subjects 3.67@php $total_fail = count(array_keys($point, "0.00")); $total_subject = count($subjects) -1.92; array_splice($point, -2);@endphp {{ array_sum($total) }} {{ ($total_fail == 0) ? number_format((array_sum($point)/$total_subject),2) : 'F' }} {{ ($total_fail == 0) ? get_final_grade((array_sum($point)/$total_subject)) : '0.00' }} {{ $total_fail }} Optional Subject Without GPA @if($optional_subject=149) {{ $optinal=$data->get_creative_mark+$data->get_mcq_mark+$data->get_practical_mark }} @else {{NA}} @endif Total Obtained Marks GPA Grade Fail Subjects 3.67@php $total_fail = count(array_keys($point, "0.00")); $total_subject = count($subjects) -1; array_splice($point, -2);@endphp {{ array_sum($total)}} {{ ($total_fail == 0) ? number_format((array_sum($point)/$total_subject),2) : 'F' }} {{ ($total_fail == 0) ? get_final_grade((array_sum($point)/$total_subject)) : '0.00' }} {{ $total_fail }} @foreach($presents AS $data) Optional Subject With GPA Total Working Day Total Present Day Total Absent Day total_present_day }} {{ $s_total=$s1-$s2}} Remarks {{ $data->remarks }} @endforeach Class Teacher Signature

Guairden Signature

Headmaster Signature & Date

© Copyright by Kalakopa K.P. High School 2019. Online Software Developed by kksolutionbd.com.
 <tr>
<td><b> 3.83 </td><td colspan="3"><b>       
                    {{ $s1=$data->working_day }}
                    </b> </td>

@endforeach

0 likes
5 replies
Snapey's avatar

a) why have you posted your entire project?

b) why have you not formatted your code for the forum?

c) actually whats the problem you want help with?

sujitdhaka's avatar

actualy this is student Progress Report Card View page code. I want to GPA without optional subject and with optional subject with gpa Example

Total GPA 5.00 (with Optional Subject)

Optional subject without TOTAL GPA is : 4:00 That i need

Cronix's avatar

It's pretty unreadable. Please format it. There is a link to the instructions in the reply box on how to post code here. It uses github flavored markdown.

Snapey's avatar

And provide just the part you are having an issue with.

sujitdhaka's avatar

Actual i want that

Subject Name GP

Math 5 Eng 4 Computer 3 Agriculture 3

above 4 subjects but my major subject is 3 (Math,Eng,Computer) so total avarage gpa is : 12/3 = 4

now one subject is optional Agriculture 3 so now agriculture point if 2 greater then count point 1+12= 4.33

Please or to participate in this conversation.