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

📄 report.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
        $table->column_class('id', 'numcol');        $table->column_class('credits', 'numcol');        $table->column_class('rcounts', 'numcol');        $table->column_class('rpercent', 'numcol');        $table->column_class('facility', 'numcol');        $table->column_class('qsd', 'numcol');        $table->column_class('disc_index', 'numcol');        $table->column_class('disc_coeff', 'numcol');        $table->column_suppress('id');        $table->column_suppress('qname');        $table->column_suppress('facility');        $table->column_suppress('qsd');        $table->column_suppress('disc_index');        $table->column_suppress('disc_coeff');        $table->set_attribute('cellspacing', '0');        $table->set_attribute('id', 'itemanalysis');        $table->set_attribute('class', 'generaltable generalbox');        // Start working -- this is necessary as soon as the niceties are over        $table->setup();        $tablesort = $table->get_sql_sort();        $sorts = explode(",",trim($tablesort));        if ($tablesort and is_array($sorts)) {            $sortindex = array();            $sortorder = array ();            foreach ($sorts as $sort) {                $data = explode(" ",trim($sort));                $sortindex[] = trim($data[0]);                $s = trim($data[1]);                if ($s=="ASC") {                    $sortorder[] = SORT_ASC;                } else {                    $sortorder[] = SORT_DESC;                }            }            if (count($sortindex)>0) {                $sortindex[] = "id";                $sortorder[] = SORT_ASC;                foreach($questions as $qid => $row){                    $index1[$qid] = $row[$sortindex[0]];                    $index2[$qid] = $row[$sortindex[1]];                }                array_multisort($index1, $sortorder[0], $index2, $sortorder[1], $questions);            }        }        $format_options = new stdClass;        $format_options->para = false;        $format_options->noclean = true;        $format_options->newlines = false;        // Now it is time to page the data, simply slice the keys in the array        $table->pagesize($pagesize, count($questions));        $start = $table->get_page_start();        $pagequestions = array_slice(array_keys($questions), $start, $pagesize);        foreach($pagequestions as $qnum) {            $q = $questions[$qnum];            $qid = $q['id'];            $question = get_record('question', 'id', $qid);            if (question_has_capability_on($question, 'edit') || question_has_capability_on($question, 'view')) {                $qnumber = " (".link_to_popup_window('/question/question.php?id='.$qid.'&amp;cmid='.$cm->id, 'editquestion', $qid, 450, 550, get_string('edit'), 'none', true ).") ";            } else {                $qnumber = $qid;            }            $qname = '<div class="qname">'.format_text($question->name." :  ", $question->questiontextformat, $format_options, $quiz->course).'</div>';            $qicon = print_question_icon($question, true);            $qreview = quiz_question_preview_button($quiz, $question);            $qtext = format_text($question->questiontext, $question->questiontextformat, $format_options, $quiz->course);            $qquestion = $qname."\n".$qtext."\n";            $responses = array();            foreach ($q['responses'] as $aid=>$resp){                $response = new stdClass;                if ($q['credits'][$aid] <= 0) {                    $qclass = 'uncorrect';                } elseif ($q['credits'][$aid] == 1) {                    $qclass = 'correct';                } else {                    $qclass = 'partialcorrect';                }                $response->credit = '<span class="'.$qclass.'">('.format_float($q['credits'][$aid],2).') </span>';                $response->text = '<span class="'.$qclass.'">'.format_text($resp, FORMAT_MOODLE, $format_options, $quiz->course).' </span>';                $count = $q['rcounts'][$aid].'/'.$q['count'];                $response->rcount = $count;                $response->rpercent =  '('.format_float($q['rcounts'][$aid]/$q['count']*100,0).'%)';                $responses[] = $response;            }            $facility = format_float($q['facility']*100,0)."%";            $qsd = format_float($q['qsd'],3);            $di = format_float($q['disc_index'],2);            $dc = format_float($q['disc_coeff'],2);            $response = array_shift($responses);            $table->add_data(array($qnumber."\n<br />".$qicon."\n ".$qreview, $qquestion, $response->text, $response->credit, $response->rcount, $response->rpercent, $facility, $qsd, $di, $dc));            foreach($responses as $response) {                $table->add_data(array('', '', $response->text, $response->credit, $response->rcount, $response->rpercent, '', '', '', ''));            }        }        print_heading_with_help(get_string("analysistitle", "quiz_analysis"),"itemanalysis", "quiz");        echo '<div id="tablecontainer">';        $table->print_html();        echo '</div>';        $this->print_options_form($quiz, $cm, $attemptselection, $lowmarklimit, $pagesize);        return true;    }    function print_options_form($quiz, $cm, $attempts, $lowlimit=0, $pagesize=QUIZ_REPORT_DEFAULT_PAGE_SIZE) {        global $CFG, $USER;        echo '<div class="controls">';        echo '<form id="options" action="report.php" method="post">';        echo '<fieldset class="invisiblefieldset">';        echo '<p class="quiz-report-options">'.get_string('analysisoptions', 'quiz').': </p>';        echo '<input type="hidden" name="id" value="'.$cm->id.'" />';        echo '<input type="hidden" name="q" value="'.$quiz->id.'" />';        echo '<input type="hidden" name="mode" value="analysis" />';        echo '<p><label for="menuattemptselection">'.get_string('attemptselection', 'quiz_analysis').'</label> ';        $options = array ( QUIZ_ALLATTEMPTS     => get_string("attemptsall", 'quiz_analysis'),                           QUIZ_HIGHESTATTEMPT => get_string("attemptshighest", 'quiz_analysis'),                           QUIZ_FIRSTATTEMPT => get_string("attemptsfirst", 'quiz_analysis'),                           QUIZ_LASTATTEMPT  => get_string("attemptslast", 'quiz_analysis'));        choose_from_menu($options, "attemptselection", "$attempts", "");        echo '</p>';        echo '<p><label for="lowmarklimit">'.get_string('lowmarkslimit', 'quiz_analysis').'</label> ';        echo '<input type="text" id="lowmarklimit" name="lowmarklimit" size="1" value="'.$lowlimit.'" /> % </p>';        echo '<p><label for="pagesize">'.get_string('pagesize', 'quiz_analysis').'</label> ';        echo '<input type="text" id="pagesize" name="pagesize" size="1" value="'.$pagesize.'" /></p>';        echo '<p><input type="submit" value="'.get_string('go').'" />';        helpbutton("analysisoptions", get_string("analysisoptions",'quiz_analysis'), 'quiz');        echo '</p>';        echo '</fieldset>';        echo '</form>';        echo '</div>';        echo "\n";        echo '<table class="boxaligncenter"><tr>';        $options = array();        $options["id"] = "$cm->id";        $options["q"] = "$quiz->id";        $options["mode"] = "analysis";        $options['sesskey'] = $USER->sesskey;        $options["noheader"] = "yes";        echo '<td>';        $options["download"] = "ODS";        print_single_button("report.php", $options, get_string("downloadods"));        echo "</td>\n";        echo '<td>';        $options["download"] = "Excel";        print_single_button("report.php", $options, get_string("downloadexcel"));        echo "</td>\n";        if (file_exists("$CFG->libdir/phpdocwriter/lib/include.php")) {            echo '<td>';            $options["download"] = "OOo";            print_single_button("report.php", $options, get_string("downloadooo", "quiz_analysis"));            echo "</td>\n";        }        echo '<td>';        $options["download"] = "CSV";        print_single_button('report.php', $options, get_string("downloadtext"));        echo "</td>\n";        echo "<td>";        helpbutton('analysisdownload', get_string('analysisdownload', 'quiz_analysis'), 'quiz');        echo "</td>\n";        echo '</tr></table>';}    function report_question_stats(&$q, &$attemptscores, &$questionscores, $top, $bottom) {        $qstats = array();        $qid = $q['id'];        $top_scores = $top_count = 0;        $bottom_scores = $bottom_count = 0;        foreach ($questionscores as $aid => $qrow){            if (isset($qrow[$qid])){                $qstats[] =  array($attemptscores[$aid],$qrow[$qid]);                if ($attemptscores[$aid]>=$top){                    $top_scores +=$qrow[$qid];                    $top_count++;                }                if ($attemptscores[$aid]<=$bottom){                    $bottom_scores +=$qrow[$qid];                    $bottom_count++;                }            }        }        $n = count($qstats);        $sumx = stats_sumx($qstats, array(0,0));        $sumg = $sumx[0];        $sumq = $sumx[1];        $sumx2 = stats_sumx2($qstats, array(0,0));        $sumg2 = $sumx2[0];        $sumq2 = $sumx2[1];        $sumxy = stats_sumxy($qstats, array(0,0));        $sumgq = $sumxy[0];        $q['count'] = $n;        $q['facility'] = $sumq/$n;        if ($n<2) {            $q['qsd'] = sqrt(($sumq2 - $sumq*$sumq/$n)/($n));            $gsd = sqrt(($sumg2 - $sumg*$sumg/$n)/($n));        } else {            $q['qsd'] = sqrt(($sumq2 - $sumq*$sumq/$n)/($n-1));            $gsd = sqrt(($sumg2 - $sumg*$sumg/$n)/($n-1));        }        $q['disc_index'] = ($top_scores - $bottom_scores)/max($top_count, $bottom_count, 1);        $div = $n*$gsd*$q['qsd'];        if ($div!=0) {            $q['disc_coeff'] = ($sumgq - $sumg*$sumq/$n)/$div;        } else {            $q['disc_coeff'] = -999;        }        return $q;    }    function Export_Excel(&$questions, $filename) {        global $CFG;        require_once("$CFG->libdir/excellib.class.php");    /// Calculate file name        $filename .= ".xls";    /// Creating a workbook        $workbook = new MoodleExcelWorkbook("-");    /// Sending HTTP headers        $workbook->send($filename);    /// Creating the first worksheet        $sheettitle = get_string('reportanalysis','quiz_analysis');        $myxls =& $workbook->add_worksheet($sheettitle);    /// format types        $format =& $workbook->add_format();        $format->set_bold(0);        $formatbc =& $workbook->add_format();        $formatbc->set_bold(1);        $formatb =& $workbook->add_format();        $formatb->set_bold(1);        $formaty =& $workbook->add_format();        $formaty->set_bg_color('yellow');        $formatyc =& $workbook->add_format();        $formatyc->set_bg_color('yellow'); //bold text on yellow bg        $formatyc->set_bold(1);        $formatyc->set_align('center');        $formatc =& $workbook->add_format();        $formatc->set_align('center');        $formatbc->set_align('center');        $formatbpct =& $workbook->add_format();

⌨️ 快捷键说明

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