Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-14406

Ensure 'length' field for description type questions is 0 and that
default for all questions is 0
  • Loading branch information...
commit 0393331c13952ae0c6acafb6eb1d184be6965f95 1 parent 5f3d54f
thepurpleblob authored
View
30 question/format.php
@@ -392,6 +392,7 @@ function create_category_path($catpath, $delimiter='/') {
}
return $category;
}
+
/**
* Return complete file within an array, one item per line
* @param string filename name of file
@@ -474,6 +475,7 @@ function defaultquestion() {
$question->incorrectfeedback = '';
$question->answernumbering = 'abc';
$question->penalty = 0.1;
+ $question->length = 1;
// this option in case the questiontypes class wants
// to know where the data came from
@@ -550,6 +552,33 @@ function importimagefile( $path, $base64 ) {
return $newfile;
}
+ /**
+ * Utility function to reconstruct part of the
+ * xml data structure (from xmlize) as a string in order
+ * to identify the actual data therein
+ * @param array $xml section of the xml data structure
+ * @return string data with everything else removed
+ */
+ function xmltostring( $xml ) {
+ // if it's not an array then it's probably just data
+ if (!is_array($xml)) {
+ $text = s(addslashes($xml));
+ }
+ else {
+ // otherwise parse the array
+ $text = '';
+ foreach ($xml as $tag=>$data) {
+ // if tag is '@' then it's attributes and we don't care
+ if ($tag!=='@') {
+ $text = $text . $this->xmltostring( $data );
+ }
+ }
+ }
+
+ return $text;
+ }
+
+
/*******************
* EXPORT FUNCTIONS
*******************/
@@ -703,6 +732,7 @@ function exportprocess() {
fclose($fh);
return true;
}
+
/**
* get the category as a path (e.g., tom/dick/harry)
* @param int id the id of the most nested catgory
View
2  question/format/gift/format.php
@@ -277,6 +277,8 @@ function readquestion($lines) {
switch ($question->qtype) {
case DESCRIPTION:
+ $question->defaultgrade = 0;
+ $question->length = 0;
return $question;
break;
case ESSAY:
View
2  question/format/xml/format.php
@@ -302,6 +302,8 @@ function import_description( $question ) {
$qo = $this->import_headers( $question );
// header parts particular to shortanswer
$qo->qtype = DESCRIPTION;
+ $qo->defaultgrade = 0;
+ $qo->length = 0;
return $qo;
}
Please sign in to comment.
Something went wrong with that request. Please try again.