}
        echo "Processing the table " . $tableName . "\n";
        $filePath = "seed/" . snake_to_camel($tableName) . "TableSeeder.php";
        $file = fopen($filePath, "w");
        $firstRow = ignore_timestamps(mysql_fetch_assoc($result));
        $truncate = isset($opts['t']) ? true : false;
        fwrite($file, get_head($tableName, $truncate));
        if ($firstRow) {
            print_comparison(array_keys($firstRow), $columns);
            mysql_data_seek($result, 0);
            while ($row = ignore_timestamps(mysql_fetch_assoc($result))) {
                $newRow = [];
                foreach ($columns as $field) {
                    $newRow[$field] = isset($row[$field]) ? $row[$field] : "";
                }
                $line = format_row($newRow);
                fwrite($file, $line);
            }
        }
        fwrite($file, get_tail());
        echo "File " . $filePath . " created\n";
        fclose($file);
    }
}
mysql_close($conn);
function print_comparison($array1, $array2)
{
    $result = "[";
    $ignored = array_diff($array1, $array2);
    foreach ($ignored as $field) {
        $result .= "-" . $field . ",";
Exemplo n.º 2
0
function format_row_duration($col, &$def, &$data)
{
    if (isset($data['LASTCHANGE']) && $data['LASTCHANGE'] == 0) {
        echo '<span>&mdash;</span>';
        return;
    }
    return format_row($col, $def, $data);
}
Exemplo n.º 3
0
function format_table(&$osv)
{
    $rows = $osv['text'];
    $b = array();
    $c = array();
    $d = array();
    getBalls($osv['results'], $b, $c, $d);
    //===begin table===
    $result = '<table border="1">';
    //===head===
    $result .= '<thead><tr><th>Фамилия, имя</th>';
    $res = mysql_query("select problem.name from mdl_problemstatement problemstatement join mdl_problemstatement_problem problem on (problem.id=problemstatement.problem_id) order by problemstatement.id");
    // where course=...
    if (!$res) {
        print mysql_error();
    }
    while ($row = mysql_fetch_assoc($res)) {
        $result .= '<th>' . $row['name'] . '</th>';
    }
    $result .= '<th>Количество решенных задач</th><th>Баллы за решение задач</th></tr></thead>';
    //===foot===
    $result .= '<tfoot><tr><td>Количество верных решений</td>';
    $res = mysql_query("select id,name from mdl_problemstatement order by id");
    //where course=...
    if (!$res) {
        print mysql_error();
    }
    while ($problemstatementrow = mysql_fetch_assoc($res)) {
        $problemstatementid = $problemstatementrow['id'];
        $i = 0;
        $res1 = mysql_query("select id,deleted from mdl_user where id>25 and deleted=0");
        // where group = ...
        if (!$res1) {
            print mysql_error();
        }
        while ($users = mysql_fetch_assoc($res1)) {
            $userid = $users['id'];
            $res2 = mysql_query("select count(submissions.succeeded) from mdl_problemstatement_submissions submissions where (submissions.problemstatement={$problemstatementid}) and (submissions.userid={$userid}) and (submissions.succeeded=1) and (submissions.processed=1)");
            if (!$res2) {
                print mysql_error();
            }
            $count = mysql_fetch_row($res2);
            $count = $count[0];
            if ($count > 0) {
                ++$i;
            }
        }
        $result .= '<td>' . $i . '</td>';
    }
    $result .= '<td></td><td></td></tr>';
    $result .= '<tr><td>Баллы за задачу</td>';
    foreach ($b as $id => $ball) {
        $result .= "<td>{$ball}</td>";
    }
    $result .= '<td></td><td></td></tr>';
    $result .= '</tfoot>';
    //===content===
    $result .= '<tbody>';
    foreach ($rows as $key => $row) {
        if ($row) {
            $result .= '<tr>' . format_row($row) . "<td>" . $c[$key] . "</td>" . '</tr>';
        }
    }
    //===end table===
    $result .= '</tbody></table>';
    $d2 = array();
    $max_key = max(array_keys($d));
    for ($i = 0; $i <= $max_key; ++$i) {
        if (array_key_exists($i, $d)) {
            $d2[$i] = $d[$i];
        } else {
            $d2[$i] = 0;
        }
    }
    $str = implode(';', $d2);
    global $grsize;
    $result .= '<p><font size="6"><strong>Распределение баллов</strong></font></p>';
    $result .= "<img src='histogram.php?grsize={$grsize}&vals={$str}'></img>";
    return $result;
}