Skip to content

Commit

Permalink
Add deflate to .htaccess
Browse files Browse the repository at this point in the history
add emulateuser admin action 
change behavior show answer after last attempt 
bug fix math2TeX display
bug fix ? to " issue

git-svn-id: http://imathas.googlecode.com/svn/trunk@311 c89b4f0b-ac2a-0410-9773-c9071ee4f95d
  • Loading branch information
drlippman committed Jan 23, 2009
1 parent e403175 commit 84b43db
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ AddType image/svg+xml .svg
AddType image/svg+xml .svgz
AddType image/x-icon .ico
Options -Indexes

AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript
BrowserMatch \bMSIE\s6 !no-gzip gzip-only-text/html
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.[0678] no-gzip
7 changes: 6 additions & 1 deletion admin/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
require("../validate.php");

switch($_GET['action']) {

case "emulateuser":
if ($myrights < 100 ) { break;}
$be = $_GET['uid'];
$query = "UPDATE imas_sessions SET userid='$be' WHERE sessionid='$sessionid'";
mysql_query($query) or die("Query failed : " . mysql_error());
break;
case "chgrights":
if ($myrights < 100 && $_POST['newrights']>75) { break;}
if ($myrights < 75) { echo "You don't have the authority for this action"; break;}
Expand Down
31 changes: 24 additions & 7 deletions assessment/displayq2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
function displayq($qnidx,$qidx,$seed,$doshowans,$showhints,$attemptn,$returnqtxt=false,$clearla=false,$seqinactive=false) {
global $imasroot, $myrights;
srand($seed);
if (is_int($doshowans) && $doshowans==2) {
$doshowans = true;
$nosabutton = true;
} else {
$nosabutton = false;
}

/*if (func_num_args()>5 && func_get_arg(5)==true) {
$returnqtxt = true;
Expand Down Expand Up @@ -212,21 +218,32 @@ function displayq($qnidx,$qidx,$seed,$doshowans,$showhints,$attemptn,$returnqtxt
echo "<p class=\"tips\">Box ".($iidx+1).": $tip</p>";
}
if ($doshowans && (!isset($showanswer) || (is_array($showanswer) && !isset($showanswer[$iidx]))) && $shans[$iidx]!=='') {

echo "<div><input class=\"sabtn\" type=button value=\"Show Answer\" onClick='javascript:document.getElementById(\"ans$qnidx-$iidx\").className=\"shown\";' />"; //AMprocessNode(document.getElementById(\"ans$qnidx-$iidx\"));'>";
echo filter(" <span id=\"ans$qnidx-$iidx\" class=\"hidden\">{$shans[$iidx]}</span></div>\n");
if ($nosabutton) {
echo filter("<div>Answer: {$shans[$iidx]} </div>\n");
} else {
echo "<div><input class=\"sabtn\" type=button value=\"Show Answer\" onClick='javascript:document.getElementById(\"ans$qnidx-$iidx\").className=\"shown\";' />"; //AMprocessNode(document.getElementById(\"ans$qnidx-$iidx\"));'>";
echo filter(" <span id=\"ans$qnidx-$iidx\" class=\"hidden\">{$shans[$iidx]}</span></div>\n");
}
} else if ($doshowans && isset($showanswer) && is_array($showanswer)) { //use part specific showanswer
if (isset($showanswer[$iidx])) {
echo "<div><input class=\"sabtn\" type=button value=\"Show Answer\" onClick='javascript:document.getElementById(\"ans$qnidx-$iidx\").className=\"shown\";' />";// AMprocessNode(document.getElementById(\"ans$qnidx-$iidx\"));'>";
echo filter(" <span id=\"ans$qnidx-$iidx\" class=\"hidden\">{$showanswer[$iidx]}</span></div>\n");
if ($nosabutton) {
echo filter("<div>Answer: {$showanswer[$iidx]} </div>\n");
} else {
echo "<div><input class=\"sabtn\" type=button value=\"Show Answer\" onClick='javascript:document.getElementById(\"ans$qnidx-$iidx\").className=\"shown\";' />";// AMprocessNode(document.getElementById(\"ans$qnidx-$iidx\"));'>";
echo filter(" <span id=\"ans$qnidx-$iidx\" class=\"hidden\">{$showanswer[$iidx]}</span></div>\n");
}
}
}
}
echo "</div>\n";

if ($doshowans && isset($showanswer) && !is_array($showanswer)) { //single showanswer defined
echo "<div><input class=\"sabtn\" type=button value=\"Show Answer\" onClick='javascript:document.getElementById(\"ans$qnidx\").className=\"shown\"; AMprocessNode(document.getElementById(\"ans$qnidx\"));' />";
echo filter(" <span id=\"ans$qnidx\" class=\"hidden\">$showanswer </span></div>\n");
if ($nosabutton) {
echo filter("<div>Answer: $showanswer </div>\n");
} else {
echo "<div><input class=\"sabtn\" type=button value=\"Show Answer\" onClick='javascript:document.getElementById(\"ans$qnidx\").className=\"shown\"; AMprocessNode(document.getElementById(\"ans$qnidx\"));' />";
echo filter(" <span id=\"ans$qnidx\" class=\"hidden\">$showanswer </span></div>\n");
}
}
echo "</div>\n";
}
Expand Down
39 changes: 29 additions & 10 deletions assessment/showtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,17 +827,33 @@
if ($allowregen) {
echo "<p><a href=\"showtest.php?action=skip&amp;to=$qn&amp;regen=$qn\">Try another similar question</a></p>\n";
}

echo "<p>Question scored. ";
if ($lefttodo > 0) {
echo "<p>Question scored. <b>Select another question</b></p>";
if ($reattemptsremain == false && $showeachscore) {
echo "<p>This question, with your last answer";
if (($showansafterlast && $qi[$questions[$qn]]['showans']=='0') || $qi[$questions[$qn]]['showans']=='F') {
echo " and correct answer";
} else if ($showansduring && $qi[$questions[$qn]]['showans']=='0' && $qi[$questions[$qn]]['showans']=='0' && $testsettings['showans']==$attempts[$qn]) {
echo " and correct answer";
}
echo '<b>Select another question</b></p>';
} else {
echo '</p>';
}
if ($reattemptsremain == false && $showeachscore) {
echo "<p>This question, with your last answer";
if (($showansafterlast && $qi[$questions[$qn]]['showans']=='0') || $qi[$questions[$qn]]['showans']=='F') {
echo " and correct answer";
$showcorrectnow = true;
} else if ($showansduring && $qi[$questions[$qn]]['showans']=='0' && $qi[$questions[$qn]]['showans']=='0' && $testsettings['showans']==$attempts[$qn]) {
echo " and correct answer";
$showcorrectnow = true;
} else {
$showcorrectnow = false;
}
if ($showcorrectnow) {
echo ', is displayed below</p>';

displayq($qn,$qi[$questions[$qn]]['questionsetid'],$seeds[$qn],2,false,$attempts[$qn],false,false);
} else {
echo ", can be viewed by clicking on the question number again.</p>";
}
}
if ($lefttodo > 0) {
echo "<p>or click <a href=\"showtest.php?action=skip&amp;done=true\">here</a> to end and score test now</p>\n";
} else {
echo "<a href=\"showtest.php?action=skip&amp;done=true\">Click here to finalize and score test</a>\n";
Expand Down Expand Up @@ -887,8 +903,11 @@
if (!$reattemptsremain && $showeachscore) {
echo "<p>Question with last attempt is displayed for your review only</p>";
$qshowans = ((($showansafterlast && $qi[$questions[$next]]['showans']=='0') || $qi[$questions[$next]]['showans']=='F') || ($showansduring && $qi[$questions[$next]]['showans']=='0' && $attempts[$next]>=$testsettings['showans']));

displayq($next,$qi[$questions[$next]]['questionsetid'],$seeds[$next],$qshowans,false,$attempts[$next],false,false);
if ($qshowans) {
displayq($next,$qi[$questions[$next]]['questionsetid'],$seeds[$next],2,false,$attempts[$next],false,false);
} else {
displayq($next,$qi[$questions[$next]]['questionsetid'],$seeds[$next],false,false,$attempts[$next],false,false);
}
}
echo "</div>\n";
}
Expand Down
3 changes: 2 additions & 1 deletion filter/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
}
function mathfiltercallback($arr) {
global $AMT,$mathimgurl;
$arr[1] = str_replace(array('&ne;','&quot;','&lt;','&gt;','&le;','&ge;'),array('ne','"','lt','gt','le','ge'),$arr[1]);
//$arr[1] = str_replace(array('&ne;','&quot;','&lt;','&gt;','&le;','&ge;'),array('ne','"','lt','gt','le','ge'),$arr[1]);
$arr[1] = str_replace(array('&ne;','&quot;','&le;','&ge;'),array('ne','"','le','ge'),$arr[1]);
$tex = $AMT->convert($arr[1]);
if (trim($tex)=='') {
return '';
Expand Down
8 changes: 4 additions & 4 deletions filter/math/ASCIIMath2TeX.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
ASCIIMath2TeX.php
ASCIIMath2TeX.php - Version 1.1
==============
This file contains functions to convert ASCII math notation
to TeX, which can be rendered via CGI to images.
Expand Down Expand Up @@ -161,8 +161,8 @@ class AMtoTeX
array( 'input'=>'ddots'),
array( 'input'=>'diamond'),
array( 'input'=>'square', 'tex'=>'boxempty'),
array( 'input'=>'|_', 'tex'=>'lfloor'),
array( 'input'=>'_|', 'tex'=>'rfloor'),
array( 'input'=>'|__', 'tex'=>'lfloor'),
array( 'input'=>'__|', 'tex'=>'rfloor'),
array( 'input'=>'|~', 'tex'=>'lceil'),
array( 'input'=>'lceiling', 'output'=>'|~', 'definition'=>TRUE),
array( 'input'=>'~|', 'tex'=>'rceil'),
Expand Down Expand Up @@ -717,10 +717,10 @@ function AMTparseExpr($str,$rightbracket) {
return array($newFrag,$str);
}
function AMTparseAMtoTeX($str) {

$this->AMnestingDepth = 0;
$str = str_replace(array('&nbsp;','&gt;','&lt;'),array('','>','<'),$str);
$str = preg_replace('/^\s+/','',$str);

$result = $this->AMTparseExpr($str, false);
return ($result[0]);
}
Expand Down
2 changes: 1 addition & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function fileBrowserCallBack(field_name, url, type, win) {
echo <<<END
function imascleanup(type, value) {
if (type=="get_from_editor") {
value = value.replace(/[\x84\x93\x94]/g,'"');
//value = value.replace(/[\x84\x93\x94]/g,'"');
//var rl = '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2018|\u2019,\',\u2013|\u2014|\u2015|\u2212,-'.split(',');
//for (var i=0; i<rl.length; i+=2) {
// value = value.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
Expand Down

0 comments on commit 84b43db

Please sign in to comment.