}
 foreach ($loop_var as $array_id => $test_xml_file) {
     //check if this item is the qti item object, or it is the content item obj
     //switch it to qti obj if it's content item obj
     if ($items[$item_id]['type'] == 'webcontent') {
         $item_qti = $items[$array_id];
     } else {
         $item_qti = $items[$item_id];
     }
     //call subrountine to add the questions.
     $qids = addQuestions($test_xml_file, $item_qti, $import_path);
     //import test
     if ($test_title == '') {
         $test_title = $content_info['title'];
     }
     $tid = $qti_import->importTest($test_title);
     //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);
     }
     //associate content and test
     $sql = 'INSERT INTO ' . TABLE_PREFIX . 'content_tests_assoc' . '(content_id, test_id) ' . 'VALUES (' . $items[$item_id]['real_content_id'] . ", {$tid})";
     $result = mysql_query($sql, $db);
     //			if (!$msg->containsErrors()) {
Esempio n. 2
0
    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();
    $testsQuestionsAssocDAO->Create($tid, $qid, $weight, $new_order);
}
Esempio n. 3
0
 //	$result = mysql_query($sql, $db) or die(mysql_error());
 /* get the content id and update $items */
 //	$items[$item_id]['real_content_id'] = mysql_insert_id($db);
 /* get the tests associated with this content */
 if (!empty($items[$item_id]['tests']) || strpos($items[$item_id]['type'], 'imsqti_xmlv1p2/imscc_xmlv1p0') !== false) {
     $qti_import = new QTIImport($import_path);
     if (isset($items[$item_id]['tests'])) {
         $loop_var = $items[$item_id]['tests'];
     } else {
         $loop_var = $items[$item_id]['file'];
     }
     foreach ($loop_var as $array_id => $test_xml_file) {
         //call subrountine to add the questions.
         $qids = addQuestions($test_xml_file, $items[$item_id], $import_path);
         //import test
         $tid = $qti_import->importTest($content_info['title']);
         //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);
         }
         //associate content and test
         $sql = 'INSERT INTO ' . TABLE_PREFIX . 'content_tests_assoc' . '(content_id, test_id) ' . 'VALUES (' . $items[$item_id]['real_content_id'] . ", {$tid})";
         $result = mysql_query($sql, $db);
         //			if (!$msg->containsErrors()) {