Change html_entity_decode to PHP5 version and also fix problem with shortening question to derive name.
This commit is contained in:
thepurpleblob
2008-08-19 10:46:27 +00:00
parent ac6a549219
commit 4a5d721cd6
+13 -47
View File
@@ -22,40 +22,6 @@ class qformat_blackboard extends qformat_default {
}
/********************************
function readdata($filename) {
/// Returns complete file with an array, one item per line
if (is_readable($filename)) {
$zip = zip_open($filename);
$zip_entry = $zip_read($zip);
if (strstr($zip_entry_name($zip_entry), "imsmanifest") == 0)
$zip_entry = $zip_read($zip); // skip past manifest file
if (zip_entry_open($zip, $zip_entry, "r")) {
$strbuf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$buf = explode("\n", $strbuf);
zip_entry_close($zip_entry);
zip_close($zip);
return $buf;
} else {
zip_close($zip);
return false;
}
}
return false;
}
********************************/
function readquestions ($lines) {
/// Parses an array of lines into an array of questions,
/// where each item is a question object as defined by
@@ -101,11 +67,11 @@ function process_tf($xml, &$questions) {
// put questiontext in question object
if ($ishtml) {
$question->questiontext = html_entity_decode_php4(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
$question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8');
}
$question->questiontext = $question->questiontext;
// put name in question object
$question->name = substr($question->questiontext, 0, 254);
$question->name = shorten_text($question->questiontext, 254);
$choices = $thisquestion["#"]["ANSWER"];
@@ -154,12 +120,12 @@ function process_mc($xml, &$questions) {
// put questiontext in question object
if ($ishtml) {
$question->questiontext = html_entity_decode_php4(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
$question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8');
}
$question->questiontext = $question->questiontext;
// put name of question in question object, careful of length
$question->name = substr($question->questiontext, 0, 254);
$question->name = shorten_text($question->questiontext, 254);
$choices = $thisquestion["#"]["ANSWER"];
for ($j = 0; $j < sizeof ($choices); $j++) {
@@ -167,7 +133,7 @@ function process_mc($xml, &$questions) {
$choice = trim($choices[$j]["#"]["TEXT"][0]["#"]);
// put this choice in the question object.
if ($ishtml) {
$question->answer[$j] = html_entity_decode_php4($choice);
$question->answer[$j] = html_entity_decode($choice,ENT_QUOTES,'UTF-8');
}
$question->answer[$j] = $question->answer[$j];
@@ -177,13 +143,13 @@ function process_mc($xml, &$questions) {
if (strcmp ($id, $correct_answer_id) == 0) {
$question->fraction[$j] = 1;
if ($ishtml) {
$question->feedback[$j] = html_entity_decode_php4(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]));
$question->feedback[$j] = html_entity_decode(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]),ENT_QUOTES,'UTF-8');
}
$question->feedback[$j] = $question->feedback[$j];
} else {
$question->fraction[$j] = 0;
if ($ishtml) {
$question->feedback[$j] = html_entity_decode_php4(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]));
$question->feedback[$j] = html_entity_decode(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]),ENT_QUOTES,'UTF-8');
}
$question->feedback[$j] = $question->feedback[$j];
}
@@ -220,11 +186,11 @@ function process_ma($xml, &$questions) {
// put questiontext in question object
if ($ishtml) {
$question->questiontext = html_entity_decode_php4(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
$question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8');
}
$question->questiontext = $question->questiontext;
// put name of question in question object
$question->name = substr($question->questiontext, 0, 254);
$question->name = shorten_text($question->questiontext, 254);
$choices = $thisquestion["#"]["ANSWER"];
$correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"];
@@ -284,11 +250,11 @@ function process_fib($xml, &$questions) {
// put questiontext in question object
if ($ishtml) {
$question->questiontext = html_entity_decode_php4(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
$question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8');
}
$question->questiontext = $question->questiontext;
// put name of question in question object
$question->name = substr($question->questiontext, 0, 254);
$question->name = shorten_text($question->questiontext, 254);
$answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]);
@@ -338,11 +304,11 @@ function process_matching($xml, &$questions) {
// put questiontext in question object
if ($ishtml) {
$question->questiontext = html_entity_decode_php4(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
$question->questiontext = html_entity_decode(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]),ENT_QUOTES,'UTF-8');
}
$question->questiontext = $question->questiontext;
// put name of question in question object
$question->name = substr($question->questiontext, 0, 254);
$question->name = shorten_text($question->questiontext, 254);
$choices = $thisquestion["#"]["CHOICE"];
for ($j = 0; $j < sizeof ($choices); $j++) {