Beispiel #1
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $category = $this->_customdata['category'];
     $omega = new omega();
     //con esto se obtienen las unidades academicas de Omega
     $unidadesAcademicas = $omega->listarUnidadesAcademicas();
     $attributes = array('id' => 'unidad');
     $mform->addElement('select', 'idOmega', 'Unidad Académica', $unidadesAcademicas, $attributes);
     //con esto se obtienen los periodos acad�micos de Omega
     $periodosAcademicos = $omega->listarPeriodosAcademicos();
     $mform->addElement('select', 'idOmega', 'Periodo Académico', $periodosAcademicos);
     //lo siguiente permite desplegar una lista con todas las categorías de moodle anidadas
     $displaylist = coursecat::make_categories_list();
     $mform->addElement('select', 'category', 'Categoría Moodle', $displaylist);
     //Y finalmente un select simple para designar si está o no activo.
     $mform->addElement('select', 'activo', 'Activo', array(0 => 'Desactivar', 1 => 'Activar'));
     //Select para configurar si el campo está activo o no
     $this->add_action_buttons(true, 'Crear');
 }
Beispiel #2
0
 function AA_results_getTimingOmega($round, $arg = false, $noerror = false)
 {
     require './lib/results_track.lib.php';
     global $cfgInvalidResult, $strErrTimingWrongRegid, $cfgRoundStatus;
     $count_results = 0;
     $number_results = 0;
     $omega = new omega($noerror);
     if ($omega->is_configured() == false) {
         return;
     }
     $results = $omega->get_lstrslt();
     $status = $omega->get_lststatu();
     $infos = $omega->get_lstrrslt();
     //print_r($results);
     if (($results && $status && $infos) == false) {
         return;
     }
     $relay = AA_checkRelay(0, $round);
     if ($arg) {
         $sqladd = "AND ru.Status = " . $cfgRoundStatus['heats_done'];
     } else {
         $sqladd = "";
     }
     mysql_query("\r\n\t\tLOCK TABLES \r\n\t\t\tserie as s WRITE\r\n\t\t\t, resultat as r WRITE\r\n\t\t\t, resultat WRITE\r\n            , resultat as re READ\r\n\t\t\t, runde as ru WRITE\r\n            , runde WRITE\r\n\t\t\t, serienstart as sst READ\r\n            , serienstart as se READ \r\n            , serienstart as ss READ \r\n            , serie as s READ\r\n\t\t\t, start as st READ\r\n\t\t\t, anmeldung as a READ\r\n\t\t\t, disziplin_de READ\r\n            , disziplin_fr READ \r\n            , disziplin_it READ \r\n            , disziplin_de as d READ\r\n            , disziplin_fr as d READ \r\n            , disziplin_it as d READ \r\n\t\t\t, wettkampf READ\r\n            , wettkampf as w READ   \r\n\t\t\t, staffel as sf READ\r\n            , kategorie as k READ");
     $res_film = mysql_query("\r\n\t\tSELECT s.Film, ru.xWettkampf FROM \r\n\t\t\tserie as s\r\n\t\t\tLEFT JOIN runde as ru USING(xRunde)\r\n\t\tWHERE s.xRunde = {$round}\r\n\t\t{$sqladd}");
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         if ($relay) {
             $sql = "SELECT \r\n                        count(*) \r\n                   FROM\r\n                        serie as s\r\n                        LEFT JOIN serienstart as sst USING(xSerie)\r\n                        LEFT JOIN start as st USING(xStart)\r\n                        LEFT JOIN staffel as sf USING(xStaffel)\r\n                        LEFT JOIN resultat as r ON (sst.xSerienstart=r.xSerienstart)\r\n                   WHERE s.xRunde = " . $round;
         } else {
             $sql = "SELECT \r\n                        count(*) \r\n                   FROM\r\n                        serie as s\r\n                        LEFT JOIN serienstart as sst USING(xSerie)\r\n                        LEFT JOIN start as st USING(xStart)                          \r\n                        LEFT JOIN resultat as r ON (sst.xSerienstart=r.xSerienstart)\r\n                   WHERE s.xRunde = " . $round;
         }
         $res = mysql_query($sql);
         $row = mysql_fetch_array($res);
         if (mysql_errno() > 0) {
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             $number_results = $row[0];
         }
         while ($row_film = mysql_fetch_array($res_film)) {
             $nr = $row_film[0];
             $event = $row_film[1];
             // get only the official results (end of judgement)
             if ($infos[$nr][8] == 'Official') {
                 // save infos like wind
                 //$timingInf[$nr] = $infos[$nr];
                 $wind = $infos[$nr][5];
                 if ($wind == 'N/A') {
                     $wind = "";
                 } else {
                     $wind = substr($wind, 0, 5);
                     // Korrektur um auf allen Versionen der OMEGA-Zeitmessung korrekte positive Winde zu übermitteln
                     // Paul Rohrer LC Basel Juni 2014
                     if (substr($wind, 0, 1) == "-") {
                         $wind = "-" . trim(substr($wind, 1, 4));
                     } elseif (substr($wind, 0, 1) == "+") {
                         $wind = trim(substr($wind, 1, 4));
                     } else {
                         // positiver Wind ab der ersten Position zu lesen
                         $wind = trim(substr($wind, 0, 4));
                     }
                     // round fraction hundert up
                     $wind = ceil($wind * 10) / 10;
                     $wind = sprintf("%01.1f", $wind);
                 }
                 mysql_query("UPDATE serie as s SET Wind = '" . $wind . "'\r\n\t\t\t\t\t\tWHERE xRunde = {$round} AND Film = {$nr}");
                 foreach ($results as $val) {
                     $reaction_time = false;
                     if ($val[0] == $nr) {
                         // add results to timingRes (array key is the registration id of the athlete)
                         //$timingRes[$val[4]] = $val;
                         // get status text for id (ok, dns, dnf, dq)
                         //$timingRes[$val[4]][6] = $status[$val[6]][2];
                         switch ($status[$val[6]][2]) {
                             case "DNS":
                                 $perf = $cfgInvalidResult['DNS']['code'];
                                 $points = 0;
                                 break;
                             case "DNF":
                                 $perf = $cfgInvalidResult['DNF']['code'];
                                 $points = 0;
                                 break;
                             case "DQ":
                                 $perf = $cfgInvalidResult['DSQ']['code'];
                                 $points = 0;
                                 break;
                             default:
                                 $perf = ceil($val[7] / 10);
                                 if (floor($val[8]) == 0) {
                                     // perf = 0.  --> reaction time
                                     $reaction_time = true;
                                     break;
                                 }
                                 $sex = 'M';
                                 if (!$relay) {
                                     /*$sql = "SELECT Geschlecht
                                     		  FROM serienstart AS sst
                                     	 LEFT JOIN serie AS s USING ( xSerie )
                                     	 LEFT JOIN start AS st ON sst.xStart = st.xStart
                                     	 LEFT JOIN anmeldung AS a ON st.xAnmeldung = a.xAnmeldung
                                     	 LEFT JOIN athlet USING ( xAthlet )
                                     		 WHERE s.xRunde = ".$round."
                                     		   AND s.Film = ".$nr."
                                     		   AND a.Startnummer = ".$val[4].";";*/
                                     $sql_sex = "SELECT DISTINCT(k.Geschlecht) AS Geschlecht\r\n\t\t\t\t\t\t\t\t\t\t\t  FROM kategorie as k \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN wettkampf USING(xKategorie) \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN start AS st USING(xWettkampf)\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN serienstart AS sst  USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN serie AS s USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\t\t WHERE s.XRunde = " . $round . " \r\n\t\t\t\t\t\t\t\t\t\t\t   AND s.Film = " . $nr . ";";
                                     $query = mysql_query($sql_sex);
                                     if (mysql_errno() > 0) {
                                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                     }
                                     if ($query && mysql_num_rows($query) == 1) {
                                         $sex = mysql_result($query, 0, 'Geschlecht');
                                     }
                                 }
                         }
                         if (!$reaction_time) {
                             if ($relay == false) {
                                 $res = mysql_query("\r\n\t\t\t\t\t\t\t\t    SELECT xResultat, sst.xSerienstart FROM\r\n\t\t\t\t\t\t\t\t\t    resultat as r\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN serienstart as sst USING(xSerienstart)\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN serie as s USING (xSerie)\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN start as st ON sst.xStart = st.xStart\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN anmeldung as a ON st.xAnmeldung = a.xAnmeldung\r\n\t\t\t\t\t\t\t\t    WHERE s.xRunde = {$round}\r\n\t\t\t\t\t\t\t\t    AND s.Film = {$nr}\r\n\t\t\t\t\t\t\t\t    AND a.Startnummer = " . $val[4]);
                                 if (mysql_num_rows($res) == 0) {
                                     // insert result
                                     $res = mysql_query("\r\n\t\t\t\t\t\t\t\t\t    SELECT sst.xSerienstart FROM\r\n\t\t\t\t\t\t\t\t\t\t    serie as s\r\n\t\t\t\t\t\t\t\t\t\t    LEFT JOIN serienstart as sst USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\t    LEFT JOIN start as st USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\t    LEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\t\t    WHERE\ta.Startnummer = " . $val[4] . "\r\n\t\t\t\t\t\t\t\t\t    AND\ts.Film = {$nr}\r\n\t\t\t\t\t\t\t\t\t    AND\ts.xRunde = {$round}");
                                     if (mysql_num_rows($res) == 0) {
                                         // no athlete with this registration id is started
                                         if ($noerror == false) {
                                             AA_printErrorMsg($strErrTimingWrongRegid);
                                         }
                                     } else {
                                         $row = mysql_fetch_array($res);
                                         $count_results++;
                                         $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[0]);
                                         mysql_query("\r\n\t\t\t\t\t\t\t\t\t\t    INSERT INTO resultat\r\n\t\t\t\t\t\t\t\t\t\t    SET \tLeistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\t, xSerienstart = " . $row[0]);
                                         AA_StatusChanged(mysql_insert_id());
                                     }
                                 } else {
                                     // update
                                     $count_results++;
                                     $row = mysql_fetch_array($res);
                                     $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[1]);
                                     mysql_query("UPDATE resultat as r SET Leistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t    , Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t        WHERE xResultat = " . $row[0]);
                                     AA_StatusChanged($row[0]);
                                 }
                                 //
                             } else {
                                 // relay event
                                 //
                                 // set startnumber - 999 because of this omega trick (nbr = 999XXX)
                                 //$val[4] = substr($val[4],3); <-- changed
                                 /*	$res = mysql_query("
                                 			   	SELECT xResultat FROM
                                 					resultat as r
                                 					LEFT JOIN serienstart as sst USING(xSerienstart)
                                 					LEFT JOIN serie as s USING (xSerie)
                                 					LEFT JOIN start as st ON sst.xStart = st.xStart
                                 					LEFT JOIN staffel as sf ON st.xStaffel = a.xStaffel
                                 				WHERE s.xRunde = $round
                                 				AND s.Film = $nr
                                 				AND sf.Startnummer = ".$val[4]
                                 			); */
                                 $res = mysql_query("\r\n\t\t\t\t\t\t\t   \t\tSELECT \r\n\t\t\t\t\t\t\t   \t\t\tr.xResultat, sst.xSerienstart ,  k.Geschlecht\r\n\t\t\t\t\t\t\t   \t\tFROM\r\n\t\t\t\t\t\t\t\t\t\tserie as s\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN serienstart as sst USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN start as st USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN staffel as sf USING(xStaffel)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN resultat as r ON (sst.xSerienstart=r.xSerienstart)\r\n                                        LEFT JOIN kategorie AS k ON ( k.xKategorie = sf.xKategorie )\r\n\t\t\t\t\t\t\t\t\tWHERE s.xRunde = {$round}\r\n\t\t\t\t\t\t\t\t\tAND s.Film = {$nr}\r\n\t\t\t\t\t\t\t\t\tAND sf.Startnummer = " . $val[4]);
                                 if (mysql_errno() > 0) {
                                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                 }
                                 $row = mysql_fetch_array($res);
                                 if (mysql_num_rows($res) == 0) {
                                     // no athlete with this registration id is started
                                     if ($noerror == false) {
                                         AA_printErrorMsg($strErrTimingWrongRegid);
                                     }
                                 } else {
                                     $sex = $row[2];
                                     $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[1]);
                                     if (empty($row[0])) {
                                         // insert result
                                         $count_results++;
                                         mysql_query("\r\n\t\t\t\t\t\t\t\t\t\t\tINSERT INTO resultat\r\n\t\t\t\t\t\t\t\t\t\t\tSET \tLeistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\t\t, xSerienstart = " . $row[1]);
                                         AA_StatusChanged(mysql_insert_id());
                                     } else {
                                         // update
                                         $count_results++;
                                         mysql_query("UPDATE resultat as r SET Leistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE xResultat = " . $row[0]);
                                         AA_StatusChanged($row[0]);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // end foreach
                 // results updated, now set status for event time table
                 mysql_query("UPDATE runde as ru SET StatusZeitmessung = 1 WHERE xRunde = {$round}");
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 }
             }
         }
         // end while
     }
     mysql_query("UNLOCK TABLES");
     // all results from omega for this round and automatic ranking is 'y'
     if ($count_results == $number_results && $_SESSION['meeting_infos']['AutoRangieren'] == 'y') {
         $layout = AA_getDisciplineType($round);
         // type determines layout
         $_GET['arg'] = 'results_done';
         $autoRank = true;
         AA_results_Track($round, $layout, $autoRank);
         // ranking
     }
 }
Beispiel #3
0
/**
 * export start information on round for timing software
 *
 */
function AA_timing_setStartInfo($round, $silent = false)
{
    $timing = AA_timing_getTiming();
    if ($timing == "omega") {
        $omega = new omega();
        $omega->set_allFiles();
    } elseif ($timing == "alge") {
        $alge = new alge();
        $alge->export_round($round);
    } else {
        if (!$silent) {
            AA_printErrorMsg($GLOBALS['strErrTimingNotConfigured']);
        }
    }
}
Beispiel #4
0
$debug = false;
if ($options['debug']) {
    $debug = true;
}
cli_heading('Sync pictures');
// TODO: localize
$now = new DateTime();
echo $now->format('Y-m-d H:i:s');
$usersidnumber = $DB->get_records_sql("\n    SELECT * \n    FROM {user} AS u\n    WHERE u.username LIKE '%uai.cl' \n    AND (u.idnumber is null OR length(u.idnumber) = 0)");
echo count($usersidnumber) . " alumnos sin RUT\n";
$moodleusers = array();
foreach ($usersidnumber as $userinmoodle) {
    $moodleusers[$userinmoodle->email] = $userinmoodle;
}
echo "Conectandose a BD Omega\n";
$omega = new omega();
$usuariosOmega = $omega->obtieneImagenesUsuario();
echo count($usuariosOmega) . " alumnos encontrados en Omega\n";
$imagenesusuarios = obtiene_imagenes_usuarios();
echo count($imagenesusuarios) . " imágenes de alumnos encontrados\n";
// First fix id numbers as pictures are identified by idnumber
$total = 0;
$fixed = 0;
foreach ($usuariosOmega as $email => $usuario) {
    $total++;
    // Check if the user idnumber is missing
    if (isset($moodleusers[$email])) {
        $moodleuser = $moodleusers[$email];
        // Check that the idnumber has not been used before
        if ($userwithrut = $DB->get_record('user', array('idnumber' => $usuario['rut']))) {
            if ($moodleuser->id != $userwithrut->id) {