Beispiel #1
0
    require AT_INCLUDE_PATH . 'header.inc.php';
    //	$msg->addConfirm(array('MEDIA_FILE_EXISTED', $existing_files));
    //	$msg->printConfirm();
    echo '<form action="" method="POST">';
    echo '<div class="input-form">';
    echo '<div class="row">';
    $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="' . $_POST['url'] . '" />';
    echo '</div></div>';
    echo '</form>';
    require AT_INCLUDE_PATH . 'footer.inc.php';
    exit;
}
//Get the XML file out and start importing them into our database.
//TODO:	import_test.php shares approx. the same code as below, just that import_test.php has
//		an extra line of code that uses a stack to remember the question #.  Might want to
//		create a function for this.
$qti_import = new QTIImport($import_path);
$qti_import->importQuestions($attributes);
//debug('done');
clr_dir(AT_CONTENT_DIR . 'import/' . $_SESSION['course_id']);
if (!$msg->containsErrors()) {
    $msg->addFeedback('IMPORT_SUCCEEDED');
}
header('Location: question_db.php');
exit;
Beispiel #2
0
    echo '<div class="row">';
    $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);
/** 
 * 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;
}