예제 #1
0
 function _resolveIntLinks($question_id)
 {
     global $ilDB;
     $resolvedlinks = 0;
     $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s", array('integer'), array($question_id));
     if ($result->numRows()) {
         while ($row = $ilDB->fetchAssoc($result)) {
             $internal_link = $row["internal_link"];
             include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
             $resolved_link = SurveyQuestion::_resolveInternalLink($internal_link);
             if (strcmp($internal_link, $resolved_link) != 0) {
                 // internal link was resolved successfully
                 $affectedRows = $ilDB->manipulateF("UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s", array('text', 'integer', 'integer'), array($resolved_link, time(), $row["material_id"]));
                 $resolvedlinks++;
             }
         }
     }
     if ($resolvedlinks) {
         // there are resolved links -> reenter theses links to the database
         // delete all internal links from the database
         include_once "./Services/Link/classes/class.ilInternalLink.php";
         ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
         $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s", array('integer'), array($question_id));
         if ($result->numRows()) {
             while ($row = $ilDB->fetchAssoc($result)) {
                 if (preg_match("/il_(\\d*?)_(\\w+)_(\\d+)/", $row["internal_link"], $matches)) {
                     ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
                 }
             }
         }
     }
 }