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


PHP MoodleODSWorkbook::send方法代码示例

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


在下文中一共展示了MoodleODSWorkbook::send方法的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('picture');
                $table->column_suppress('fullname');
                foreach ($extrafields as $field) {
                    $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') {
开发者ID:numbas,项目名称:moodle,代码行数:67,代码来源:report.php

示例5: display


//.........这里部分代码省略.........
                 // Get rid of zero length questions.
                 unset($questions[$id]);
                 unset($questionids[$key]);
             }
         }
     }
     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;
                 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:67,代码来源:report.php

示例6: display


//.........这里部分代码省略.........
         }
     }
     if (!$download) {
         // Set up the table.
         $params = array('offlinequiz' => $offlinequiz, 'noresults' => $noresults, 'pagesize' => $pagesize);
         $table = new offlinequiz_results_table('mod-offlinequiz-report-overview-report', $params);
         $table->define_columns($tablecolumns);
         $table->define_headers($tableheaders);
         $table->define_baseurl($CFG->wwwroot . '/mod/offlinequiz/report.php?mode=overview&amp;id=' . $cm->id . '&amp;noresults=' . $noresults . '&amp;pagesize=' . $pagesize);
         $table->sortable(true);
         $table->no_sorting('checkbox');
         if ($withparticipants) {
             $table->no_sorting('checked');
         }
         $table->column_suppress('picture');
         $table->column_suppress('fullname');
         $table->column_class('picture', 'picture');
         $table->column_class($offlinequizconfig->ID_field, 'userkey');
         $table->column_class('timestart', 'timestart');
         $table->column_class('offlinegroupid', 'offlinegroupid');
         $table->column_class('sumgrades', 'sumgrades');
         $table->set_attribute('cellpadding', '2');
         $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', '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');
             // Here starts workshhet headers.
             $headers = array(get_string($offlinequizconfig->ID_field), get_string('firstname'), get_string('lastname'), get_string('importedon', 'offlinequiz'), get_string('group'), get_string('grade', 'offlinequiz'));
             if (!empty($withparticipants)) {
                 $headers[] = get_string('present', 'offlinequiz');
             }
             $colnum = 0;
             foreach ($headers as $item) {
                 $myxls->write(0, $colnum, $item, $formatbc);
                 $colnum++;
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:67,代码来源:report.php

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

示例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);
    if (!empty($fields)) {
        $countcols = count($fields);
        $keys = array_keys($fields);
        $lastkey = end($keys);
        foreach ($fields as $key => $heading) {
            $matrix[0][$key] = str_replace("\n", ' ', htmlspecialchars_decode(strip_tags(nl2br($heading))));
        }
    }

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

    foreach ($matrix as $ri => $col) {
        foreach ($col as $ci => $cv) {
            $myxls->write_string($ri, $ci, $cv);
        }
    }
    //$worksheet[0] = $workbook->add_worksheet('');
    //$row = 0;
    //$col = 0;
    //
    //foreach ($fields as $field) {
    //     $myxls->write_string($ri, $ci, $cv);
    //    $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();
    exit;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:68,代码来源:lib.php

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

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

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

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

示例13: array

    }
}

// Output the file as a valid ODS spreadsheet if required
$coursecontext = context_course::instance($course->id);
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));

if ($type == "ods") {
    require_once("$CFG->libdir/odslib.class.php");

/// Calculate file name
    $downloadfilename = clean_filename(strip_tags($courseshortname.' '.format_string($survey->name, true))).'.ods';
/// Creating a workbook
    $workbook = new MoodleODSWorkbook("-");
/// Sending HTTP headers
    $workbook->send($downloadfilename);
/// Creating the first worksheet
    $myxls = $workbook->add_worksheet(textlib::substr(strip_tags(format_string($survey->name,true)), 0, 31));

    $header = array("surveyid","surveyname","userid","firstname","lastname","email","idnumber","time", "notes");
    $col=0;
    foreach ($header as $item) {
        $myxls->write_string(0,$col++,$item);
    }

    foreach ($nestedorder as $key => $nestedquestions) {
        foreach ($nestedquestions as $key2 => $qid) {
            $question = $questions[$qid];
            if ($question->type == "0" || $question->type == "1" || $question->type == "3" || $question->type == "-1")  {
                $myxls->write_string(0,$col++,"$question->text");
            }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:download.php

示例14: display


//.........这里部分代码省略.........
             }
         }
         if ($hasfeedback) {
             $columns[] = 'feedbacktext';
             $headers[] = get_string('feedback', 'quiz');
         }
         if (!$download) {
             // Set up the table
             $table = new flexible_table('mod-quiz-report-overview-report');
             $table->define_columns($columns);
             $table->define_headers($headers);
             $table->define_baseurl($reporturlwithdisplayoptions->out());
             $table->sortable(true);
             $table->collapsible(true);
             $table->column_suppress('picture');
             $table->column_suppress('fullname');
             $table->column_suppress('idnumber');
             $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') {
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:67,代码来源:report.php

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


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