Skip to content
Snippets Groups Projects
Commit fcb66291 authored by Tim Hunt's avatar Tim Hunt
Browse files

Move to plots storage to moodledata.

parent 82d28b39
No related branches found
No related tags found
No related merge requests found
plot.php 0 → 100644
<?php
// This file is part of Stack - http://stack.bham.ac.uk//
//
// Stack is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Stack is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Stack. If not, see <http://www.gnu.org/licenses/>.
/**
* This script serves plot files that have been saved in the moodledata folder.
*
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir . '/filelib.php');
$plot = $CFG->dataroot . '/stack/plots/' . clean_filename(get_file_argument());
if (!is_readable($plot)) {
header('HTTP/1.0 404 Not Found');
header('Content-Type: text/plain;charset=UTF-8');
echo 'File not found';
die();
}
// Handle If-Modified-Since
$filedate = filemtime($plot);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $filedate) {
header('HTTP/1.0 304 Not Modified');
die();
}
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $filedate).' GMT');
// Type
header('Content-Type: ' . mimeinfo('type', 'x.png'));
header('Content-Length: ' . filesize($plot));
// Output file
session_get_instance()->write_close(); // unlock session during file serving.
readfile($plot);
...@@ -97,8 +97,8 @@ function stack_generate_maximalocal() { ...@@ -97,8 +97,8 @@ function stack_generate_maximalocal() {
} }
$maximalocal['TMP_IMAGE_DIR'] = $path = $CFG->dataroot . '/stack/'; $maximalocal['TMP_IMAGE_DIR'] = $path = $CFG->dataroot . '/stack/';
//TODO where do we put plots properly?! //TODO where do we put plots properly?!
$maximalocal['IMAGE_DIR'] = 'C:/xampp/htdocs/tmp/'; // $CFG->dataroot; $maximalocal['IMAGE_DIR'] = $CFG->dataroot . '/stack/plots/';
$maximalocal['URL_BASE'] = 'http://localhost/tmp/'; //$CFG->wwwroot; $maximalocal['URL_BASE'] = moodle_url::make_file_url('/question/type/stack/plot.php', '');
// Loop over this array to format them correctly... // Loop over this array to format them correctly...
foreach ($maximalocal as $var => $val) { foreach ($maximalocal as $var => $val) {
...@@ -135,13 +135,14 @@ STACK generates LaTeX on the fly, and enables teachers to write LaTeX in questio ...@@ -135,13 +135,14 @@ STACK generates LaTeX on the fly, and enables teachers to write LaTeX in questio
It assumes that LaTeX will be converted by a moodle filter. Below are samples of displayed and inline expressions in LaTeX which should be It assumes that LaTeX will be converted by a moodle filter. Below are samples of displayed and inline expressions in LaTeX which should be
appear correctly in your browser. Problems here indicate incorrect moodle filter settings, not faults with STACK itself. appear correctly in your browser. Problems here indicate incorrect moodle filter settings, not faults with STACK itself.
<h3>Single and double dollar math environments</h3> <h3>Single and double dollar math environments</h3>
$$ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.$$ <?php echo format_text('$$ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.$$'); ?>
<br /> <br />
$ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.$ <?php echo format_text('$ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.$'); ?>
<h3>Matching displayed and inline LaTeX tags.</h3> <h3>Matching displayed and inline LaTeX tags.</h3>
\[ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.\] <?php echo format_text('\[ \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.\]'); ?>
<br /> <br />
\( \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.\) <?php echo format_text('\( \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}.\)'); ?>
<br /> <br />
(These are currently not generated by STACK on the fly, but may be written by some question authors.) (These are currently not generated by STACK on the fly, but may be written by some question authors.)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment