Esempio n. 1
0
    $msg->printInfos(array('MEDIA_FILE_EXISTED', $existing_files));
    echo '</div>';
    echo '<div class="row buttons">';
    echo '<input type="submit" class="" name="submit_yes" value="' . _AT('yes') . '"/>';
    echo '<input type="submit" class="" name="submit_no" value="' . _AT('no') . '"/>';
    echo '<input type="hidden" name="submit_import" value="submit_import" />';
    echo '<input type="hidden" name="url" value="' . AT_print($_POST['url'], 'input.hidden') . '" />';
    echo '</div></div>';
    echo '</form>';
    require TR_INCLUDE_PATH . 'footer.inc.php';
    exit;
}
//Get the XML file out and start importing them into our database.
//TODO: See question_import.php 287-289.
$qti_import = new QTIImport($import_path);
$qids = $qti_import->importQuestions($attributes);
//import test
$tid = $qti_import->importTest();
//associate question and tests
foreach ($qids as $order => $qid) {
    if (isset($qti_import->weights[$order])) {
        $weight = round($qti_import->weights[$order]);
    } else {
        $weight = 0;
    }
    $new_order = $order + 1;
    //	$sql = "INSERT INTO " . TABLE_PREFIX . "tests_questions_assoc" .
    //			"(test_id, question_id, weight, ordering, required) " .
    //			"VALUES ($tid, $qid, $weight, $new_order, 0)";
    //	$result = mysql_query($sql, $db);
    $testsQuestionsAssocDAO = new TestsQuestionsAssocDAO();
/** 
 * This function will take the test accessment XML and add these to the database.
 * @param	string	The path of the XML, without the import_path.
 * @param	mixed	An item singleton.  Contains the info of this item, namely, the accessment details.
 *					The item must be an object created by the ims class.
 * @param	string	the import path
 * @return	mixed	An Array that contains all the question IDs that have been imported.
 */
function addQuestions($xml, $item, $import_path)
{
    global $test_title;
    $qti_import = new QTIImport($import_path);
    $tests_xml = $import_path . $xml;
    //Mimic the array for now.
    $test_attributes['resource']['href'] = $item['href'];
    $test_attributes['resource']['type'] = preg_match('/imsqti_xmlv1p2/', $item['type']) == 1 ? 'imsqti_xmlv1p2' : 'imsqti_xmlv1p1';
    $test_attributes['resource']['file'] = $item['file'];
    //Get the XML file out and start importing them into our database.
    //TODO: See question_import.php 287-289.
    $qids = $qti_import->importQuestions($test_attributes);
    $test_title = $qti_import->title;
    return $qids;
}