// nothing to send. empty file
            $msg->addError('ENROLLMENT_NONE_FOUND');
        } else {
            $this_row = "First Name, Last Name, Email, Grade\n";
            foreach ($rows_enrolled as $row) {
                // retrieve title
                $sql_title = "(SELECT g.gradebook_test_id, t.title" . " FROM %sgradebook_tests g, %stests t" . " WHERE g.type='ATutor Test'" . " AND g.id = t.test_id" . " AND g.gradebook_test_id=%d)" . " UNION (SELECT g.gradebook_test_id, a.title" . " FROM %sgradebook_tests g, %sassignments a" . " WHERE g.type='ATutor Assignment'" . " AND g.id = a.assignment_id" . " AND g.gradebook_test_id=%d)" . " UNION (SELECT gradebook_test_id, title " . " FROM %sgradebook_tests" . " WHERE type='External'" . " AND gradebook_test_id=%d)";
                $row_title = queryDB($sql_title, array(TABLE_PREFIX, TABLE_PREFIX, $_POST['gradebook_test_id'], TABLE_PREFIX, TABLE_PREFIX, $_POST['gradebook_test_id'], TABLE_PREFIX, $_POST['gradebook_test_id']), TRUE);
                // retrieve grade
                $sql_grade = "SELECT grade FROM %sgradebook_detail WHERE gradebook_test_id=%d AND member_id=%d";
                $row_grade = queryDB($sql_grade, array(TABLE_PREFIX, $_POST["gradebook_test_id"], $row["member_id"]), TRUE);
                $grade = $row_grade["grade"];
                $this_row .= quote_csv($row['first_name']) . ",";
                $this_row .= quote_csv($row['last_name']) . ",";
                $this_row .= quote_csv($row['email']) . ",";
                $this_row .= quote_csv($grade) . "\n";
            }
            header('Content-Type: text/csv');
            header('Content-transfer-encoding: binary');
            header('Content-Disposition: attachment; filename="grade_' . $row_title["title"] . '.csv"');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            echo $this_row;
            exit;
        }
    }
}
require AT_INCLUDE_PATH . 'header.inc.php';
?>
<form method="post" action="<?php 
                     } else {
                         if ($_POST['alumni']) {
                             $condition = "AND approved = 'a'";
                         }
                     }
                 }
             }
         }
     }
 }
 $sql = "SELECT m.first_name, m.last_name, m.email \n\t\t\t\tFROM %scourse_enrollment cm JOIN %smembers m ON cm.member_id = m.member_id JOIN %scourses c ON (cm.course_id = c.course_id AND cm.member_id <> c.member_id)\tWHERE cm.course_id = %d " . $condition . "ORDER BY m.last_name";
 $rows_enrollment = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, TABLE_PREFIX, $_SESSION['course_id']));
 foreach ($rows_enrollment as $row) {
     $this_row .= quote_csv($row['first_name']) . ",";
     $this_row .= quote_csv($row['last_name']) . ",";
     $this_row .= quote_csv($row['email']) . "\n";
 }
 if ($this_row) {
     header('Content-Type: text/csv');
     header('Content-transfer-encoding: binary');
     header('Content-Disposition: attachment; filename="course_list_' . $_SESSION['course_id'] . '.csv"');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     echo $this_row;
 } else {
     // nothing to send. empty file
     $msg->addError('ENROLLMENT_NONE_FOUND');
     header('Location: export_course_list.php');
 }
 exit;
Example #3
0
     if ($row['to_cid'] == '' || $row['to_cid'] == '0') {
         $this_row .= '"0",';
     } else {
         if ($title_refs[$row['to_cid']] == '') {
             $this_row .= quote_csv(_AT('deleted')) . ',';
         } else {
             if ($title_refs[$row['to_cid']] != '') {
                 $this_row .= quote_csv($title_refs[$row['to_cid']]) . ",";
             } else {
                 $this_row .= '"0",';
             }
         }
     }
     $this_row .= quote_csv(_AT($title_refs2[$row['g']])) . ",";
     $this_row .= AT_date(_AT('forum_date_format'), $row['timestamp'], AT_DATE_UNIX_TIMESTAMP) . ",";
     $this_row .= quote_csv($row['duration']) . "\n";
 }
 if (!@opendir(AT_CONTENT_DIR . 'export/')) {
     mkdir(AT_CONTENT_DIR . 'export/', 0777);
 }
 $fp = @fopen(AT_CONTENT_DIR . 'export/' . $name . '_tracking.csv', 'w');
 if (!$fp) {
     $errors = array('CSV_FAILED', $name);
     $msg->printErrors($errors);
     exit;
 }
 @fputs($fp, $this_row);
 @fclose($fp);
 @readfile(AT_CONTENT_DIR . 'export/' . escapeshellcmd($name) . '_tracking.csv');
 @unlink(AT_CONTENT_DIR . 'export/' . escapeshellcmd($name) . '_tracking.csv');
 exit;
Example #4
0
require AT_INCLUDE_PATH . 'vitals.inc.php';
authenticate(AT_PRIV_CONTENT);
function quote_csv($line)
{
    $line = str_replace('"', '""', $line);
    $line = str_replace("\n", '\\n', $line);
    $line = str_replace("\r", '\\r', $line);
    $line = str_replace("", '\\0', $line);
    return '"' . $line . '"';
}
$name = str_replace(" ", "_", $_SESSION['course_title']);
$name = str_replace("'", "", $name);
header('Content-Type: text/csv');
header('Content-Disposition: inline; filename="' . $name . '_tracking.csv"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
$file_row = "page,member,visits,duration,timestamp";
$file_row .= "\n";
$sql = "SELECT C.title, M.login, MT.counter, SEC_TO_TIME(MT.duration) AS time, MT.last_accessed\n\t\t\tFROM %scontent C, %smembers M, %smember_track MT\n\t\t\tWHERE M.member_id=MT.member_id AND C.content_id=MT.content_id AND C.course_id=%d\n\t\t\tORDER BY C.title, M.login ASC";
$rows_tracking = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, TABLE_PREFIX, $_SESSION['course_id']));
foreach ($rows_tracking as $row) {
    $file_row .= quote_csv($row['title']) . ",";
    $file_row .= quote_csv($row['login']) . ",";
    $file_row .= quote_csv($row['counter']) . ",";
    $file_row .= quote_csv($row['time']) . ",";
    $file_row .= AT_date(_AT('forum_date_format'), $row['last_accessed']) . ",";
    $file_row .= "\n";
}
echo $file_row;
exit;
Example #5
0
function display_test_info($row, $anonymous)
{
    global $random, $num_questions, $total_weight, $questions, $total_score, $table_content, $csv_content;
    global $passscore, $passpercent;
    global $q_sql, $db;
    $row['login'] = $row['login'] ? $row['login'] : '******' . _AT('guest') . ' -';
    $table_content .= '<tr>';
    if ($anonymous == 1) {
        $table_content .= '<td align="center">' . _AT('anonymous') . '</td>';
        $csv_content .= quote_csv(_AT('anonymous')) . ', ';
    } else {
        $table_content .= '<td align="center">' . $row['login'] . '</td>';
        $csv_content .= quote_csv($row['login']) . ', ';
    }
    $startend_date_format = _AT('startend_date_format');
    $table_content .= '<td align="center">' . AT_date($startend_date_format, $row['date_taken'], AT_DATE_MYSQL_DATETIME) . '</td>';
    $csv_content .= quote_csv($row['date_taken']) . ', ';
    if ($passscore != 0) {
        $table_content .= '<td align="center">' . $passscore . '</td>';
        $csv_content .= $passscore . ', ';
    } elseif ($passpercent != 0) {
        $table_content .= '<td align="center">' . $passpercent . '%</td>';
        $csv_content .= $passpercent . '%, ';
    } else {
        $table_content .= '<td align="center">' . _AT('na') . '</td>';
        $csv_content .= _AT('na') . ', ';
    }
    $table_content .= '<td align="center">' . $row['final_score'] . '/' . $total_weight . '</td>';
    $csv_content .= $row['final_score'] . '/' . $total_weight;
    $total_score += $row['final_score'];
    $answers = array();
    /* need this, because we dont know which order they were selected in */
    //get answers for this test result
    $sql = "SELECT question_id, score FROM " . TABLE_PREFIX . "tests_answers WHERE result_id={$row['result_id']} AND question_id IN ({$q_sql})";
    $result2 = mysql_query($sql, $db);
    if ($result2) {
        while ($row2 = mysql_fetch_assoc($result2)) {
            $answers[$row2['question_id']] = $row2['score'];
        }
    }
    //print answers out for each question
    for ($i = 0; $i < $num_questions; $i++) {
        $questions[$i]['score'] += $answers[$questions[$i]['question_id']];
        $table_content .= '<td align="center">';
        if ($answers[$questions[$i]['question_id']] == '') {
            $table_content .= '<span style="color:#ccc;">-</span>';
            $csv_content .= ', -';
        } else {
            $table_content .= $answers[$questions[$i]['question_id']];
            $csv_content .= ', ' . $answers[$questions[$i]['question_id']];
            if ($random) {
                $questions[$i]['count']++;
            }
        }
        $table_content .= '</td>';
    }
    $table_content .= '</tr>';
    // append guest information into CSV content if the test is taken by a guest
    if (substr($row['member_id'], 0, 2) == 'g_' || substr($row['member_id'], 0, 2) == 'G_') {
        $sql = "SELECT * FROM " . TABLE_PREFIX . "guests WHERE guest_id='" . $row['member_id'] . "'";
        $result3 = mysql_query($sql, $db);
        $row3 = mysql_fetch_assoc($result3);
        $csv_content .= ', ' . quote_csv($row3['name']) . ', ' . quote_csv($row3['organization']) . ', ' . quote_csv($row3['location']) . ', ' . quote_csv($row3['role']) . ', ' . quote_csv($row3['focus']);
    }
    $csv_content .= "\n";
}