merging MOODLE_19_QUESTIONS with HEAD

This commit is contained in:
jamiesensei 2007-08-09 21:51:09 +00:00
parent 3bee1ead40
commit 271e6decda
47 changed files with 2807 additions and 1546 deletions

View file

@ -36,8 +36,12 @@ class question_edit_match_form extends question_edit_form {
} else {
$countsubquestions = 0;
}
$repeatsatstart = (QUESTION_NUMANS_START > ($countsubquestions + QUESTION_NUMANS_ADD))?
QUESTION_NUMANS_START : ($countsubquestions + QUESTION_NUMANS_ADD);
if ($this->question->formoptions->repeatelements){
$repeatsatstart = (QUESTION_NUMANS_START > ($countsubquestions + QUESTION_NUMANS_ADD))?
QUESTION_NUMANS_START : ($countsubquestions + QUESTION_NUMANS_ADD);
} else {
$repeatsatstart = $countsubquestions;
}
$mform->setType('subanswer', PARAM_TEXT);
$mform->setType('subquestion', PARAM_TEXT);
@ -67,7 +71,7 @@ class question_edit_match_form extends question_edit_form {
}
function validation($data){
$errors = array();
$errors = parent::validation($data);
$answers = $data['subanswers'];
$questions = $data['subquestions'];
$questioncount = 0;

View file

@ -616,7 +616,7 @@ class question_match_qtype extends default_questiontype {
/**
* Decode links in question type specific tables.
* @return bool success or failure.
*/
*/
function decode_content_links_caller($questionids, $restore, &$i) {
$status = true;
@ -646,6 +646,38 @@ class question_match_qtype extends default_questiontype {
return $status;
}
function find_file_links($question, $courseid){
// find links in the question_match_sub table.
$urls = array();
foreach ($question->options->subquestions as $subquestion) {
$urls += question_find_file_links_from_html($subquestion->questiontext, $courseid);
}
//set all the values of the array to the question object
if ($urls){
$urls = array_combine(array_keys($urls), array_fill(0, count($urls), array($question->id)));
}
$urls = array_merge_recursive($urls, parent::find_file_links($question, $courseid));
return $urls;
}
function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination){
parent::replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination);
// replace links in the question_match_sub table.
if (isset($question->options->subquestions)){
foreach ($question->options->subquestions as $subquestion) {
$subquestionchanged = false;
$subquestion->questiontext = question_replace_file_links_in_html($subquestion->questiontext, $fromcourseid, $tocourseid, $url, $destination, $subquestionchanged);
if ($subquestionchanged){//need to update rec in db
if (!update_record('question_match_sub', addslashes_recursive($subquestion))) {
error('Couldn\'t update \'question_match_sub\' record '.$subquestion->id);
}
}
}
}
}
}
//// END OF CLASS ////