|
From: <dav...@us...> - 2010-03-30 10:55:25
|
Revision: 2408
http://qtitools.svn.sourceforge.net/qtitools/?rev=2408&view=rev
Author: davemckain
Date: 2010-03-30 10:55:19 +0000 (Tue, 30 Mar 2010)
Log Message:
-----------
playr: Added replacement for pre-QTIEngine media.php that
works as a simple proxy to access test-specific resources
on the backend engine. This should allow things like images
inside tests to work correctly.
Modified Paths:
--------------
branches/mathassess/qtiplayr/MathAssessEngine-support/css/test.css
branches/mathassess/qtiplayr/media.php
Added Paths:
-----------
branches/mathassess/qtiplayr/testresource.php
Modified: branches/mathassess/qtiplayr/MathAssessEngine-support/css/test.css
===================================================================
--- branches/mathassess/qtiplayr/MathAssessEngine-support/css/test.css 2010-03-30 10:53:43 UTC (rev 2407)
+++ branches/mathassess/qtiplayr/MathAssessEngine-support/css/test.css 2010-03-30 10:55:19 UTC (rev 2408)
@@ -1,6 +1,6 @@
/* (This provides full rendering of tests) */
-body.mathassessengine, .mathassessengine #body {
+.mathassessengine.test {
font-family: verdana, sans-serif;
font-size: small;
text-align: center;
@@ -9,47 +9,47 @@
margin:0px;
}
-.mathassessengine #body-container {
+.mathassessengine.test #body-container {
width: 800px;
margin-left: auto;
margin-right: auto;
}
-.mathassessengine .outer-box {
+.mathassessengine.test .outer-box {
border: thin solid #A9A9A9;
text-align: left;
}
-.mathassessengine .box-title {
+.mathassessengine.test .box-title {
display:inline;
font-size: xx-small;
color: #A9A9A9;
padding:10px;
background-color:inherit
}
-.mathassessengine .inner-box {
+.mathassessengine.test .inner-box {
border: thin dashed #A9A9A9;
margin-bottom: 10px;
margin-left: 10px;
margin-right: 10px;
padding: 5px
}
-.mathassessengine .feedback_assessmentTest {
+.mathassessengine.test .feedback_assessmentTest {
}
-.mathassessengine .feedback_mathassessenginePart {
+.mathassessengine.test .feedback_mathassessengine.testPart {
font-style: italic;
}
-.mathassessengine .feedback_title {
+.mathassessengine.test .feedback_title {
font-weight: bold;
margin: 0;
padding: 0;
}
-.mathassessengine .validation,
-.mathassessengine .flash {
+.mathassessengine.test .validation,
+.mathassessengine.test .flash {
font-weight: bold;
color: red;
background-color:inherit;
}
-.mathassessengine img, .mathassessengine applet {
+.mathassessengine.test img, .mathassessengine.test applet {
display: block;
margin-left: auto;
margin-right: auto;
@@ -58,21 +58,21 @@
border: none;
}
-.mathassessengine h1 {
+.mathassessengine.test h1 {
font-size: large;
}
-.mathassessengine h2 {
+.mathassessengine.test h2 {
display: block;
color: white;
font-size: medium;
background-color: #535C75;
}
-.mathassessengine #controls {
+.mathassessengine.test #controls {
height: 50px;
float: right;
}
-.mathassessengine .spacer {
+.mathassessengine.test .spacer {
height: 5px;
clear:both;
}
Modified: branches/mathassess/qtiplayr/media.php
===================================================================
--- branches/mathassess/qtiplayr/media.php 2010-03-30 10:53:43 UTC (rev 2407)
+++ branches/mathassess/qtiplayr/media.php 2010-03-30 10:55:19 UTC (rev 2408)
@@ -1,62 +1,68 @@
<?php
- include('playrlib.inc.php');
-
- require_once("../../config.php");
- require_once("lib.php");
-
- $id = $_GET['id'];
-
- //workaround strange bug (something to do with url encoding and the applet I guess)
- if (!isset($_GET['m'])) {
- $m = $_GET['amp;m'];
- } else {
- $m = $_GET['m'];
- }
-
- if ($id) {
- if (! $cm = get_record("course_modules", "id", $id)) {
- error("Course Module ID was incorrect");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("Course is misconfigured");
- }
-
- if (! $qtiplayr = get_record("qtiplayr", "id", $cm->instance)) {
- error("Course module is incorrect");
- }
-
- } else {
- if (! $qtiplayr = get_record("qtiplayr", "id", $a)) {
- error("Course module is incorrect");
- }
- if (! $course = get_record("course", "id", $qtiplayr->course)) {
- error("Course is misconfigured");
- }
- if (! $cm = get_coursemodule_from_instance("qtiplayr", $qtiplayr->id, $course->id)) {
- error("Course Module ID was incorrect");
- }
- }
-
- require_login($course->id);
- if (!$id) $id = $cm->id;
-
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- $SESSID = "jsessionid.".$USER->id.".".$qtiplayr->id;
- $ASSESS_ID = $SESSID."_assess";
-
- if (isset($_SESSION[$SESSID])) {
- //or load the existing session
- $sessionid = $_SESSION[$SESSID];
-
- $content = file_get_contents(_getBaseURL()."/../media.jsp;jsessionid=".$sessionid."?m=".$m, false);
- foreach ($http_response_header as $k => $v) {
- if (strpos($v, "Content-Type") !== FALSE) {
- header($v);
- break;
- }
- }
- echo $content;
- }
+// DM: Note that this appears to be a hang-over from the pre-QTIEngine version
+// of the plugin and it was never ported to use QTIEngine. I've done similar
+// (but less intricate) version for MAEngine - see testresource.php.
+//
+header('HTTP/1.0 400 Bad Request');
+//
+// include('playrlib.inc.php');
+//
+// require_once("../../config.php");
+// require_once("lib.php");
+//
+// $id = $_GET['id'];
+//
+// //workaround strange bug (something to do with url encoding and the applet I guess)
+// if (!isset($_GET['m'])) {
+// $m = $_GET['amp;m'];
+// } else {
+// $m = $_GET['m'];
+// }
+//
+// if ($id) {
+// if (! $cm = get_record("course_modules", "id", $id)) {
+// error("Course Module ID was incorrect");
+// }
+//
+// if (! $course = get_record("course", "id", $cm->course)) {
+// error("Course is misconfigured");
+// }
+//
+// if (! $qtiplayr = get_record("qtiplayr", "id", $cm->instance)) {
+// error("Course module is incorrect");
+// }
+//
+// } else {
+// if (! $qtiplayr = get_record("qtiplayr", "id", $a)) {
+// error("Course module is incorrect");
+// }
+// if (! $course = get_record("course", "id", $qtiplayr->course)) {
+// error("Course is misconfigured");
+// }
+// if (! $cm = get_coursemodule_from_instance("qtiplayr", $qtiplayr->id, $course->id)) {
+// error("Course Module ID was incorrect");
+// }
+// }
+//
+// require_login($course->id);
+// if (!$id) $id = $cm->id;
+//
+// $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+//
+// $SESSID = "jsessionid.".$USER->id.".".$qtiplayr->id;
+// $ASSESS_ID = $SESSID."_assess";
+//
+// if (isset($_SESSION[$SESSID])) {
+// //or load the existing session
+// $sessionid = $_SESSION[$SESSID];
+//
+// $content = file_get_contents(_getBaseURL()."/../media.jsp;jsessionid=".$sessionid."?m=".$m, false);
+// foreach ($http_response_header as $k => $v) {
+// if (strpos($v, "Content-Type") !== FALSE) {
+// header($v);
+// break;
+// }
+// }
+// echo $content;
+// }
?>
Added: branches/mathassess/qtiplayr/testresource.php
===================================================================
--- branches/mathassess/qtiplayr/testresource.php (rev 0)
+++ branches/mathassess/qtiplayr/testresource.php 2010-03-30 10:55:19 UTC (rev 2408)
@@ -0,0 +1,50 @@
+<?php // $Id$
+/**
+ * Simple HTTP proxy for delivering resources on the backend server.
+ *
+ * (This is a new addition for the MathAssessEngine-aware version of the plugin.
+ * It replaces the old media.php which never seemed to get ported over to QTIEngine.
+ * Note that I've gone with the simplest possible implementation, so there's no session
+ * management and only a very basic attempt at security by whitelisting paths on the
+ * underlying MAEngine that this proxy will work with.
+ */
+
+require_once('playrlib.inc.php');
+require_once('../../config.php');
+require_once('lib.php');
+
+$path_whitelist = array('/applets', '/content', '/css', '/images', '/js', '/Jscript');
+
+function proxy_resource($path) {
+ global $CFG, $path_whitelist;
+
+ $is_allowed = false;
+ foreach ($path_whitelist as $i => $allowed_path) {
+ if (strncmp($path, $allowed_path, strlen($allowed_path))==0) {
+ $is_allowed = true;
+ break;
+ }
+ }
+
+ if ($is_allowed) {
+ $http_client = _newClient();
+ $http_client->get($CFG->qtiplayr_contextpath . $path);
+ $response = $http_client->get_response();
+ if ($response->get_status()==HTTP_STATUS_OK) {
+ header("Content-Type: " . $response->get_content_type());
+ header("Content-Length: " . $response->get_content_length());
+ echo $response->get_body();
+ }
+ else {
+ header('HTTP/1.0 404 Not Found');
+ }
+ }
+ else {
+ header('HTTP/1.0 401 Forbidden');
+ }
+}
+
+$resource_path = $_SERVER['PATH_INFO'];
+proxy_resource($resource_path);
+
+?>
Property changes on: branches/mathassess/qtiplayr/testresource.php
___________________________________________________________________
Added: svn:keywords
+ Id Date Revision Author
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|