mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
Merge branch 'MDL-51603-fixes' of git://github.com/dmonllao/moodle
This commit is contained in:
commit
2b311b2d3e
11 changed files with 69 additions and 41 deletions
|
@ -46,5 +46,26 @@ class writer extends \core\dataformat\spout_base {
|
|||
/** @var $spouttype */
|
||||
protected $spouttype = \Box\Spout\Common\Type::XLSX;
|
||||
|
||||
/**
|
||||
* Set the title of the worksheet inside a spreadsheet
|
||||
*
|
||||
* For some formats this will be ignored.
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function set_sheettitle($title) {
|
||||
if (!$title) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace any characters in the name that Excel cannot cope with.
|
||||
$title = strtr(trim($title, "'"), '[]*/\?:', ' ');
|
||||
// Shorten the title if necessary.
|
||||
$title = \core_text::substr($title, 0, 31);
|
||||
// After the substr, we might now have a single quote on the end.
|
||||
$title = trim($title, "'");
|
||||
|
||||
$this->sheettitle = $title;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,5 +46,26 @@ class writer extends \core\dataformat\spout_base {
|
|||
/** @var $spouttype */
|
||||
protected $spouttype = \Box\Spout\Common\Type::ODS;
|
||||
|
||||
/**
|
||||
* Set the title of the worksheet inside a spreadsheet
|
||||
*
|
||||
* For some formats this will be ignored.
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function set_sheettitle($title) {
|
||||
if (!$title) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace any characters in the name that ODS cannot cope with.
|
||||
$title = strtr(trim($title, "'"), '[]*/\?:', ' ');
|
||||
// Shorten the title if necessary.
|
||||
$title = \core_text::substr($title, 0, 31);
|
||||
// After the substr, we might now have a single quote on the end.
|
||||
$title = trim($title, "'");
|
||||
|
||||
$this->sheettitle = $title;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,10 @@ abstract class spout_base extends \core\dataformat\base {
|
|||
$this->writer = \Box\Spout\Writer\WriterFactory::create($this->spouttype);
|
||||
$filename = $this->filename . $this->get_extension();
|
||||
$this->writer->openToBrowser($filename);
|
||||
if ($this->sheettitle) {
|
||||
$sheet = $this->writer->getCurrentSheet();
|
||||
$sheet->setName($this->sheettitle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,11 +68,7 @@ abstract class spout_base extends \core\dataformat\base {
|
|||
if (!$title) {
|
||||
return;
|
||||
}
|
||||
$title = preg_replace('/[\\\\\/\\?\\*\\[\\]]/', '', $title);
|
||||
$title = substr($title, 0, 31);
|
||||
$this->sheettitle = $title;
|
||||
$sheet = $this->writer->getCurrentSheet();
|
||||
$sheet->setName($title);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
*/
|
||||
function download_as_dataformat($filename, $dataformat, $columns, $iterator, $callback = null) {
|
||||
|
||||
if (!NO_OUTPUT_BUFFERING) {
|
||||
throw new coding_exception("NO_OUTPUT_BUFFERING must be set to true before calling download_as_dataformat");
|
||||
if (ob_get_length()) {
|
||||
throw new coding_exception("Output can not be buffered before calling download_as_dataformat");
|
||||
}
|
||||
|
||||
$classname = 'dataformat_' . $dataformat . '\writer';
|
||||
|
|
|
@ -1893,7 +1893,7 @@ class core_renderer extends renderer_base {
|
|||
if ($format->is_enabled()) {
|
||||
$options[] = array(
|
||||
'value' => $format->name,
|
||||
'label' => get_string('shortname', $format->component),
|
||||
'label' => get_string('dataformat', $format->component),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1704,10 +1704,8 @@ class table_dataformat_export_format extends table_default_export_format_parent
|
|||
public function __construct(&$table, $dataformat) {
|
||||
parent::__construct($table);
|
||||
|
||||
if (!NO_OUTPUT_BUFFERING) {
|
||||
// Ideally this would throw a coding exception but we are more forgiving here due
|
||||
// to the large amount of code already using table_sql.
|
||||
debugging("NO_OUTPUT_BUFFERING should be set to true before downloading", DEBUG_DEVELOPER);
|
||||
if (ob_get_length()) {
|
||||
throw new coding_exception("Output can not be buffered before instantiating table_dataformat_export_format");
|
||||
}
|
||||
|
||||
$classname = 'dataformat_' . $dataformat . '\writer';
|
||||
|
|
|
@ -30,15 +30,17 @@
|
|||
* submit
|
||||
}}
|
||||
<form method="get" action="{{base}}" class="dataformatselector">
|
||||
<input type="hidden" name="sesskey" value="{{sesskey}}">
|
||||
<label for="downloadtype_{{name}}">{{label}}</label>
|
||||
<select name="{{name}}" id="downloadtype_{{name}}">
|
||||
{{#options}}
|
||||
<option value="{{value}}">{{label}}</option>
|
||||
{{/options}}
|
||||
</select>
|
||||
<input type="submit" value="{{submit}}">
|
||||
{{#params}}
|
||||
<input type="hidden" name="{{name}}" value="{{value}}" />
|
||||
{{/params}}
|
||||
<div class="mdl-align">
|
||||
<input type="hidden" name="sesskey" value="{{sesskey}}">
|
||||
<label for="downloadtype_{{name}}">{{label}}</label>
|
||||
<select name="{{name}}" id="downloadtype_{{name}}">
|
||||
{{#options}}
|
||||
<option value="{{value}}">{{label}}</option>
|
||||
{{/options}}
|
||||
</select>
|
||||
<input type="submit" value="{{submit}}">
|
||||
{{#params}}
|
||||
<input type="hidden" name="{{name}}" value="{{value}}" />
|
||||
{{/params}}
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -116,6 +116,7 @@ information provided here is intended especially for developers.
|
|||
* behat_util::is_server_running() is removed, please use behat_util::check_server_status() instead.
|
||||
* Behat\Mink\Selector\SelectorsHandler::xpathLiteral() method is deprecated use behat_context_helper::escape instead
|
||||
when building Xpath, or pass the unescaped value when using the named selector.',
|
||||
* table_sql download process is using the new data formats plugin which you can't use if you are buffering any output
|
||||
|
||||
=== 3.0 ===
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ $string['detailedanalysis'] = 'More detailed analysis of the responses to this q
|
|||
$string['detailedanalysisforvariant'] = 'More detailed analysis of the responses to variant {$a} of this question';
|
||||
$string['discrimination_index'] = 'Discrimination index';
|
||||
$string['discriminative_efficiency'] = 'Discriminative efficiency';
|
||||
$string['downloadeverything'] = 'Download full report as {$a->formatsmenu} {$a->downloadbutton}';
|
||||
$string['downloadeverything'] = 'Download full report as';
|
||||
$string['duration'] = 'Open for';
|
||||
$string['effective_weight'] = 'Effective weight';
|
||||
$string['errordeleting'] = 'Error deleting old {$a} records.';
|
||||
|
|
|
@ -667,21 +667,10 @@ class quiz_statistics_report extends quiz_default_report {
|
|||
* @return string HTML.
|
||||
*/
|
||||
protected function everything_download_options() {
|
||||
$downloadoptions = $this->table->get_download_menu();
|
||||
global $OUTPUT;
|
||||
|
||||
$downloadelements = new stdClass();
|
||||
$downloadelements->formatsmenu = html_writer::select($downloadoptions, 'download',
|
||||
$this->table->defaultdownloadformat, false);
|
||||
$downloadelements->downloadbutton = '<input type="submit" value="' .
|
||||
get_string('download') . '"/>';
|
||||
|
||||
$output = '<form action="'. $this->table->baseurl .'" method="post">';
|
||||
$output .= '<div class="mdl-align">';
|
||||
$output .= '<input type="hidden" name="everything" value="1"/>';
|
||||
$output .= html_writer::tag('label', get_string('downloadeverything', 'quiz_statistics', $downloadelements));
|
||||
$output .= '</div></form>';
|
||||
|
||||
return $output;
|
||||
return $OUTPUT->download_dataformat_selector(get_string('downloadeverything', 'quiz_statistics'),
|
||||
$this->table->baseurl->out_omit_querystring(), 'download', $this->table->baseurl->params() + array('everything' => 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,10 +22,6 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!empty($_GET['download'])) {
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
}
|
||||
|
||||
require('../../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/report/log/locallib.php');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue