Ejemplo n.º 1
0
/**
 * Process Job's results logged in a text file.
 * 
 * @param array $scan from table blended_scans
 */
function register_scannedjob($scan)
{
    global $CFG;
    global $scansfoldername;
    $jobid = $scan->id;
    $fieldspath = blended_getOMRFieldsetDir($scan);
    $logfile = blended_getOMRInputLogFilePath($scan);
    try {
        if ($logfile != 'null') {
            $logelements = read_log_file($logfile);
        }
        if (!isset($logelements) || count($logelements) == 0) {
            throw new OMRError("Log file is empty", OMRError::LOG_FILE_IS_EMPTY);
        }
    } catch (OMRError $e) {
        throw $e;
    }
    // open a transaction
    begin_sql();
    foreach ($logelements as $logelement) {
        try {
            //cada elemento es un registro de blended_images.
            $image_result = parse_log_elements($logelement);
            $image_result->jobid = $jobid;
            register_image($image_result);
            $acode = $image_result->activitycode;
            if ($acode != null) {
                if ($acode == 'Undetected') {
                    mtrace("Undetected activity code for result:" . $logelement);
                } else {
                    mtrace('<br>REGISTERING FIELDS...');
                    register_template_fields($image_result, $fieldspath);
                    mtrace('<br>REGISTERING RESULTS...');
                    register_result_files($image_result, $fieldspath);
                    mtrace('<br>CHECKING VALIDITY...');
                    check_invalid_results($image_result);
                }
            }
        } catch (Exception $e) {
            mtrace('OMRError: ' . $e->getMessage());
            register_exception($e, $jobid);
            $errorcode = $e->getCode();
            if ($errorcode == 5 or $errorcode == 6) {
                //print_object($e);
                //throw $e;
                continue;
                // process next result
            }
        }
    }
    mtrace('<br>UPDATING SCANJOB QUEUE...');
    update_record('blended_scans', $scan);
    // End the transaction
    commit_sql();
    return;
}
Ejemplo n.º 2
0
    } else {
        if ($mform->is_cancelled()) {
            //you need this section if you have a cancel button on your form
            //here you tell php what to do if your user presses cancel
            //probably a redirect is called for!
            $continue = "{$CFG->wwwroot}/mod/blended/scannedJob.php?a={$a}&jobid={$jobid}";
            echo $strprocesscancelled;
            print_continue($continue);
        } else {
            $evaluar = "Pasar a QUIZ";
            //echo "<BR>";
            $link = "<a href=\"evaluate.php?&a={$a}&acode={$acode}&jobid={$jobid}\">{$evaluar}</a>";
            echo "<center>{$link}</center><BR><BR>";
            $currentpage = "showdetails.php";
            display_details($mform, $jobid, $acode, $course, $a, $currentpage);
        }
    }
} catch (ResultsError $e) {
    if ($e->getCode() == ResultsError::TABLE_BLENDED_RESULTS_IS_EMPTY) {
        debugging("Fatal ResultsError: " . $e->getMessage());
        register_exception($e, $jobid);
    } else {
        debugging("Ha ocurrido un error durante la obtención de datos del formulario.<BR>");
        debugging("FATAL ResultsError: " . $e->getMessage() . "<BR>");
        register_exception($e, $jobid);
    }
}
echo "<BR><BR><center>";
helpbutton($page = 'showdetails', get_string('pagehelp', 'blended'), $module = 'blended', $image = true, $linktext = true, $text = '', $return = false, $imagetext = '');
echo "</center>";
print_footer($course);