Forum Discussion
Gradebook percentage in moodle
function get_studentshtml
Line 784 approx. of /grade/report/grader/lib.php
//IF finalgrade is null, must be calculated
if ($grade->finalgrade=="") {
$sql="SELECT t.value FROM mdl_scorm_scoes_track t, mdl_grade_items g where g.id=".$grade->itemid." and
t.userid=".$grade->userid." and g.itemmodule='scorm' and g.iteminstance=t.scormid and t.element='cmi.suspend_data'
order by t.timemodified desc limit 1";
$rs = get_recordset_sql($sql);
while ($datos = rs_fetch_next_record($rs)) {
$registros=explode("|", $datos->value, 3);
}
$posicion=strpos($registros[1],"=");
$numDiapos=(int)substr($registros[1],$posicion+1);
$posicionIni=strpos($registros[2],"##,");
if ($posicionIni!=false) {
$posicionFin=strpos(substr($registros[2],$posicionIni),"#");
$strDiapos=substr($registros[2],$posicionIni+3,$posicionFin-($posicionIni+2));
$Diapos=explode(",", $strDiapos);
$totalDiapos=count($Diapos);
}
$grade->finalgrade=($numDiapos * 100) / $totalDiapos;
}
This code mus be applied in other scripts where the partial percentaje is empty