Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.15.1.23
$(function () {
new Chart(document.getElementById("bar_chart").getContext("2d"), getChartJs('bar'));
});
function getChartJs(type) {
var config = null;
var subject;
var conducted;
var attended;
var percent;
var parameters = "&screen=attendance";
var rgPerinfo;
$.ajax({
type: 'post',
url: 'src/attendance.php',
data:parameters,
async: false,
success: function(response)
{
response = JSON.parse(response);
subject = response.subject;
conducted = response.conducted;
attended = response.attended;
subcode = response.subcode;
subshort = response.subshort;
percent = response.percent;
rgPerinfo = response.rgPerinfo;
var { strRegno,strName,strDegree,strSemester,strExam } = rgPerinfo;
$("#studinfo").append(`<tr><td width='20%'><b>Reg. No. </td><td> : ${ strRegno }
</b></td></tr><tr><td width='20%'><b>Student Name </td><td> : ${ strName }
</b></td></tr><tr><td width='20%'><b>Degree </td><td> : ${ strDegree }</b></td></tr>
<tr><td width='20%'><b>Semester </td><td> : ${ strSemester + " - " + strExam }</b></td></tr>`);
var conducted_arr = $.map(conducted, (el) => { return parseInt($.trim(el)) });
var attend_arr = $.map(attended, (el) => { return parseInt($.trim(el)) });
var rgPercent = new Array();
var rgFillcolor = new Array();
for(let i in attend_arr)
{
rgPercent[i] = Math.round((attend_arr[i] * 100/conducted_arr[i])*100)/100;
if(rgPercent[i] >= 75.00)
rgFillcolor.push('rgb(57, 173, 68, 0.7)');
else
rgFillcolor.push('rgb(211, 29, 38, 0.7)');
}
if (type === 'bar') {
config = {
type: 'bar',
data: {
labels: subshort,
datasets: [{
label: "Conducted",
data: conducted_arr,
backgroundColor: 'rgba(0, 188, 212, 0.7)'
}, {
label: "Attended",
data: attend_arr,
backgroundColor: rgFillcolor
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
}
}
var table = `<table class="m-b-20 table table-condensed table-bordered table-striped table-hover">
<tr style = "height:40px;">
<th style = "width:8%;"><center>Sl. No. </center></th>
<th style = "width:10%;"><center>Subject Code</center></th>
<th style = "width:10%;"><center>Shortname</center></th>
<th><center>Subject Name</center></th>
<th style = "width:8%;"><center>Cond.</center></th>
<th style = "width:8%;"><center>Att.</center></th>
<th style = "width:8%;"><center>%</center></th>
</tr>`;
for(let i in subject)
{
table += `<tr>
<td><center> ${parseInt(i)+1} </center></td>
<td><center> ${subcode[i]} </center></td>
<td>${subshort[i]}</td>
<td>${subject[i]}</td>
<td><center>${conducted_arr[i]}</center></td>
<td><center>${attend_arr[i]}</center></td>
<td><center>${percent[i]}</center></td>
</tr>`;
}
table += `</table>`;
$('#att_table').html(table);
}
});
return config;
}
|