}
 $table2->data[] = array("{$scrom_name} : " . $scorm->name);
 $sql = "SELECT COUNT(*) as count \n                FROM  {$CFG->prefix}scorm_scoes sss\n               \tWHERE sss.scorm = {$scormfull->threshold}\n\t\tAND sss.scormtype = 'sco'";
 $sco_count = 0;
 $get_countarray = $DB->get_records_sql($sql);
 foreach ($get_countarray as $value) {
     $sco_count = $value->count;
 }
 $user_grades_array = get_quiz_grades($quiz->id);
 $get_user = usersdata($course->id, $perpage * $page, $perpage);
 $usercount = count(usersdata($course->id));
 foreach ($get_user as $key => $value) {
     $getvalue = 0;
     $sql = "SELECT st.id,st.userid,st.scormid,st.scoid,st.attempt,st.element,st.value,st.timemodified\n                        FROM {$CFG->prefix}scorm_scoes_track st\n                        WHERE st.scormid ={$scormfull->threshold} and ( value='completed' or value='suspend')  and st.userid={$key}  group by st.scoid";
     $getqudata = $DB->get_records_sql($sql);
     $calculation_results = calculateInteTime(integrate_log($scormfull, $key));
     if (!empty($getqudata)) {
         $getvalue = round(count($getqudata) / $sco_count, 2);
     }
     $setjudg = get_string('starnopass', 'scormfull');
     if ($getvalue >= (int) $scormfull->thresholdvalue / 100) {
         $setjudg = get_string('strpass', 'scormfull');
         $setjudg = !$scormfull->report_add ? get_string('strpass', 'scormfull') : ($calculation_results >= $scormfull->report_value ? get_string('strpass', 'scormfull') : get_string('starnopass', 'scormfull'));
     }
     $table->data[] = array("<a href=\"{$CFG->wwwroot}/user/view.php?id={$key}&amp;course={$course->id}\">" . "{$value}</a><br />", $setjudg, !empty($user_grades_array[$key]) ? $user_grades_array[$key]->grade : $not_been_exam, !empty($user_grades_array[$key]) ? $user_grades_array[$key]->grade >= $scormfull->quid_score ? get_string('strpass', 'scormfull') : get_string('starnopass', 'scormfull') : "-");
 }
 $table2->data[] = array("{$connected_exam} : " . $quiz->name);
 $table2->data[] = array("{$Thresholdvalue} : " . $scormfull->thresholdvalue . "%");
 $report_data;
 if (!$scormfull->report_add) {
     $report_data = get_string('Not_joined_the_settings', 'scormfull');
function caculateScormTime($userID, $courseID, $scormID)
{
    global $DB;
    if (!($scorm = $DB->get_record("scorm", array("id" => $scormID)))) {
        return false;
    }
    $courseActionTime = calculateInteTime(integrate_log($userID, $courseID, $scormID));
    return $courseActionTime;
}
function getJudg($coursedata, $userdata, $quiz_id)
{
    global $CFG, $DB;
    $sql = "SELECT * FROM {$CFG->prefix}scormfull WHERE course={$coursedata->id} AND quid= {$quiz_id}";
    $scormfull = $DB->get_records_sql($sql);
    if (empty($scormfull)) {
        return;
    }
    foreach ($scormfull as $value) {
        $scormfull = $value;
    }
    if (!$scormfull->threshold) {
        if (!($scormdata = $DB->get_records("scorm", array("course" => $coursedata->id)))) {
            error("The scorm with id {$cm->instance} corresponding to this scormfull {$id} is missing");
        }
        $sql = "SELECT count(*) as allcount FROM {$CFG->prefix}scorm_scoes ss ,{$CFG->prefix}scorm sc WHERE ss.scorm=sc.id And sc.course={$coursedata->id} AND ss.scormtype = 'sco'";
        $all_count = $DB->get_records_sql($sql);
        foreach ($all_count as $value) {
            $all_count = $value->allcount;
        }
        $sum = 0;
        $calculation_results_sum = 0;
        foreach ($scormdata as $value) {
            $sql = "SELECT st.id,st.userid,st.scormid,st.scoid,st.attempt,st.element,st.value,st.timemodified\n                        FROM {$CFG->prefix}scorm_scoes_track st\n                        WHERE st.scormid ={$value->id} and (value='completed' or value='suspend')  and st.userid={$userdata->id}  group by st.scoid";
            $getcount = $DB->get_records_sql($sql);
            if (!empty($getcount)) {
                $sum = $sum + count($getcount);
            }
            if ($scormfull->report_add) {
                $calculation_results = calculateInteTime(integrate_log($scormfull, $userdata->id, $value->id));
                $calculation_results_sum = $calculation_results_sum + $calculation_results;
            }
        }
        $getvalue = round($sum / $all_count, 2);
        if ($getvalue < (int) $scormfull->thresholdvalue / 100) {
            redirect("{$CFG->wwwroot}/mod/scormfull/user.php?n={$quiz_id}");
        }
        if ($scormfull->report_add) {
            if ($calculation_results_sum >= $scormfull->report_value) {
            } else {
                redirect("{$CFG->wwwroot}/mod/scormfull/user.php?n={$quiz_id}");
            }
        }
    } else {
        if (!($scorm = $DB->get_record("scorm", array("id" => $scormfull->threshold)))) {
            error("The scorm with id {$cm->instance} corresponding to this scormfull {$scormfull->threshold} is missing");
        }
        $sql = "SELECT COUNT(*) as count \n                FROM  {$CFG->prefix}scorm_scoes sss\n                WHERE sss.scorm = {$scormfull->threshold}\n                AND sss.scormtype = 'sco'";
        $sco_count = 0;
        $get_countarray = $DB->get_records_sql($sql);
        foreach ($get_countarray as $value) {
            $sco_count = $value->count;
        }
        $sql = "SELECT st.id,st.userid,st.scormid,st.scoid,st.attempt,st.element,st.value,st.timemodified\n                        FROM {$CFG->prefix}scorm_scoes_track st\n                        WHERE st.scormid ={$scormfull->threshold} and (value='completed' or value='suspend')  and st.userid={$userdata->id} group by st.scoid";
        $getqudata = $DB->get_records_sql($sql);
        $getvalue = round(count($getqudata) / $sco_count, 2);
        if ($getvalue < (int) $scormfull->thresholdvalue / 100) {
            redirect("{$CFG->wwwroot}/mod/scormfull/user.php?n={$quiz_id}");
        }
        if ($scormfull->report_add) {
            $calculation_results = calculateInteTime(integrate_log($scormfull, $userdata->id));
            if ($calculation_results > $scormfull->report_value) {
            } else {
                redirect("{$CFG->wwwroot}/mod/scormfull/user.php?n={$quiz_id}");
            }
        }
    }
}
    $table2->data[] = array("{$Thresholdvalue} : " . $scormfull->thresholdvalue . "%");
} else {
    if (!($scorm = $DB->get_record("scorm", array("id" => $scormfull->threshold)))) {
        error("The scorm with id {$cm->instance} corresponding to this scormfull {$scormfull->threshold} is missing");
    }
    $table2->data[] = array("{$scrom_name} : " . $scorm->name);
    $sql = "SELECT COUNT(*) as count \n                FROM  {$CFG->prefix}scorm_scoes sss\n               \tWHERE sss.scorm = {$scormfull->threshold}\n\t\tAND sss.scormtype = 'sco'";
    $sco_count = 0;
    $get_countarray = $DB->get_records_sql($sql);
    foreach ($get_countarray as $value) {
        $sco_count = $value->count;
    }
    $sql = "SELECT st.id,st.userid,st.scormid,st.scoid,st.attempt,st.element,st.value,st.timemodified\n                        FROM {$CFG->prefix}scorm_scoes_track st\n                        WHERE st.scormid ={$scormfull->threshold} and (value='completed' or value='suspend')  and st.userid={$USER->id}  group by st.scoid";
    $getqudata = $DB->get_records_sql($sql);
    $user_grades_array = get_quiz_grades($quiz->id);
    $calculation_results = calculateInteTime(integrate_log($scormfull, $USER->id));
    if (!empty($getqudata)) {
        $getvalue = round(count($getqudata) / $sco_count, 2);
    }
    if ($getvalue >= 1) {
        $getvalue = 1;
    }
    $setjudg = get_string('starnopass', 'scormfull');
    $threshold_judg = get_string('starnopass', 'scormfull');
    if ($getvalue >= (int) $scormfull->thresholdvalue / 100) {
        $setjudg = get_string('strpass', 'scormfull');
        $threshold_judg = !$scormfull->report_add ? get_string('strpass', 'scormfull') : ($calculation_results >= $scormfull->report_value ? get_string('strpass', 'scormfull') : get_string('starnopass', 'scormfull'));
    }
    //			 $table->data[] = array (($USER->lastname.$USER->firstname),$setjudg,(($getvalue*100)."%"));
    $table->data[] = array("<a href=\"{$CFG->wwwroot}/user/view.php?id={$USER->id}&amp;course={$course->id}\">" . "{$USER->lastname}{$USER->firstname}</a><br />", $setjudg, $getvalue * 100 . "%", $calculation_results, !$scormfull->report_add ? "-" : ($calculation_results >= $scormfull->report_value ? get_string('strpass', 'scormfull') : get_string('starnopass', 'scormfull')));
    $table3->data[] = array("<a href=\"{$CFG->wwwroot}/user/view.php?id={$USER->id}&amp;course={$course->id}\">" . "{$USER->lastname}{$USER->firstname}</a><br />", $threshold_judg, !empty($user_grades_array[$USER->id]) ? $user_grades_array[$USER->id]->grade : $not_been_exam, !empty($user_grades_array[$USER->id]) ? $user_grades_array[$USER->id]->grade >= $scormfull->quid_score ? get_string('strpass', 'scormfull') : get_string('starnopass', 'scormfull') : "-");