{# Template For UG Students In SFS
Changes : show percentage in each subject
            Show  Pass status and SGPA #}
<style>
     td, th { padding: 5px; }
    .no-border{
        border-top:1px solid #fff !important;
        border-left:1px solid #fff !important;
        border-right:1px solid #fff !important;
        border-bottom:1px solid #fff !important;
    }
    .consolidated-table thead tr th {

    }
    .border-trl-0{
        border-top:1px solid #fff !important;
        border-left:1px solid #fff !important;
        border-right:1px solid #fff !important;
    }
    .border-rl-0{
        border-left:1px solid #fff !important;
        border-right:1px solid #fff !important;
    }
    .border-b-0{
        border-bottom:1px solid #fff !important;
        border-top:1px solid #000 !important;
    }
    .border-t-0{
        border-top:1px solid #fff !important;
        border-bottom:1px solid #000 !important;
    }
    .noborder-r-0{
       border-right-style: none;
    }
    .border-bt-0{
        border-bottom:1px solid #fff !important;
        border-top:1px solid #fff !important;
    }
</style>
    <div class="page" style="width:100%;">
    {% set subjectLen =  data.examRegistrationData.subjectGroups|length %}
    {% set subjectColSpan =   subjectLen * 5 %}
    {% set trcolSpan =  data.examRegistrationData.totalColSpanGrouped + 6 %}
    {% set addedAttribute =  data.hideExternalOrInternalMark ? ' data-exclude = true ' : '' %}
    <table class="table border table-responsive-md"  style='' border="1" role="grid" id="regular-consolidated-exam-report" class="consolidated-table">
        <thead>
            <tr class="">
                <td class="removeTdBorder college-head no-border" style="text-align:center;" data-f-bold='true' data-a-h='center' colspan="{{trcolSpan}}" >
                    <div style="text-align:center;margin-top:10px; ">
                        <img  src = '{{data.collegeData.collageLogo}}' style = 'width: 85px; height: 115px;'>
                            <div align="center">
                            <div style='font-size:24px; margin-top:10px;'><b>{{data.collegeData.collegeName}}</b></div>
                            <div><b>{{data.collegeData.collegeAddress}}</b></div>
                            <div>{{data.collegeData.collegeAddress2 |escape}}</div>
                            {# <font size="4">
                                <b style='font-size: 19px;'>{{data.collegeAndOtherData.collegeName}}</b>
                            </font><br /> #}
                        </div>
                    </div>
                </td>
            </tr>
            
             <tr class="">
                <td class="removeTdBorder college-head no-border" style="text-align:center;" data-f-bold='true' data-a-h='center' colspan="{{trcolSpan}}" >
                    <div class="" style='font-size: 20px;'><b>Exam Registration Name : {{data.examRegistrationData.name |upper}}</b></div>
                {# <div style='font-size: 15px; line-height:15px;'><b>Exam Registration Name : {{data.examRegistrationData.name}}</b></div></td> #}
                </td>
            </tr>
            <tr class="">
                <td class="removeTdBorder college-head no-border" style="text-align:center;" data-f-bold='true' data-a-h='center' colspan="{{trcolSpan}}" >
                    <div class="" style='font-size: 20px;text-align:center;'><b>Department : {{data.examRegistrationData.deptName |upper}}</b></div>
                </td>
            </tr>
            <tr class="">
                <td class="removeTdBorder college-head no-border" style="text-align:center;" data-f-bold='true' data-a-h='center' colspan="{{trcolSpan}}" >
                    <div class="" style='font-size: 20px;text-align:center;'><b>Semester : {{data.examRegistrationData.academicTermName |upper}}</b></div>
                </td>
            </tr>
            <tr></tr>
            <tr class="border">
                <th width="5%" rowspan="2" class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Sl.No.</th>
                {% if data.hideExternalOrInternalMark %}
                    <th width="10%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Student Name</th>
                    <th width="5%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Reg. No</th>
                    {% for subject in data.examRegistrationData.subjectGroups %}
                        <th  width="5%" colspan="{{subject.subColSpan}}" style="text-transform: none !important;" class='text-center border-r-0' data-a-h='center' data-a-v='middle'>{{subject.code |raw}} <br> {{subject.name |raw}}</th>
                    {% endfor %}
                {% else %}
                    <th width="30%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Student Name</th>
                    <th width="30%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Reg. No</th>
                    {% for subject in data.examRegistrationData.subjectGroups %}
                        <th width="15%" colspan="{{subject.subColSpan}}" style="text-transform: none !important;" class='text-center border-r-0' data-a-h='center' data-a-v='middle'>{{subject.code |raw}} <br> {{subject.name |raw}}</th>
                    {% endfor %}
                {% endif %}
                <th width="5%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Total Grade Point</th>
                <th width="5%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Status</th>
                <th width="5%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>SGPA</th>
                <th width="5%" rowspan="2"class='text-center bold border-r-0' data-a-h='center' data-a-v='middle'>Grade</th>
            </tr>
            
            <tr class="border">
                {% for subject in data.examRegistrationData.subjectGroups %}
                    <th width="5%" {{addedAttribute}} class='hideMarks text-center border-r-0' data-a-h='center' data-a-v='middle'>Internal Mark</th>
                    <th width="5%" {{addedAttribute}} class='hideMarks text-cente border-r-0' data-a-h='center' data-a-v='middle'>External Mark</th>
                    <th width="5%" {{addedAttribute}} class='hideMarks text-center border-r-0' data-a-h='center' data-a-v='middle'>Total Mark</th>
                    <th width="5%" {{addedAttribute}} class='hideMarks text-center border-r-0' data-a-h='center' data-a-v='middle'>Grade Point</th>
                    <th width="5%" {{addedAttribute}} class='hideMarks text-center border-r-0' data-a-h='center' data-a-v='middle'>Percentage</th>
                    <th width="5%" class='text-center border-r-0' data-a-h='center' data-a-v='middle'>Grade</th>
                {% endfor %} 
            </tr>
        </thead>
        <tbody>
            {% set slno = 0 %}
            {% for student in data.studentData %}
            {% set slno = slno + 1 %}
                <tr>
                    <td class="align-middle text-center border-r-0">{{slno}}</td>
                    <td class="align-middle text-left border-r-0">{{student.name | upper}}</td>
                    <td class="align-middle text-center border-r-0">{{student.registerNo}}</td>
                    {% set updatedPaperSubjectIds = [] %}
                    {% for subject in data.examRegistrationData.subjectGroups %}
                        {% set isEntered = false %}
                        {% set isEnteredGroup = false %}
                        {% for studentSubject in student.subjects %}
                            {% if studentSubject.id in subject.academicPaperSubjectIds and isEnteredGroup == false %}
                                {% if studentSubject.id not in updatedPaperSubjectIds %}
                                    {% set updatedPaperSubjectIds = updatedPaperSubjectIds|merge([studentSubject.id]) %}
                                    <td {{addedAttribute}} class="hideMarks text-center noborder-r-0">{{ (not studentSubject.showExcludeSubjectFromTotalWithDetails and studentSubject.excludeSubjectFromTotal == "1") ? "-" : studentSubject.isInternal == 1 ? studentSubject.internalAttendanceStatus == "ABSENT" ? "<span style='color:red;'> A </span>" : studentSubject.internalMark : "-"}}</td>
                                    <td {{addedAttribute}} class="hideMarks text-center noborder-r-0">
                                        {% if studentSubject.excludeSubjectFromTotal == "1" %}
                                            <span > - </span> 
                                        {% else %}
                                            {% if studentSubject.isExternal  != '1' %}
                                                <span > -</span> 
                                            {% else %}
                                                {% if studentSubject.attendanceStatus == "PRESENT" %}
                                                {{  studentSubject.externalMark }}
                                                {% elseif studentSubject.attendanceStatus == "MALPRACTICE" %}
                                                <span style="color:red;">MAL </span> 
                                                {% else %}
                                                <span style="color:red;"> A </span> 
                                                {% endif %}
                                            {% endif %}
                                        {% endif %} 
                                    </td>
                                    <td {{addedAttribute}} class="hideMarks text-center noborder-r-0">{{ (not studentSubject.showExcludeSubjectFromTotalWithDetails and studentSubject.excludeSubjectFromTotal == "1") ? "-" : studentSubject.markObtained }}</td>
                                    <td {{addedAttribute}} class="hideMarks text-center noborder-r-0">{{ (not studentSubject.showExcludeSubjectFromTotalWithDetails and studentSubject.excludeSubjectFromTotal == "1") ? "-" : studentSubject.gradePoint }}</td>
                                    <td {{addedAttribute}} class="hideMarks text-center noborder-r-0">{{ (not studentSubject.showExcludeSubjectFromTotalWithDetails and studentSubject.excludeSubjectFromTotal == "1") ? "-" : studentSubject.percentage }}</td>
                                    {% if studentSubject.failedStatus == "PASSED" %}
                                        <td class="text-center border-r-0">{{ studentSubject.excludeSubjectFromTotal == "1" ? 'P': studentSubject.grade }}</td>
                                    {% else %}
                                    <td class="text-center border-r-0">F</td>
                                    {% endif %}
                                    {% set isEnteredGroup = true %}
                                    {% set isEntered = true %}
                                {% endif %}
                            {% endif %}
                        {% endfor %}
                        {% if isEntered == false %}
                            <td {{addedAttribute}} class="hideMarks text-center noborder-r-0"> * </td>
                            <td {{addedAttribute}} class="hideMarks text-center noborder-r-0"> * </td>
                            <td {{addedAttribute}} class="hideMarks text-center noborder-r-0"> * </td>
                            <td {{addedAttribute}} class="hideMarks text-center noborder-r-0"> * </td>
                            <td {{addedAttribute}} class="hideMarks text-center noborder-r-0"> * </td>
                            <td class="text-center border-r-0"> * </td>
                        {% endif %}
                    {% endfor %}
                    <td class="align-middle text-center border-r-0">{{ student.semesterCreditGradePoint}}</td>
                    <td class="align-middle text-center border-r-0">{{student.failedStatus == 'PASSED' ? 'Pass' : 'Fail'}}</td>
                    <td class="align-middle text-center border-r-0">{{ student.failedStatus == 'PASSED' ? student.semesterSgpa|number_format(student.roundOff, '.') : '*'}}</td>
                    <td class="align-middle text-center border-r-0">{{ student.semesterGrade}}</td>
                </tr>
            {% endfor %}
        </tbody>
        {% if data.showFooter %}
            {% set leftColSpan = (trcolSpan / 3)|round(0, 'floor') %}
            {% set rightColSpan = (trcolSpan / 3)|round(0, 'floor') %}
            {% set centerColSpan = trcolSpan - leftColSpan - rightColSpan %}
            <tr style="height:80px;">
                <td colspan="{{ leftColSpan }}" class="no-border" style="border:none; padding-top:60px; white-space:nowrap; text-align:left;" data-a-h='left' data-a-v='bottom'>
                    <strong>Prepared by</strong>
                </td>
                <td colspan="{{ centerColSpan }}" class="no-border" style="border:none; padding-top:60px; white-space:nowrap; text-align:center;" data-a-h='center' data-a-v='bottom'>
                    <strong>Checked By</strong>
                </td>
                <td colspan="{{ rightColSpan }}" class="no-border" style="border:none; padding-top:60px; white-space:nowrap; text-align:right;" data-a-h='right' data-a-v='bottom'>
                    <strong>Deputy Controller of Examinations</strong>
                </td>
            </tr>   
        {% endif %}
    </table>
</div>
