Could anyone help me please - I need the below code in stored procedure format,its too urgent i have a deadline
function scormtrack($user,$courid)
{
$scormfile= get_records_sql('SELECT * FROM mdl_grade_grades gg, mdl_grade_items gi, mdl_scorm sc, mdl_scorm_scoes_track ssc WHERE gg.userid ='.$user.' AND usermodified ='.$user.' AND gi.courseid ='.$courid.' AND gi.id = gg.itemid AND sc.id = gi.iteminstance AND ssc.scormid = sc.id AND ssc.userid ='.$user.'');
$sq='SELECT * FROM mdl_grade_grades gg, mdl_grade_items gi, mdl_scorm sc, mdl_scorm_scoes_track ssc WHERE gg.userid ='.$user.' AND usermodified ='.$user.' AND gi.courseid ='.$courid.' AND gi.id = gg.itemid AND sc.id = gi.iteminstance AND ssc.scormid = sc.id AND ssc.userid ='.$user.'';
echo $sq;
$sq='SELECT * FROM mdl_grade_grades gg, mdl_grade_items gi, mdl_scorm sc, mdl_scorm_scoes_track ssc WHERE gg.userid ='.$user.' AND usermodified ='.$user.' AND gi.courseid ='.$courid.' AND gi.id = gg.itemid AND sc.id = gi.iteminstance AND ssc.scormid = sc.id AND ssc.userid ='.$user.'';
echo $sq;
foreach($scormfile as $scormval)
{
$userid=$scormval->userid;
$scormid=$scormval->scormid;
$attempt=$scormval->attempt;
$element=$scormval->element;
$value=$scormval->value;
$timemodified=$scormval->timemodified;
$scoid=$scormval->scoid;
$sqlabc="INSERT INTO mdl_scorm_scoes_tract_bk (userid,scormid,scoid,attempt,element,value,timemodified) values($userid,$scormid,$scoid,$attempt,'$element','$value',$timemodified)";
echo $sqlabc;
$myquresult = mysql_query($sqlabc ) or die ('MySQL Error processing courses' . mysql_error());
$delsql='DELETE FROM mdl_scorm_scoes_track where userid='.$userid.' AND scormid='.$scormid.'';
echo $delsql;
$myquresult = mysql_query($delsql ) or die ('MySQL Error processing courses' . mysql_error());
}
}