Skip to content
Snippets Groups Projects
Commit d32ba4b7 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Pass one at using Moodle's configuration settings.

parent b36424a0
Branches
No related tags found
No related merge requests found
doc/content/logo-trans.png

4.08 KiB

doc/content/logoJB.jpg

83.6 KiB

This diff is collapsed.
<?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/>.
/**
*
* Welcome to STACK. A system for teaching and assessment using a
* computer algebra kernel.
*
* This file is licensed under the GPL License.
*
* A copy of the license is in your STACK distribution called
* license.txt. If you are missing this file you can obtain
* it from:
* http://www.stack.bham.ac.uk/license.txt
* Documentation system as a static wiki of markdown.
*
* @package stackDoc
* @author Ben Holmes
* @copyright 2012 The University of Birmingham
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../../../config.php');
require_once(dirname(__FILE__) . '/../locallib.php');
require_once(dirname(__FILE__) . '/phpMarkdown/markdown.php');// TODO: remove all this? Is this a core part of Moodle?
require_once(dirname(__FILE__) . '/../stack/stringutil.class.php');
/*
* This file serves the contents of a local directory and renders markup to html
* A file is requested by appending it's path (from the docs root) to doc.php
* e.g. for /docs/CAS/Maxima.md request /doc.php/CAS/Maxima.md
* A file is requested by appending it's path (from the doc root) to doc.php
* e.g. for /CAS/Maxima.md request /doc.php/CAS/Maxima.md
* Language selection is done automatically.
*/
header('Content-Type: text/html; charset=utf-8');
require_login();
if (substr($_SERVER['REQUEST_URI'], -7) == 'doc.php') {
// Don't access doc.php directly, treat it like a directory instead.
......@@ -29,48 +44,42 @@ if (substr($_SERVER['REQUEST_URI'], -7) == 'doc.php') {
exit();
}
// TODO get config to work with new setup
require_once 'config.php';
$config = new StackConfig();
global $config;
$docroot = $CFG->dirroot;
$webroot = $CFG->wwwroot;
$docs = '/question/type/stack/doc/' . $CFG->lang; // docs local location
$webdocs = $webroot.'/question/type/stack/doc/doc.php'; // doc.php web address
$docroot = $config->get('docroot');
$webroot = $config->get('webroot');
$docs = '/lang/' . $config->get('lang') . '/doc'; // docs local location
$webDocs = "$webroot/doc.php"; // doc.php web address
$docLog = "$docroot/docLog.txt"; //$config->get('tmp') . '/docLog.txt';
$uri = str_replace($webDocs, '', urldecode($_SERVER['REQUEST_URI'])); // the uri string
$logpath = new STACK_StringUtil($CFG->dataroot . '/stack/logs');
$doclog = $logpath->convertSlashPaths();
$uri = get_file_argument(); // the uri string
$segs = explode('/', $uri);
$doc = $segs[count($segs) - 1];
/*
* Only really needed back when the extension was appended automatically
$ext = '.md';
*/
$file = $docroot . $docs . $uri . ($doc == '' ? 'index' : '');
$file = $docroot . $docs . $uri . ($doc == '' ? 'index' : '') . '.md';
// the path to the directory for static content to be served by the docs
// access this string in the docs with %CONTENT
$docsContent = "$webroot/docs_content";
$webpix = $CFG->wwwroot.'/question/type/stack/pix/logo-sm.png';
require_once $docroot . '/doc/phpMarkdown/markdown.php';
// Frontend was required for html_head, possibly nothing else
require_once $docroot . '/lib/ui/frontend.php'; // TODO find the new version of this
require_once $docroot . '/lib/translator.php'; // TODO find the new version of this
// the URL to the directory for static content to be served by the docs
// access this string in the docs with %CONTENT
$docscontent = $webroot.'/question/type/stack/doc/content';
if ($uri == '/') { // docs root
$head = get_string('stackDoc_home', 'stack');
} else if ($doc == '') { // directory
$head = $segs[count($segs) - 2];
} else {
$head = $doc;
}
if (!file_exists($file)) {
header('HTTP/1.0 404 Not Found');
error_log(date(DATE_ISO8601) . "\tE\t404 - Could not find $file, called from {$_SERVER['REQUEST_URI']} \n", 3, $docLog);
$head = get_string('stackDoc_404', 'stack');
//error_log(date(DATE_ISO8601) . "\tE\t404 - Could not find $file, called from {$_SERVER['REQUEST_URI']} \n", 3, $docLog);
//$head = stack_string('stackDoc_404', 'stack');
}
$context = context_system::instance();
require_capability('moodle/site:config', $context);
$PAGE->set_context($context);
$PAGE->set_url('/question/type/stack/doc/doc.php');
$PAGE->set_title(stack_string('stackDoc_docs'));
echo $OUTPUT->header();
$pagetitle = "<img src=\"{$webpix}\" style=\"margin-right: 10px;\" />".stack_string('stackDoc_docs');
echo $OUTPUT->heading($pagetitle);
function index($d, $relPath = ''){
// Write a list describing the directory structure, recursive, discriminates for .md files
......@@ -84,9 +93,7 @@ function index($d, $relPath = ''){
$i .= "<li><a href=\"$relPath/$f/\">" . str_replace('_', ' ', $f)
. "</a>" . index($fPath, "$relPath/$f") . '</li>';
} else {
// Old code if (pathinfo($fPath, PATHINFO_EXTENSION) == 'md'
// and $f != 'index.md') {
if ($f != 'index.md') {
if ($f != 'index.md' && '.bak'!= substr($f,-4)) {
$fName = pathinfo($fPath, PATHINFO_FILENAME);
$i .= "<li><a href=\"$relPath/$fName\">" . str_replace('_', ' ', $fName) . "</a></li>";
}
......@@ -100,12 +107,9 @@ function index($d, $relPath = ''){
return $i;
}
// TODO replace this
echo html_head($head . ' - ' . get_string('stackDoc_docs', 'stack'), "$webroot/", "$webroot/styles.css");
?>
<style type="text/css" media="all">
@import "<?php echo $webroot; ?>/styles.css";
ul.dir ul {
display: block;
......@@ -142,33 +146,8 @@ echo html_head($head . ' - ' . get_string('stackDoc_docs', 'stack'), "$webroot/"
</style>
</head>
<body>
<?php
// TODO update these strings
if ($uri == '/') { // I.e. at doc.php/ the docs front page
$links = array($webroot => get_string('stackDoc_mainMenu', 'stack'),
"$webDocs/Site_map" => get_string('stackDoc_siteMap', 'stack'));
} else {
$links = array($webDocs => get_string('stackDoc_home', 'stack'),
'./' => get_string('stackDoc_index', 'stack'),
'../' => get_string('stackDoc_parent', 'stack'),
"$webDocs/Site_map" => get_string('stackDoc_siteMap', 'stack'),
$webroot => get_string('stackDoc_mainMenu', 'stack'));
}
$linkStrs = array();
foreach ($links as $url => $link) $linkStrs[] = "<a href=\"$url\">$link</a>";
$linkStr = implode(' | ', $linkStrs);
$header = $footer = "<p>$linkStr</p>";
$header = "<h2><img src=\"$docsContent/logo-sm.png\" style=\"margin-right: 10px;\" />"
. get_string('stackDoc_docs', 'stack') . "</h2>" . $header;
$header .= "\n<hr />\n";
echo $header;
if (file_exists($file)){
$handle = fopen($file, 'r');
......@@ -176,7 +155,7 @@ if(file_exists($file)){
fclose($handle);
$page = preg_replace('/\\\%CONTENT/', '$$$PARSE_ERROR', $page); // escaped \%CONTENT won't get processed
$page = preg_replace('/\%CONTENT/', $docsContent, $page);
$page = preg_replace('/\%CONTENT/', $docscontent, $page);
$page = preg_replace('/\$\$\$PARSE_ERROR/', '%CONTENT', $page);
if (pathinfo($file, PATHINFO_EXTENSION) == 'md') {
......@@ -189,20 +168,34 @@ if(file_exists($file)){
} else {
?>
<h1><?php echo get_string('stackDoc_404', 'stack'); ?></h1>
<p><?php echo get_string('stackDoc_404message', 'stack'); ?></p>
<h1><?php echo stack_string('stackDoc_404', 'stack'); ?></h1>
<p><?php echo stack_string('stackDoc_404message', 'stack'); ?></p>
<?php
}
if ($uri == '/') {
// I.e. at doc.php/ the docs front page
$links = array($webdocs.'/Site_map' => stack_string('stackDoc_siteMap'));
} else {
$links = array($webdocs => stack_string('stackDoc_home'),
'./' => stack_string('stackDoc_index'),
'../' => stack_string('stackDoc_parent'),
$webdocs.'/Site_map' => stack_string('stackDoc_siteMap'));
}
$linkStrs = array();
foreach ($links as $url => $link) {
$linkstrs[] = "<a href=\"$url\">$link</a>";
}
$linkstr = implode(' | ', $linkstrs);
echo $linkstr;
if ($doc == 'Site_map') {
echo '<h3>' . get_string('stackDoc_directoryStructure', 'stack') . '</h3>' . index($docroot . $docs, $webDocs); // assumes at a file in /
echo '<h3>' . stack_string('stackDoc_directoryStructure', 'stack') . '</h3>' . index($docroot . $docs, $webdocs); // assumes at a file in /
// if in any directory root
// echo '<h3>' . get_string('stackDoc_directoryStructure', 'stack') . '</h3>' . index($docroot . $docs . $uri, $webDocs . rtrim($uri, '/'));
// echo '<h3>' . stack_string('stackDoc_directoryStructure', 'stack') . '</h3>' . index($docroot . $docs . $uri, $webDocs . rtrim($uri, '/'));
}
echo $footer;
?>
</body>
</html>
echo $OUTPUT->footer();
......@@ -6,7 +6,7 @@ The STACK logo is based on the following problem.
The answer is that there is no limit to how far it can lean! A physical model is shown below.
![A model of the STACK logo](../../pix/logoJB.jpg)
![A model of the STACK logo](%CONTENT/logoJB.jpg)
## The mathematics of this problem
......
......@@ -21,6 +21,8 @@ Gradually change variable and function names to conform to Maxima coding standar
Basic skeleton import of STACK 2 questions and storage in the database. Teacher can create a question version and attempt this from the database, with no caching.
1. Get this plumbed together without any validation.
## Milestone 3.
Reinstate the dynamic cache and make it work with one Moodle behaviour. At this point we should be able to include a STACK question into a moodle quiz, for demonstration and testing purposes.
......
# Site map
A directory listing of all the entire documents.
# STACK
[![STACK Logo](%CONTENT/logo-trans.png)](About/Logo)
**S**ystem for **T**eaching and **A**ssessment using a **C**omputer algebra **K**ernel
Welcome to the official user documentation for the [STACK project](About/).
STACK is an open-source system for computer-aided assessment in Mathematics and related disciplines, with emphasis on formative assessment.
More about what we are trying to achieve can be found under [the philosophy of STACK](About/The_philosophy_of_STACK).
## Where to start ##
* **Teachers**
1. [Authoring questions](Authoring/), including an [authoring quick start guide](Authoring/Authoring_quick_start).
2. [Question testing](Authoring/Testing).
3. [Deploying questions](Authoring/Deploying).
4. [Including questions in a Moodle Quiz](Components/Moodle#Including_questions)
5. [Reviewing](Authoring/Reviewing)
* [Frequently asked questions](Authoring/Author_FAQ)
* [**Students**](Students/)
* [Frequently asked questions](Students/FAQ).
* [Input instructions](Students/Answer_input).
* [How answers are assessed](Students/Answer_assessment).
* **Administrators**
* For [Installation instructions](Installation/) there is a [detailed installation guide](Installation/Installation_instructions). There is also specific information for platforms:
* [Microsoft](Installation/Installing_STACK_on_an_MS_Platform)
* [Linux](Installation/Installing_STACK_on_linux)
* [Mac OS X](Installation/Installing_STACK_on_Mac_OS_X)
* **Reference**
* Documentation is arranged in categories as a reference to STACK. Please use the [site map](Site_map).
* **[Developers]()**
* [Developer docs](Developer/)
* [Development track](Developer/Development_track)
* STACK source code is hosted on [sourceForge](https://sourceforge.net/tracker2/?group_id=119224) by cvs.
From here you can track development and report bugs.
## Community ##
[Community](Community/) support is important to the STACK project.
There are active [discussions on our Moodle forums](http://stack.bham.ac.uk/live/course/view.php?id=16), and we have listed our [Development track](Developer/Development_track).
......@@ -249,3 +249,13 @@ $string['ATSysEquiv_SA_missing_variables'] = 'Your answer is missing one or
$string['ATSysEquiv_SA_extra_variables'] = 'Your answer includes too many variables!';
$string['ATSysEquiv_SA_system_underdetermined'] = 'The equations in your system appear to be correct, but you need others besides.';
$string['ATSysEquiv_SA_system_overdetermined'] = 'The entries in red below are those that are incorrect. {$a->m0} ';
// Documentation strings
$string['stackDoc_404'] = 'Error 404';
$string['stackDoc_docs'] = 'STACK Documentation';
$string['stackDoc_home'] = 'Documentation home';
$string['stackDoc_index'] = 'Category index';
$string['stackDoc_parent'] = 'Parent';
$string['stackDoc_siteMap'] = 'Site map';
$string['stackDoc_404message'] = 'File not found.';
$string['stackDoc_directoryStructure'] = 'Directory structure';
pix/logo-sm.png

853 B

pix/logo-trans.png

4.08 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment