⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 report.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
                $table->no_sorting('feedbacktext');                    $table->column_class('picture', 'picture');                $table->column_class('fullname', 'bold');                $table->column_class('sumgrades', 'bold');                    $table->set_attribute('cellspacing', '0');                $table->set_attribute('id', 'attempts');                $table->set_attribute('class', 'generaltable generalbox');                    // Start working -- this is necessary as soon as the niceties are over                $table->setup();            } else if ($download =='ODS') {                require_once("$CFG->libdir/odslib.class.php");                    $filename .= ".ods";                // Creating a workbook                $workbook = new MoodleODSWorkbook("-");                // Sending HTTP headers                $workbook->send($filename);                // Creating the first worksheet                $sheettitle = get_string('reportoverview','quiz');                $myxls =& $workbook->add_worksheet($sheettitle);                // format types                $format =& $workbook->add_format();                $format->set_bold(0);                $formatbc =& $workbook->add_format();                $formatbc->set_bold(1);                $formatbc->set_align('center');                $formatb =& $workbook->add_format();                $formatb->set_bold(1);                $formaty =& $workbook->add_format();                $formaty->set_bg_color('yellow');                $formatc =& $workbook->add_format();                $formatc->set_align('center');                $formatr =& $workbook->add_format();                $formatr->set_bold(1);                $formatr->set_color('red');                $formatr->set_align('center');                $formatg =& $workbook->add_format();                $formatg->set_bold(1);                $formatg->set_color('green');                $formatg->set_align('center');                // Here starts workshhet headers                    $colnum = 0;                foreach ($headers as $item) {                    $myxls->write(0,$colnum,$item,$formatbc);                    $colnum++;                }                $rownum=1;            } else if ($download =='Excel') {                require_once("$CFG->libdir/excellib.class.php");                    $filename .= ".xls";                // Creating a workbook                $workbook = new MoodleExcelWorkbook("-");                // Sending HTTP headers                $workbook->send($filename);                // Creating the first worksheet                $sheettitle = get_string('reportoverview','quiz');                $myxls =& $workbook->add_worksheet($sheettitle);                // format types                $format =& $workbook->add_format();                $format->set_bold(0);                $formatbc =& $workbook->add_format();                $formatbc->set_bold(1);                $formatbc->set_align('center');                $formatb =& $workbook->add_format();                $formatb->set_bold(1);                $formaty =& $workbook->add_format();                $formaty->set_bg_color('yellow');                $formatc =& $workbook->add_format();                $formatc->set_align('center');                $formatr =& $workbook->add_format();                $formatr->set_bold(1);                $formatr->set_color('red');                $formatr->set_align('center');                $formatg =& $workbook->add_format();                $formatg->set_bold(1);                $formatg->set_color('green');                $formatg->set_align('center');                    $colnum = 0;                foreach ($headers as $item) {                    $myxls->write(0,$colnum,$item,$formatbc);                    $colnum++;                }                $rownum=1;            } else if ($download=='CSV') {                $filename .= ".txt";                    header("Content-Type: application/download\n");                header("Content-Disposition: attachment; filename=\"$filename\"");                header("Expires: 0");                header("Cache-Control: must-revalidate,post-check=0,pre-check=0");                header("Pragma: public");                    echo implode("\t", $headers)." \n";            }                    // Construct the SQL            $select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, ';            if ($qmsubselect) {                $select .=                    "(CASE " .                    "   WHEN $qmsubselect THEN 1" .                    "   ELSE 0 " .                    "END) AS gradedattempt, ";            }                        $select .= 'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .                     'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, ' .                    'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';                // This part is the same for all cases - join users and quiz_attempts tables            $from = 'FROM '.$CFG->prefix.'user u ';            $from .= 'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON qa.userid = u.id AND qa.quiz = '.$quiz->id;            if ($qmsubselect && $qmfilter){                $from .= ' AND '.$qmsubselect;            }            switch ($attemptsmode){                case QUIZ_REPORT_ATTEMPTS_ALL:                    // Show all attempts, including students who are no longer in the course                    $where = ' WHERE qa.id IS NOT NULL AND qa.preview = 0';                    break;                case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH:                    // Show only students with attempts                    $where = ' WHERE u.id IN (' .$allowedlist. ') AND qa.preview = 0 AND qa.id IS NOT NULL';                    break;                case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO:                    // Show only students without attempts                    $where = ' WHERE u.id IN (' .$allowedlist. ') AND qa.id IS NULL';                    break;                case QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS:                    // Show all students with or without attempts                    $where = ' WHERE u.id IN (' .$allowedlist. ') AND (qa.preview = 0 OR qa.preview IS NULL)';                    break;            }                $countsql = 'SELECT COUNT(DISTINCT('.sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, 0)').')) '.$from.$where;                            // Add table joins so we can sort by question grade            // unfortunately can't join all tables necessary to fetch all grades            // to get the state for one question per attempt row we must join two tables            // and there is a limit to how many joins you can have in one query. In MySQL it            // is 61. This means that when having more than 29 questions the query will fail.            // So we join just the tables needed to sort the attempts.            if(!$download && $sort = $table->get_sql_sort()) {                if (!$download && $detailedmarks) {                    $from .= ' ';                    $sortparts    = explode(',', $sort);                    $matches = array();                    foreach($sortparts as $sortpart) {                        $sortpart = trim($sortpart);                        if (preg_match('/^qsgrade([0-9]+)/', $sortpart, $matches)){                            $qid = intval($matches[1]);                            $select .=  ", qs$qid.grade AS qsgrade$qid, qs$qid.event AS qsevent$qid, qs$qid.id AS qsid$qid";                            $from .= "LEFT JOIN {$CFG->prefix}question_sessions qns$qid ON qns$qid.attemptid = qa.uniqueid AND qns$qid.questionid = $qid ";                            $from .=  "LEFT JOIN  {$CFG->prefix}question_states qs$qid ON qs$qid.id = qns$qid.newgraded ";                        } else {                            $newsort[] = $sortpart;                        }                    }                    $select .= ' ';                }            }                           if ($download){                $sort = '';            }            // Fix some wired sorting            if (empty($sort)) {                $sort = ' ORDER BY uniqueid';            } else {                $sort = ' ORDER BY '.$sort;            }                if (!$download) {                // Add extra limits due to initials bar                if($table->get_sql_where()) {                    $where .= ' AND '.$table->get_sql_where();                }                    if (!empty($countsql)) {                    $totalinitials = count_records_sql($countsql);                    if ($table->get_sql_where()) {                        $countsql .= ' AND '.$table->get_sql_where();                    }                    $total  = count_records_sql($countsql);                    }                    $table->pagesize($pagesize, $total);            }                // Fetch the attempts            if (!$download) {                $attempts = get_records_sql($select.$from.$where.$sort,                                        $table->get_page_start(), $table->get_page_size());            } else {                $attempts = get_records_sql($select.$from.$where.$sort);            }                        // Build table rows            if (!$download) {                $table->initialbars($totalinitials>20);            }            if ($attempts) {                if($detailedmarks) {                    //get all the attempt ids we want to display on this page                    //or to export for download.                    $attemptids = array();                    foreach ($attempts as $attempt){                        if ($attempt->attemptuniqueid > 0){                            $attemptids[] = $attempt->attemptuniqueid;                        }                    }                    $gradedstatesbyattempt = quiz_get_newgraded_states($attemptids, true, 'qs.id, qs.grade, qs.event, qs.question, qs.attempt');                }                foreach ($attempts as $attempt) {                        // Username columns.                    $row = array();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -