当前位置: 首页>>代码示例>>PHP>>正文


PHP MoodleODSWorkbook::add_worksheet方法代码示例

本文整理汇总了PHP中MoodleODSWorkbook::add_worksheet方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleODSWorkbook::add_worksheet方法的具体用法?PHP MoodleODSWorkbook::add_worksheet怎么用?PHP MoodleODSWorkbook::add_worksheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoodleODSWorkbook的用法示例。


在下文中一共展示了MoodleODSWorkbook::add_worksheet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: user_download_ods

function user_download_ods($fields)
{
    global $CFG, $SESSION, $DB;
    require_once "{$CFG->libdir}/odslib.class.php";
    require_once $CFG->dirroot . '/user/profile/lib.php';
    $filename = clean_filename(get_string('users') . '.ods');
    $workbook = new MoodleODSWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] =& $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }
    $row = 1;
    foreach ($SESSION->bulk_users as $userid) {
        if (!($user = $DB->get_record('user', array('id' => $userid)))) {
            continue;
        }
        $col = 0;
        profile_load_data($user);
        foreach ($fields as $field => $unused) {
            $worksheet[0]->write($row, $col, $user->{$field});
            $col++;
        }
        $row++;
    }
    $workbook->close();
    die;
}
开发者ID:nmicha,项目名称:moodle,代码行数:31,代码来源:user_bulk_download.php

示例2: user_download_ods

function user_download_ods($fields, $extrafields = array())
{
    global $CFG, $SESSION, $DB;
    require_once "{$CFG->libdir}/odslib.class.php";
    require_once $CFG->dirroot . '/user/profile/lib.php';
    $filename = clean_filename(get_string('users') . '.ods');
    $workbook = new MoodleODSWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }
    $extrafield_sql = '';
    foreach ($extrafields as $n => $v) {
        $extrafield_sql .= " MAX(IF(muif.shortname = '" . $v->shortname . "', muid.data, NULL)) profile_field_" . $v->shortname . ",";
    }
    $extrafield_sql = rtrim($extrafield_sql, ",");
    $idstoload = $SESSION->bulk_users;
    $users = array();
    foreach (array_chunk($idstoload, 10000, true) as $user_id) {
        $userids = implode(",", $user_id);
        $users[] = $DB->get_records_sql("SELECT mu.*,\r\n                                {$extrafield_sql}\r\n                                FROM mdl_user AS mu\r\n                                LEFT JOIN mdl_user_info_data AS muid ON mu.id = muid.userid\r\n                                LEFT JOIN mdl_user_info_field AS muif ON muif.id = muid.fieldid\r\n                                WHERE mu.id IN ({$userids}) GROUP BY mu.id");
    }
    $row = 1;
    foreach ($users as $userdetails) {
        foreach ($userdetails as $user) {
            #if (!$user = $DB->get_record('user', array('id'=>$userid))) {
            #continue;
            #}
            $col = 0;
            #profile_load_data($user,$userfields);
            foreach ($fields as $field => $unused) {
                $worksheet[0]->write($row, $col, $user->{$field});
                $col++;
            }
            $row++;
        }
    }
    $workbook->close();
    die;
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:44,代码来源:user_bulk_download_list.php

示例3: export_report

/** Configurable Reports
 * A Moodle block for creating customizable reports
 * @package blocks
 * @author: Juan leyva <http://www.twitter.com/jleyvadelgado>
 * @date: 2009
 */
function export_report($report) {
    global $DB, $CFG;
    require_once($CFG->dirroot . '/lib/odslib.class.php');

    $table = $report->table;
    $matrix = array();
    $filename = 'report_' . (time()) . '.ods';

    if (!empty($table->head)) {
        $countcols = count($table->head);
        $keys = array_keys($table->head);
        $lastkey = end($keys);
        foreach ($table->head as $key => $heading) {
            $matrix[0][$key] = str_replace("\n", ' ', htmlspecialchars_decode(strip_tags(nl2br($heading))));
        }
    }

    if (!empty($table->data)) {
        foreach ($table->data as $rkey => $row) {
            foreach ($row as $key => $item) {
                $matrix[$rkey + 1][$key] = str_replace("\n", ' ', htmlspecialchars_decode(strip_tags(nl2br($item))));
            }
        }
    }

    $downloadfilename = clean_filename($filename);
    /// Creating a workbook
    $workbook = new MoodleODSWorkbook("-");
    /// Sending HTTP headers
    $workbook->send($downloadfilename);
    /// Adding the worksheet
    $myxls = & $workbook->add_worksheet($filename);

    foreach ($matrix as $ri => $col) {
        foreach ($col as $ci => $cv) {
            $myxls->write_string($ri, $ci, $cv);
        }
    }

    $workbook->close();
    exit;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:48,代码来源:export.php

示例4: display


//.........这里部分代码省略.........
                 $table->column_suppress($field);
             }
             foreach ($nosort as $field) {
                 $table->no_sorting($field);
             }
             $table->no_sorting('start');
             $table->no_sorting('finish');
             $table->no_sorting('score');
             $table->no_sorting('checkbox');
             $table->no_sorting('picture');
             foreach ($scoes as $sco) {
                 if ($sco->launch != '') {
                     $table->no_sorting('scograde' . $sco->id);
                 }
             }
             $table->column_class('picture', 'picture');
             $table->column_class('fullname', 'bold');
             $table->column_class('score', '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('report', 'scorm');
                 $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.
开发者ID:lucaboesch,项目名称:moodle,代码行数:67,代码来源:report.php

示例5: MoodleODSWorkbook

 function Export_ODS(&$questions, $filename)
 {
     global $CFG;
     require_once "{$CFG->libdir}/odslib.class.php";
     /// Calculate file name
     $filename .= ".ods";
     /// Creating a workbook
     $workbook = new MoodleODSWorkbook("-");
     /// 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();
     $formatbpct->set_bold(1);
     $formatbpct->set_num_format('0.0%');
     $formatbrt =& $workbook->add_format();
     $formatbrt->set_bold(1);
     $formatbrt->set_align('right');
     $formatred =& $workbook->add_format();
     $formatred->set_bold(1);
     $formatred->set_color('red');
     $formatred->set_align('center');
     $formatblue =& $workbook->add_format();
     $formatblue->set_bold(1);
     $formatblue->set_color('blue');
     $formatblue->set_align('center');
     /// Here starts workshhet headers
     $myxls->write_string(0, 0, $sheettitle, $formatb);
     $headers = array(get_string('qidtitle', 'quiz_analysis'), get_string('qtypetitle', 'quiz_analysis'), get_string('qnametitle', 'quiz_analysis'), get_string('qtexttitle', 'quiz_analysis'), get_string('responsestitle', 'quiz_analysis'), get_string('rfractiontitle', 'quiz_analysis'), get_string('rcounttitle', 'quiz_analysis'), get_string('rpercenttitle', 'quiz_analysis'), get_string('qcounttitle', 'quiz_analysis'), get_string('facilitytitle', 'quiz_analysis'), get_string('stddevtitle', 'quiz_analysis'), get_string('dicsindextitle', 'quiz_analysis'), get_string('disccoefftitle', 'quiz_analysis'));
     foreach ($headers as $key => $header) {
         $headers[$key] = preg_replace('/<br[^>]*>/', ' ', $header);
     }
     $col = 0;
     foreach ($headers as $item) {
         $myxls->write(2, $col, $item, $formatbc);
         $col++;
     }
     $row = 3;
     foreach ($questions as $q) {
         $rows = $this->print_row_stats_data($q);
         foreach ($rows as $rowdata) {
             $col = 0;
             foreach ($rowdata as $item) {
                 $myxls->write($row, $col, $item, $format);
                 $col++;
             }
             $row++;
         }
     }
     /// Close the workbook
     $workbook->close();
     exit;
 }
开发者ID:veritech,项目名称:pare-project,代码行数:71,代码来源:report.php

示例6: data_export_ods

/**
 * @global object
 * @param array $export
 * @param string $dataname
 * @param int $count
 * @param string
 */
function data_export_ods($export, $dataname, $count) {
    global $CFG;
    require_once("$CFG->libdir/odslib.class.php");
    $filename = clean_filename("{$dataname}-{$count}_record");
    if ($count > 1) {
        $filename .= 's';
    }
    $filename .= clean_filename('-' . gmdate("Ymd_Hi"));
    $filename .= '.ods';
    $filearg = '-';
    $workbook = new MoodleODSWorkbook($filearg);
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] =& $workbook->add_worksheet('');
    $rowno = 0;
    foreach ($export as $row) {
        $colno = 0;
        foreach($row as $col) {
            $worksheet[0]->write($rowno, $colno, $col);
            $colno++;
        }
        $rowno++;
    }
    $workbook->close();
    return $filename;
}
开发者ID:nottmoo,项目名称:moodle,代码行数:33,代码来源:lib.php

示例7: print_log_ods

function print_log_ods($course, $user, $date, $order = 'l.time DESC', $modname, $modid, $modaction, $groupid)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/odslib.class.php";
    if (!($logs = build_logs_array($course, $user, $date, $order, '', '', $modname, $modid, $modaction, $groupid))) {
        return false;
    }
    $courses = array();
    if ($course->id == SITEID) {
        $courses[0] = '';
        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
            foreach ($ccc as $cc) {
                $courses[$cc->id] = $cc->shortname;
            }
        }
    } else {
        $courses[$course->id] = $course->shortname;
    }
    $count = 0;
    $ldcache = array();
    $tt = getdate(time());
    $today = mktime(0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
    $strftimedatetime = get_string("strftimedatetime");
    $nroPages = ceil(count($logs) / (EXCELROWS - FIRSTUSEDEXCELROW + 1));
    $filename = 'logs_' . userdate(time(), get_string('backupnameformat', 'langconfig'), 99, false);
    $filename .= '.ods';
    $workbook = new MoodleODSWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $headers = array(get_string('course'), get_string('time'), get_string('ip_address'), get_string('fullnameuser'), get_string('action'), get_string('info'));
    // Creating worksheets
    for ($wsnumber = 1; $wsnumber <= $nroPages; $wsnumber++) {
        $sheettitle = get_string('logs') . ' ' . $wsnumber . '-' . $nroPages;
        $worksheet[$wsnumber] =& $workbook->add_worksheet($sheettitle);
        $worksheet[$wsnumber]->set_column(1, 1, 30);
        $worksheet[$wsnumber]->write_string(0, 0, get_string('savedat') . userdate(time(), $strftimedatetime));
        $col = 0;
        foreach ($headers as $item) {
            $worksheet[$wsnumber]->write(FIRSTUSEDEXCELROW - 1, $col, $item, '');
            $col++;
        }
    }
    if (empty($logs['logs'])) {
        $workbook->close();
        return true;
    }
    $formatDate =& $workbook->add_format();
    $formatDate->set_num_format(get_string('log_excel_date_format'));
    $row = FIRSTUSEDEXCELROW;
    $wsnumber = 1;
    $myxls =& $worksheet[$wsnumber];
    foreach ($logs['logs'] as $log) {
        if (isset($ldcache[$log->module][$log->action])) {
            $ld = $ldcache[$log->module][$log->action];
        } else {
            $ld = $DB->get_record('log_display', array('module' => $log->module, 'action' => $log->action));
            $ldcache[$log->module][$log->action] = $ld;
        }
        if ($ld && !empty($log->info)) {
            // ugly hack to make sure fullname is shown correctly
            if ($ld->mtable == 'user' and $ld->field == $DB->sql_concat('firstname', "' '", 'lastname')) {
                $log->info = fullname($DB->get_record($ld->mtable, array('id' => $log->info)), true);
            } else {
                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id' => $log->info));
            }
        }
        // Filter log->info
        $log->info = format_string($log->info);
        $log->info = strip_tags(urldecode($log->info));
        // Some XSS protection
        if ($nroPages > 1) {
            if ($row > EXCELROWS) {
                $wsnumber++;
                $myxls =& $worksheet[$wsnumber];
                $row = FIRSTUSEDEXCELROW;
            }
        }
        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
        $myxls->write_string($row, 0, format_string($courses[$log->course], true, array('context' => $coursecontext)));
        $myxls->write_date($row, 1, $log->time);
        $myxls->write_string($row, 2, $log->ip);
        $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext));
        $myxls->write_string($row, 3, $fullname);
        $myxls->write_string($row, 4, $log->module . ' ' . $log->action);
        $myxls->write_string($row, 5, $log->info);
        $row++;
    }
    $workbook->close();
    return true;
}
开发者ID:numbas,项目名称:moodle,代码行数:90,代码来源:lib.php

示例8: display


//.........这里部分代码省略.........
                    $table->column_suppress($field);
                }

                $table->no_sorting('start');
                $table->no_sorting('finish');
                $table->no_sorting('score');

                foreach ($scoes as $sco) {
                    if ($sco->launch != '') {
                        $table->no_sorting('scograde'.$sco->id);
                    }
                }

                $table->column_class('picture', 'picture');
                $table->column_class('fullname', 'bold');
                $table->column_class('score', '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('report', 'scorm');
                $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";
开发者ID:numbas,项目名称:moodle,代码行数:67,代码来源:report.php

示例9: display


//.........这里部分代码省略.........
             }
         }
     }
     if ($hasfeedback) {
         $tablecolumns[] = 'feedbacktext';
         $tableheaders[] = get_string('feedback', 'game');
     }
     if (!$download) {
         // Set up the table.
         $table = new flexible_table('mod-game-report-overview-report');
         $table->define_columns($tablecolumns);
         $table->define_headers($tableheaders);
         $table->define_baseurl($CFG->wwwroot . '/mod/game/report.php?mode=overview&amp;id=' . $cm->id . '&amp;noattempts=' . $noattempts . '&amp;detailedmarks=' . $detailedmarks . '&amp;pagesize=' . $pagesize);
         $table->sortable(true);
         $table->collapsible(true);
         $table->column_suppress('picture');
         $table->column_suppress('fullname');
         $table->column_class('picture', 'picture');
         $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', 'game');
             $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.
             $headers = array(get_string('fullname'), get_string('startedon', 'game'), get_string('timecompleted', 'game'), get_string('attemptduration', 'game'));
             if ($game->grade) {
                 $headers[] = get_string('grade', 'game') . '/' . $game->grade;
             }
             if ($detailedmarks) {
                 foreach ($questionids as $id) {
                     $headers[] = '#' . $questions[$id]->number;
                 }
             }
             if ($hasfeedback) {
                 $headers[] = get_string('feedback', 'game');
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:67,代码来源:report.php

示例10: MoodleODSWorkbook

    echo $OUTPUT->notification(get_string('nocertificatesissued', 'certificate'));
    echo $OUTPUT->footer($course);
    exit;
}
// Get extra fields to show the user.
$extrafields = get_extra_user_fields($context);
if ($download == "ods") {
    require_once "{$CFG->libdir}/odslib.class.php";
    // Calculate file name
    $filename = certificate_get_certificate_filename($certificate, $cm, $course) . '.ods';
    // Creating a workbook
    $workbook = new MoodleODSWorkbook("-");
    // Send HTTP headers
    $workbook->send($filename);
    // Creating the first worksheet
    $myxls = $workbook->add_worksheet($strreport);
    // Print names of all the fields
    $myxls->write_string(0, 0, get_string("lastname"));
    $myxls->write_string(0, 1, get_string("firstname"));
    $nextposition = 2;
    foreach ($extrafields as $field) {
        $myxls->write_string(0, $nextposition, get_user_field_name($field));
        $nextposition++;
    }
    $myxls->write_string(0, $nextposition, get_string("group"));
    $myxls->write_string(0, $nextposition + 1, $strdate);
    $myxls->write_string(0, $nextposition + 2, $strgrade);
    $myxls->write_string(0, $nextposition + 3, $strcode);
    // Generate the data for the body of the spreadsheet
    $i = 0;
    $row = 1;
开发者ID:ccle,项目名称:moodle-mod_certificate,代码行数:31,代码来源:report.php

示例11: offlinequiz_download_partlist

/**
 * Serves a list of participants as a file.
 *
 * @param unknown_type $offlinequiz
 * @param unknown_type $fileformat
 * @param unknown_type $coursecontext
 * @param unknown_type $systemcontext
 */
function offlinequiz_download_partlist($offlinequiz, $fileformat, &$coursecontext, &$systemcontext)
{
    global $CFG, $DB, $COURSE;
    offlinequiz_load_useridentification();
    $offlinequizconfig = get_config('offlinequiz');
    $filename = clean_filename(get_string('participants', 'offlinequiz') . $offlinequiz->id);
    // First get roleids for students from leagcy.
    if (!($roles = get_roles_with_capability('mod/offlinequiz:attempt', CAP_ALLOW, $systemcontext))) {
        print_error("No roles with capability 'mod/offlinequiz:attempt' defined in system context");
    }
    $roleids = array();
    foreach ($roles as $role) {
        $roleids[] = $role->id;
    }
    list($csql, $cparams) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
    list($rsql, $rparams) = $DB->get_in_or_equal($roleids, SQL_PARAMS_NAMED, 'role');
    $params = array_merge($cparams, $rparams);
    $sql = "SELECT p.id, p.userid, p.listid, u." . $offlinequizconfig->ID_field . ", u.firstname, u.lastname,\n                   u.alternatename, u.middlename, u.firstnamephonetic, u.lastnamephonetic,\n                   u.picture, p.checked\n             FROM {offlinequiz_participants} p,\n                  {offlinequiz_p_lists} pl,\n                  {user} u,\n                  {role_assignments} ra\n            WHERE p.listid = pl.id\n              AND p.userid = u.id\n              AND ra.userid=u.id\n              AND pl.offlinequizid = :offlinequizid\n              AND ra.contextid {$csql}\n              AND ra.roleid {$rsql}";
    $params['offlinequizid'] = $offlinequiz->id;
    // Define table headers.
    $tableheaders = array(get_string('fullname'), get_string($offlinequizconfig->ID_field), get_string('participantslist', 'offlinequiz'), get_string('attemptexists', 'offlinequiz'), get_string('present', 'offlinequiz'));
    if ($fileformat == '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('participants', 'offlinequiz');
        $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');
        // Print worksheet headers.
        $colnum = 0;
        foreach ($tableheaders as $item) {
            $myxls->write(0, $colnum, $item, $formatbc);
            $colnum++;
        }
        $rownum = 1;
    } else {
        if ($fileformat == '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('participants', 'offlinequiz');
            $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 = new StdClass();
            $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');
            // Print worksheet headers.
            $colnum = 0;
//.........这里部分代码省略.........
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:101,代码来源:locallib.php

示例12: array

    function export_ods($report, $filename = null) {
        global $DB, $CFG;
        require_once($CFG->dirroot . '/lib/odslib.class.php');

        $table = $report->table;
        $matrix = array();
        //!$fname? $filename = 'report_'.(time()).'.ods':
        $filename = $filename . '.ods';

        if (!empty($table->head)) {
            $countcols = count($table->head);
            $keys = array_keys($table->head);
            $lastkey = end($keys);
            foreach ($table->head as $key => $heading) {
                $matrix[0][$key] = str_replace("\n", ' ', htmlspecialchars_decode(strip_tags(nl2br($heading))));
            }
        }

        if (!empty($table->data)) {
            foreach ($table->data as $rkey => $row) {
                foreach ($row as $key => $item) {
                    $matrix[$rkey + 1][$key] = str_replace("\n", ' ', htmlspecialchars_decode(strip_tags(nl2br($item))));
                }
            }
        }
        $workbook = new MoodleODSWorkbook($filename);

        $myxls = array();

        $myxls[0] = $workbook->add_worksheet('');
        foreach ($matrix as $ri => $col) {
            foreach ($col as $ci => $cv) {
                $myxls[0]->write($ri, $ci, $cv);
            }
        }
        $writer = new MoodleODSWriter($myxls);
        $contents = $writer->get_file_content();
        $handle = fopen($filename, 'w');
        fwrite($handle, $contents);
        fclose($handle);
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:41,代码来源:lib.php

示例13: array

    echo markdown_to_html($notes);
    echo $OUTPUT->box_end();
    echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('type' => 'excel2007')), 'Test Excel 2007 format');
    echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('type' => 'ods')), 'Test ODS format');
    echo $OUTPUT->footer();
    die;
}
if ($type === 'excel2007') {
    $workbook = new MoodleExcelWorkbook('moodletest.xlsx', 'Excel2007');
} else {
    if ($type === 'ods') {
        $workbook = new MoodleODSWorkbook('moodletest.ods');
    }
}
$worksheet = array();
$worksheet = $workbook->add_worksheet('Supported');
$worksheet->hide_screen_gridlines();
$worksheet->write_string(0, 0, 'Moodle worksheet export test', $workbook->add_format(array('color' => 'red', 'size' => 20, 'bold' => 1, 'italic' => 1)));
$worksheet->set_row(0, 25);
$worksheet->write(1, 0, 'Moodle release: ' . $CFG->release, $workbook->add_format(array('size' => 8, 'italic' => 1)));
$worksheet->set_column(0, 0, 20);
$worksheet->set_column(1, 1, 30);
$worksheet->set_column(2, 2, 5);
$worksheet->set_column(3, 3, 30);
$worksheet->set_column(4, 4, 20);
$miniheading = $workbook->add_format(array('size' => 15, 'bold' => 1, 'italic' => 1, 'underline' => 1));
$worksheet->write(2, 0, 'Cell types', $miniheading);
$worksheet->set_row(2, 20);
$worksheet->set_row(3, 5);
$worksheet->write(4, 0, 'String');
$worksheet->write_string(4, 1, 'Žluťoučký koníček');
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:spreadsheettestpage.php

示例14: grade_download

function grade_download($download, $id)
{
    global $CFG;
    require_login();
    if (!($course = get_record("course", "id", $id))) {
        error("Course ID was incorrect");
    }
    require_capability('moodle/course:viewcoursegrades', get_context_instance(CONTEXT_COURSE, $id));
    $strgrades = get_string("grades");
    $strgrade = get_string("grade");
    $strmax = get_string("maximumshort");
    $stractivityreport = get_string("activityreport");
    /// Check to see if groups are being used in this course
    $currentgroup = get_current_group($course->id);
    if (($currentgroup = get_current_group($course->id)) && groupmode($course) != 0) {
        $students = get_group_students($currentgroup, "u.lastname ASC");
    } else {
        $students = grade_get_course_students($course->id);
    }
    if (!empty($students)) {
        foreach ($students as $student) {
            $grades[$student->id] = array();
            // Collect all grades in this array
            $gradeshtml[$student->id] = array();
            // Collect all grades html formatted in this array
            $totals[$student->id] = array();
            // Collect all totals in this array
        }
    }
    $columns = array();
    // Accumulate column names in this array.
    $columnhtml = array();
    // Accumulate column html in this array.
    /// Collect modules data
    get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
    /// Search through all the modules, pulling out grade data
    $sections = get_all_sections($course->id);
    // Sort everything the same as the course
    for ($i = 0; $i <= $course->numsections; $i++) {
        if (isset($sections[$i])) {
            // should always be true
            $section = $sections[$i];
            if ($section->sequence) {
                $sectionmods = explode(",", $section->sequence);
                foreach ($sectionmods as $sectionmod) {
                    $mod = $mods[$sectionmod];
                    $instance = get_record("{$mod->modname}", "id", "{$mod->instance}");
                    $libfile = "{$CFG->dirroot}/mod/{$mod->modname}/lib.php";
                    if (file_exists($libfile)) {
                        require_once $libfile;
                        $gradefunction = $mod->modname . "_grades";
                        if (function_exists($gradefunction)) {
                            // Skip modules without grade function
                            if ($modgrades = $gradefunction($mod->instance)) {
                                if (!empty($modgrades->maxgrade)) {
                                    if ($mod->visible) {
                                        $maxgrade = "{$strmax}: {$modgrades->maxgrade}";
                                    } else {
                                        $maxgrade = "{$strmax}: {$modgrades->maxgrade}";
                                    }
                                } else {
                                    $maxgrade = "";
                                }
                                $columns[] = "{$mod->modfullname}: " . format_string($instance->name, true) . " - {$maxgrade}";
                                if (!empty($students)) {
                                    foreach ($students as $student) {
                                        if (!empty($modgrades->grades[$student->id])) {
                                            $grades[$student->id][] = $currentstudentgrade = $modgrades->grades[$student->id];
                                        } else {
                                            $grades[$student->id][] = $currentstudentgrade = "";
                                            $gradeshtml[$student->id][] = "";
                                        }
                                        if (!empty($modgrades->maxgrade)) {
                                            $totals[$student->id] = (double) $totals[$student->id] + (double) $currentstudentgrade;
                                        } else {
                                            $totals[$student->id] = (double) $totals[$student->id] + 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // a new Moodle nesting record? ;-)
    /// OK, we have all the data, now present it to the user
    /// OK, we have all the data, now present it to the user
    if ($download == "ods" and confirm_sesskey()) {
        require_once "../lib/odslib.class.php";
        /// Calculate file name
        $downloadfilename = clean_filename("{$course->shortname} {$strgrades}.ods");
        /// Creating a workbook
        $workbook = new MoodleODSWorkbook("-");
        /// Sending HTTP headers
        $workbook->send($downloadfilename);
        /// Adding the worksheet
        $myxls =& $workbook->add_worksheet($strgrades);
        /// Print names of all the fields
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:lib.php

示例15: print_coursereport_ods

function print_coursereport_ods($coursereport_ods)
{
    global $CFG;
    require_once "{$CFG->libdir}/odslib.class.php";
    //release coursereport ods data
    $courseID = $coursereport_ods->courseID;
    $courseName = $coursereport_ods->courseName;
    $categoryName = $coursereport_ods->categoryName;
    $userIDDataArray = $coursereport_ods->userIDDataArray;
    $actionIDNameArray = $coursereport_ods->actionIDNameArray;
    $courseUserArray = $coursereport_ods->courseUserArray;
    $userPassArray = $coursereport_ods->userPassArray;
    $tt = getdate(time());
    $today = mktime(0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
    $filename = 'course_reports_' . userdate(time(), get_string('backupnameformat', 'langconfig'), 99, false);
    $filename .= '.ods';
    $workbook = new MoodleODSWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    // Creating worksheets
    $sheettitle = 'course_report';
    //紀錄1-1
    $worksheet =& $workbook->add_worksheet($sheettitle);
    $worksheet->set_column(1, 1, 60);
    $worksheet->write_string(0, 0, $categoryName);
    $worksheet->write_string(1, 0, $courseName);
    $col = 0;
    $row = 4;
    $headerArray = processCourseReportHeader($courseUserArray, $actionIDNameArray);
    foreach ($headerArray as $item) {
        $worksheet->write($row - 1, $col, $item, '');
        $col++;
    }
    $myxls =& $worksheet;
    foreach ($courseUserArray as $userID => $actionInfo) {
        $col = 0;
        $myxls->write_string($row, $col, $userIDDataArray[$userID]['name']);
        $col++;
        $myxls->write_string($row, $col, $userIDDataArray[$userID]['description']);
        $col++;
        $myxls->write_string($row, $col, $userIDDataArray[$userID]['email']);
        $col++;
        foreach ($actionInfo as $actionID => $actionContent) {
            if ($actionContent['timeEnable']) {
                $myxls->write_string($row, $col, $actionContent['time']);
                $col++;
            }
            if ($actionContent['scoreEnable']) {
                $myxls->write_string($row, $col, $actionContent['score']);
                $col++;
            }
            if ($actionContent['timePass'] and $actionContent['scorePass']) {
                $myxls->write_string($row, $col, '通過');
                $col++;
            } else {
                $myxls->write_string($row, $col, '不通過');
                $col++;
            }
        }
        $myxls->write_string($row, $col, $userPassArray[$userID] ? '通過' : '不通過');
        $col++;
        $row++;
    }
    $workbook->close();
    return true;
}
开发者ID:stepsgithub,项目名称:moodle-block_report_module,代码行数:66,代码来源:ods.php


注:本文中的MoodleODSWorkbook::add_worksheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。