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


PHP MoodleODSWorkbook::close方法代码示例

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


在下文中一共展示了MoodleODSWorkbook::close方法的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.*,\n                                {$extrafield_sql}\n                                FROM mdl_user AS mu\n                                LEFT JOIN mdl_user_info_data AS muid ON mu.id = muid.userid\n                                LEFT JOIN mdl_user_info_field AS muif ON muif.id = muid.fieldid\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.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: foreach

                if ($usergrps = groups_get_all_groups($course->id, $user->id)) {
                    foreach ($usergrps as $ug) {
                        $ug2 = $ug2 . $ug->name;
                    }
                }
                $myxls->write_string($row, 3, $ug2);
                if (isset($option_text)) {
                    $myxls->write_string($row, 4, format_string($option_text, true));
                }
                $row++;
                $pos = 4;
            }
        }
    }
    /// Close the workbook
    $workbook->close();
    exit;
}
//print spreadsheet if one is asked for:
if ($download == "xls" && has_capability('mod/choice:downloadresponses', $context)) {
    require_once "{$CFG->libdir}/excellib.class.php";
    /// Calculate file name
    $filename = clean_filename("{$course->shortname} " . strip_tags(format_string($choice->name, true))) . '.xls';
    /// Creating a workbook
    $workbook = new MoodleExcelWorkbook("-");
    /// Send HTTP headers
    $workbook->send($filename);
    /// Creating the first worksheet
    $myxls = $workbook->add_worksheet($strresponses);
    /// Print names of all the fields
    $myxls->write_string(0, 0, get_string("lastname"));
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源: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: exporttotableed

function exporttotableed($data, $filename, $format)
{
    global $CFG;
    if ($format === 'excel') {
        require_once "{$CFG->libdir}/excellib.class.php";
        $filename .= ".xls";
        $workbook = new MoodleExcelWorkbook("-");
    } else {
        require_once "{$CFG->libdir}/odslib.class.php";
        $filename .= ".ods";
        $workbook = new MoodleODSWorkbook("-");
    }
    // Sending HTTP headers.
    $workbook->send($filename);
    // Creating the first worksheet.
    $myxls = $workbook->add_worksheet('Attendances');
    // Format types.
    $formatbc = $workbook->add_format();
    $formatbc->set_bold(1);
    $myxls->write(0, 0, get_string('course'), $formatbc);
    $myxls->write(0, 1, $data->course);
    $myxls->write(1, 0, get_string('group'), $formatbc);
    $myxls->write(1, 1, $data->group);
    $i = 3;
    $j = 0;
    foreach ($data->tabhead as $cell) {
        $myxls->write($i, $j++, $cell, $formatbc);
    }
    $i++;
    $j = 0;
    foreach ($data->table as $row) {
        foreach ($row as $cell) {
            $myxls->write($i, $j++, $cell);
        }
        $i++;
        $j = 0;
    }
    $workbook->close();
}
开发者ID:lsuits,项目名称:moodle-mod_attendance,代码行数:39,代码来源:export.php

示例7: 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

示例8: facetoface_download_ods

/** Download data in ODS format
  *
  * @param array $fields Array of column headings
  * @param string $datarows Array of data to populate table with
  * @param string $file Name of file for exportig
  * @return Returns the ODS file
 */
function facetoface_download_ods($fields, $datarows, $file=null) {
    global $CFG, $DB;

    require_once("$CFG->libdir/odslib.class.php");
    $filename = clean_filename($file . '.ods');

    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");

    $workbook = new MoodleODSWorkbook('-');
    $workbook->send($filename);

    $worksheet = array();

    $worksheet[0] = $workbook->add_worksheet('');
    $row = 0;
    $col = 0;

    foreach ($fields as $field) {
        $worksheet[0]->write($row, $col, strip_tags($field));
        $col++;
    }
    $row++;

    $numfields = count($fields);

    foreach ($datarows as $record) {
        for($col=0; $col<$numfields; $col++) {
            if (isset($record[$col])) {
                $worksheet[0]->write($row, $col, html_entity_decode($record[$col], ENT_COMPAT, 'UTF-8'));
            }
        }
        $row++;
    }

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

示例9: 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

示例10: array

 /**
  * To be implemented by child classes
  */
 function print_grades()
 {
     global $CFG;
     require_once $CFG->dirroot . '/lib/odslib.class.php';
     $export_tracking = $this->track_exports();
     $strgrades = get_string('grades');
     $shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id)));
     /// Calculate file name
     $downloadfilename = clean_filename("{$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
     $myxls->write_string(0, 0, get_string("firstname"));
     $myxls->write_string(0, 1, get_string("lastname"));
     $myxls->write_string(0, 2, get_string("idnumber"));
     $myxls->write_string(0, 3, get_string("institution"));
     $myxls->write_string(0, 4, get_string("department"));
     $myxls->write_string(0, 5, get_string("email"));
     $pos = 6;
     foreach ($this->columns as $grade_item) {
         $myxls->write_string(0, $pos++, $this->format_column_name($grade_item));
         /// add a column_feedback column
         if ($this->export_feedback) {
             $myxls->write_string(0, $pos++, $this->format_column_name($grade_item, true));
         }
     }
     /// Print all the lines of data.
     $i = 0;
     $geub = new grade_export_update_buffer();
     $gui = new graded_users_iterator($this->course, $this->columns, $this->groupid);
     $gui->require_active_enrolment($this->onlyactive);
     $gui->init();
     while ($userdata = $gui->next_user()) {
         $i++;
         $user = $userdata->user;
         $myxls->write_string($i, 0, $user->firstname);
         $myxls->write_string($i, 1, $user->lastname);
         $myxls->write_string($i, 2, $user->idnumber);
         $myxls->write_string($i, 3, $user->institution);
         $myxls->write_string($i, 4, $user->department);
         $myxls->write_string($i, 5, $user->email);
         $j = 6;
         foreach ($userdata->grades as $itemid => $grade) {
             if ($export_tracking) {
                 $status = $geub->track($grade);
             }
             $gradestr = $this->format_grade($grade);
             if (is_numeric($gradestr)) {
                 $myxls->write_number($i, $j++, $gradestr);
             } else {
                 $myxls->write_string($i, $j++, $gradestr);
             }
             // writing feedback if requested
             if ($this->export_feedback) {
                 $myxls->write_string($i, $j++, $this->format_feedback($userdata->feedbacks[$itemid]));
             }
         }
     }
     $gui->close();
     $geub->close();
     /// Close the workbook
     $workbook->close();
     exit;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:71,代码来源:grade_export_ods.php

示例11: array

 /**
  * To be implemented by child classes
  */
 function print_grades()
 {
     global $CFG;
     require_once $CFG->dirroot . '/lib/odslib.class.php';
     $export_tracking = $this->track_exports();
     $strgrades = get_string('grades');
     $shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
     // Calculate file name
     $downloadfilename = clean_filename("{$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.
     $profilefields = grade_helper::get_user_profile_fields($this->course->id, $this->usercustomfields);
     foreach ($profilefields as $id => $field) {
         $myxls->write_string(0, $id, $field->fullname);
     }
     $pos = count($profilefields);
     if (!$this->onlyactive) {
         $myxls->write_string(0, $pos++, get_string("suspended"));
     }
     foreach ($this->columns as $grade_item) {
         $myxls->write_string(0, $pos++, $this->format_column_name($grade_item));
         // Add a column_feedback column.
         if ($this->export_feedback) {
             $myxls->write_string(0, $pos++, $this->format_column_name($grade_item, true));
         }
     }
     // Print all the lines of data.
     $i = 0;
     $geub = new grade_export_update_buffer();
     $gui = new graded_users_iterator($this->course, $this->columns, $this->groupid);
     $gui->require_active_enrolment($this->onlyactive);
     $gui->allow_user_custom_fields($this->usercustomfields);
     $gui->init();
     while ($userdata = $gui->next_user()) {
         $i++;
         $user = $userdata->user;
         foreach ($profilefields as $id => $field) {
             $fieldvalue = grade_helper::get_user_field_value($user, $field);
             $myxls->write_string($i, $id, $fieldvalue);
         }
         $j = count($profilefields);
         if (!$this->onlyactive) {
             $issuspended = $user->suspendedenrolment ? get_string('yes') : '';
             $myxls->write_string($i, $j++, $issuspended);
         }
         foreach ($userdata->grades as $itemid => $grade) {
             if ($export_tracking) {
                 $status = $geub->track($grade);
             }
             $gradestr = $this->format_grade($grade);
             if (is_numeric($gradestr)) {
                 $myxls->write_number($i, $j++, $gradestr);
             } else {
                 $myxls->write_string($i, $j++, $gradestr);
             }
             // writing feedback if requested
             if ($this->export_feedback) {
                 $myxls->write_string($i, $j++, $this->format_feedback($userdata->feedbacks[$itemid]));
             }
         }
     }
     $gui->close();
     $geub->close();
     // Close the workbook.
     $workbook->close();
     exit;
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:75,代码来源:grade_export_ods.php

示例12: view_issued_certificates


//.........这里部分代码省略.........
                     $workbook->send(format_text($filename, true));
                     // Creating the first worksheet
                     $myxls = $workbook->add_worksheet($strreport);
                     // Print names of all the fields
                     $myxls->write_string(0, 0, get_string("fullname"));
                     $myxls->write_string(0, 1, get_string("idnumber"));
                     $myxls->write_string(0, 2, get_string("group"));
                     $myxls->write_string(0, 3, $strdate);
                     $myxls->write_string(0, 4, $strgrade);
                     $myxls->write_string(0, 5, $strcode);
                     // Generate the data for the body of the spreadsheet
                     $i = 0;
                     $row = 1;
                     if ($users) {
                         foreach ($users as $user) {
                             $myxls->write_string($row, 0, fullname($user));
                             $studentid = !empty($user->idnumber) ? $user->idnumber : " ";
                             $myxls->write_string($row, 1, $studentid);
                             $ug2 = '';
                             if ($usergrps = groups_get_all_groups($this->get_course()->id, $user->id)) {
                                 foreach ($usergrps as $ug) {
                                     $ug2 = $ug2 . $ug->name;
                                 }
                             }
                             $myxls->write_string($row, 2, $ug2);
                             $myxls->write_string($row, 3, userdate($user->timecreated));
                             $myxls->write_string($row, 4, $this->get_grade($user->id));
                             $myxls->write_string($row, 5, $user->code);
                             $row++;
                         }
                         $pos = 5;
                     }
                     // Close the workbook
                     $workbook->close();
                     break;
                 case 'xls':
                     require_once "{$CFG->libdir}/excellib.class.php";
                     // Creating a workbook
                     $workbook = new MoodleExcelWorkbook("-");
                     // Send HTTP headers
                     $workbook->send(format_text($filename, true));
                     // Creating the first worksheet
                     $myxls = $workbook->add_worksheet($strreport);
                     // Print names of all the fields
                     $myxls->write_string(0, 0, get_string("fullname"));
                     $myxls->write_string(0, 1, get_string("idnumber"));
                     $myxls->write_string(0, 2, get_string("group"));
                     $myxls->write_string(0, 3, $strdate);
                     $myxls->write_string(0, 4, $strgrade);
                     $myxls->write_string(0, 5, $strcode);
                     // Generate the data for the body of the spreadsheet
                     $i = 0;
                     $row = 1;
                     if ($users) {
                         foreach ($users as $user) {
                             $myxls->write_string($row, 0, fullname($user));
                             $studentid = !empty($user->idnumber) ? $user->idnumber : " ";
                             $myxls->write_string($row, 1, $studentid);
                             $ug2 = '';
                             if ($usergrps = groups_get_all_groups($this->get_course()->id, $user->id)) {
                                 foreach ($usergrps as $ug) {
                                     $ug2 = $ug2 . $ug->name;
                                 }
                             }
                             $myxls->write_string($row, 2, $ug2);
                             $myxls->write_string($row, 3, userdate($user->timecreated));
开发者ID:seducto,项目名称:moodle-mod_simplecertificate,代码行数:67,代码来源:locallib.php

示例13: user_download_ods

function user_download_ods($userids, $fields, $includecompanyfield)
{
    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) {
        if ($includecompanyfield || $fieldname != "profile_field_company") {
            $worksheet[0]->write(0, $col, $fieldname);
            $col++;
        }
    }
    $worksheet[0]->write(0, $col, 'temppassword');
    $row = 1;
    foreach ($userids as $userid) {
        // Stop the script from timing out on large numbers of users.
        set_time_limit(30);
        if (!($user = $DB->get_record('user', array('id' => $userid)))) {
            continue;
        }
        $col = 0;
        profile_load_data($user);
        foreach ($fields as $field => $unused) {
            // Stop the script from timing out on large numbers of users.
            set_time_limit(30);
            if ($includecompanyfield || $field != "profile_field_company") {
                $worksheet[0]->write($row, $col, $user->{$field});
                $col++;
            }
        }
        $worksheet[0]->write($row, $col, company_user::get_temporary_password($user));
        $row++;
    }
    $workbook->close();
    die;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:41,代码来源:user_bulk_download.php

示例14: grade_download


//.........这里部分代码省略.........
        $myxls->write_string(0, 5, get_string("email"));
        $pos = 6;
        foreach ($columns as $column) {
            $myxls->write_string(0, $pos++, strip_tags($column));
        }
        $myxls->write_string(0, $pos, get_string("total"));
        /// Print all the lines of data.
        $i = 0;
        if (!empty($grades)) {
            foreach ($grades as $studentid => $studentgrades) {
                $i++;
                $student = $students[$studentid];
                if (empty($totals[$student->id])) {
                    $totals[$student->id] = '';
                }
                $myxls->write_string($i, 0, $student->firstname);
                $myxls->write_string($i, 1, $student->lastname);
                $myxls->write_string($i, 2, $student->idnumber);
                $myxls->write_string($i, 3, $student->institution);
                $myxls->write_string($i, 4, $student->department);
                $myxls->write_string($i, 5, $student->email);
                $j = 6;
                foreach ($studentgrades as $grade) {
                    if (is_numeric($grade)) {
                        $myxls->write_number($i, $j++, strip_tags($grade));
                    } else {
                        $myxls->write_string($i, $j++, strip_tags($grade));
                    }
                }
                $myxls->write_number($i, $j, $totals[$student->id]);
            }
        }
        /// Close the workbook
        $workbook->close();
        exit;
    } else {
        if ($download == "xls" and confirm_sesskey()) {
            require_once "../lib/excellib.class.php";
            /// Calculate file name
            $downloadfilename = clean_filename("{$course->shortname} {$strgrades}.xls");
            /// Creating a workbook
            $workbook = new MoodleExcelWorkbook("-");
            /// Sending HTTP headers
            $workbook->send($downloadfilename);
            /// Adding the worksheet
            $myxls =& $workbook->add_worksheet($strgrades);
            /// Print names of all the fields
            $myxls->write_string(0, 0, get_string("firstname"));
            $myxls->write_string(0, 1, get_string("lastname"));
            $myxls->write_string(0, 2, get_string("idnumber"));
            $myxls->write_string(0, 3, get_string("institution"));
            $myxls->write_string(0, 4, get_string("department"));
            $myxls->write_string(0, 5, get_string("email"));
            $pos = 6;
            foreach ($columns as $column) {
                $myxls->write_string(0, $pos++, strip_tags($column));
            }
            $myxls->write_string(0, $pos, get_string("total"));
            /// Print all the lines of data.
            $i = 0;
            if (!empty($grades)) {
                foreach ($grades as $studentid => $studentgrades) {
                    $i++;
                    $student = $students[$studentid];
                    if (empty($totals[$student->id])) {
                        $totals[$student->id] = '';
开发者ID:veritech,项目名称:pare-project,代码行数:67,代码来源: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::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。