17 var
$arPicture = Array(
"detail_picture",
"preview_picture",
"file_id");
18 var
$arDate = Array(
"active_from",
"active_to",
"timestamp_x",
"date_create");
19 private $replacingResId;
25 $this->ID = intval($COURSE_ID);
29 if (!$this->arCourse =
$res->Fetch())
31 $this->LAST_ERROR =
GetMessage(
"LEARNING_BAD_COURSE_ID_EX");
42 $this->LAST_ERROR =
GetMessage(
"LEARNING_BAD_SITE_ID_EX");
62 $DB->DateToCharFunction(
"T.TIMESTAMP_X").
" as TIMESTAMP_X ".
63 "FROM b_learn_test T ".
64 "WHERE T.COURSE_ID = ".intval($this->ID).
" ".
72 $this->strItems .=
'<item identifier="TES'.$r.
'" identifierref="RES'.$r.
'"><title>'.
htmlspecialcharsbx(
$arRes[
"NAME"]).
'</title>';
74 $marksRes =
$DB->Query(
75 "SELECT * FROM b_learn_test_mark WHERE TEST_ID = '" . (
string) ((
int)
$arRes[
'ID']) .
"'"
77 while ($arMarksRes= $marksRes->Fetch())
80 $this->arItems[$r] = $this->
CreateTMK($arMarksRes, $r);
81 $this->strItems .=
'<item identifier="TMK'.$r.
'" identifierref="RES'.$r.
'">'
82 .
'<title>' .
htmlspecialcharsbx($arMarksRes[
'MARK'] .
' (' . $arMarksRes[
'DESCRIPTION'] .
')') .
'</title>'
86 $this->strItems .=
'</item>';
87 $this->strResourses .=
'<resource identifier="RES'.$r.
'" type="webcontent" href="res'.$r.
'.xml">'.$this->
_GetResourceFiles($r).
'</resource>';
95 if ($this->LAST_ERROR <>
'')
99 if (mb_substr($PACKAGE_DIR, -1, 1) !=
"/")
108 $this->LAST_ERROR =
GetMessage(
"LEARNING_BAD_PACKAGE");
116 foreach ($this->arItems as $res_id =>
$content)
122 $dbres_path =
$path.
"/dbresources/";
125 foreach ($this->arResources as $res_id =>
$arFiles)
127 $res_path =
$path.
"/resources/res".$res_id.
"/";
132 if (array_key_exists(
"DB", $arFile))
134 $arTempFile = CFile::MakeFileArray($arFile[
"DB"]);
135 if($arTempFile && isset($arTempFile[
"tmp_name"]))
136 @copy($arTempFile[
"tmp_name"], $dbres_path.$arFile[
"ID"]);
140 @copy(
$_SERVER[
"DOCUMENT_ROOT"].$arFile[
"SRC"], $res_path.$arFile[
"ID"]);
154 if ($this->LAST_ERROR <>
'')
157 $this->createQuestionItems($this->arCourse[
"LESSON_ID"]);
159 $strManifest =
"<".
"?xml version=\"1.0\" encoding=\"".$this->charset.
"\"?".
">\n";
160 $strManifest .=
'<manifest xmlns="http://www.imsproject.org/xsd/imscp_rootv1p1p2" identifier="toc1">';
162 $strManifest .=
'<organizations default="man1"><organization identifier="man1" structure="hierarchical">';
163 $strManifest .=
'<item identifier="COR1" identifierref="RES1" parameters=""><title>'.htmlspecialcharsbx($this->arCourse[
"NAME"]).
'</title>';
165 $strManifest .=
'</item>';
166 $strManifest .=
'</organization></organizations>';
168 $strManifest .=
'<resources><resource identifier="RES1" type="webcontent" href="res1.xml">'.$this->_GetResourceFiles(1).
'</resource>';
170 $strManifest .=
'</resources>';
171 $strManifest .=
'</manifest>';
192 if (
$arRes[
'IS_CHILDS'] ==
'1')
198 $arRes[
'META_PUBLISH_PROHIBITED'] =
'Y';
200 $arRes[
'META_PUBLISH_PROHIBITED'] =
'N';
204 $this->strItems .=
'<item identifier="' . $itemType . $r .
'" identifierref="RES'.$r.
'"><title>'.
htmlspecialcharsbx(
$arRes[
"NAME"]).
'</title>';
205 $this->strResourses .=
'<resource identifier="RES'.$r.
'" type="webcontent" href="res'.$r.
'.xml">'.$this->
_GetResourceFiles($r).
'</resource>';
207 $this->createQuestionItems(
$arRes[
"ID"]);
210 if (
$arRes[
'IS_CHILDS'] ==
'1')
213 $this->strItems .=
"</item>";
221 $str =
"<".
"?xml version=\"1.0\" encoding=\"".$this->charset.
"\"?".
">\n";
222 $str .=
"<coursetoc>";
224 foreach ($this->arCourse as
$key =>
$val)
229 if (
$key ===
'site_id')
232 $str .=
"<".$key.
">";
233 if (in_array(
$key, $this->arDraftFields) &&
$val <> '')
235 $str .=
"<![CDATA[".$this->_ReplaceImages(
$val, 1).
"]]>";
243 $src = CFile::GetPath(
$val);
245 $this->arResources[1][] = Array(
"DB" =>
$val,
"SRC"=>$src,
"ID"=>
$val.
".".$ext);
249 if ($arFileData =
$rs->Fetch())
251 $strDelayed =
'<' .
$key .
'_description' .
'>'
253 .
'</' .
$key .
'_description' .
'>';
260 $str .=
"</".$key.
">\n";
264 $str .=
"</coursetoc>";
274 if (
is_set($this->arResources,$res_id))
275 foreach ($this->arResources[$res_id] as $arFile)
277 $str .=
'<file href="dbresources/'.$arFile[
"ID"].
'" />';
279 $str .=
'<file href="resources/res'.$res_id.
'/'.$arFile[
"ID"].
'" />';
286 $str =
"<".
"?xml version=\"1.0\" encoding=\"".$this->charset.
"\"?".
">\n";
287 $str .=
'<content type="'.$TYPE.
'">';
295 if (
$key ===
'site_id')
298 $str .=
"<".$key.
">";
299 if (in_array(
$key, $this->arDraftFields) &&
$val <> '')
301 $str .=
"<![CDATA[".$this->_ReplaceImages(
$val, $res_id).
"]]>";
305 $src = CFile::GetPath(
$val);
307 $this->arResources[$res_id][] = Array(
"DB" =>
$val,
"SRC"=>$src,
"ID"=>
$val.
".".$ext);
311 if ($arFileData =
$rs->Fetch())
313 $strDelayed =
'<' .
$key .
'_description' .
'>'
315 .
'</' .
$key .
'_description' .
'>';
326 $str .=
"</".$key.
">\n";
331 $str .=
"</content>";
339 if($src <>
"" && is_file(
$_SERVER[
"DOCUMENT_ROOT"].$src))
341 $dest = basename($src);
342 $uid = RandString(5);
345 $this->arResources[$this->replacingResId][] =
array(
"SRC"=>$src,
"ID"=>
$uid.
".".
$dest);
346 return stripslashes(
$matches[1].
$matches[2].
"cid:resources/res".$this->replacingResId.
"/".
$uid.
".".
$dest.$matches[4].$matches[5]);
354 $this->replacingResId = $res_id;
355 return preg_replace_callback(
"/(<.+?src\\s*=\\s*)([\"']?)(.*?)(\\2)(.*?>)/is",
array($this,
"_replace_img"),
$text);
358 private function createQuestionItems($lessonId)
362 $strSql =
"SELECT * FROM b_learn_question WHERE LESSON_ID=".$lessonId.
" ORDER BY SORT ASC ";
363 $q =
$DB->Query($strSql);
364 while ($arQRes = $q->Fetch())
367 $this->arItems[$r] = $this->
CreateQTI($arQRes, $r);
368 $this->strItems .=
'<item identifier="QUE'.$r.
'" identifierref="RES'.$r.
'"><title>'.
htmlspecialcharsbx($arQRes[
"NAME"]).
'</title></item>';
369 $this->strResourses .=
'<resource identifier="RES'.$r.
'" type="imsqti_xmlv1p1" href="res'.$r.
'.xml">'.$this->
_GetResourceFiles($r).
'</resource>';
378 if ($this->LAST_ERROR <>
'')
381 $str =
"<".
"?xml version=\"1.0\" encoding=\"".$this->charset.
"\"?".
">\n";
382 $str .=
"<questestinterop>";
384 $str .=
'<item ident="QUE'.$res_id.
'">';
385 $str .=
'<presentation><material><mattext>'.htmlspecialcharsbx(
$arParams[
"NAME"]).
'</mattext>';
389 $arFile = CFile::GetFileArray(
$arParams[
"FILE_ID"]);
393 $this->arResources[$res_id][] = Array(
"DB" => $arFile[
"ID"],
"SRC"=>$arFile[
"SRC"],
"ID"=>
$name);
395 $str .=
'<matimage imagtype="'.$arFile[
"CONTENT_TYPE"].
'" width="'.$arFile[
"WIDTH"].
'" height="'.$arFile[
"HEIGHT"].
'" uri="dbresources/'.
$name.
'"></matimage>';
400 $str .=
"</material>";
416 $str .=
'<response_lid ident="LID'.$res_id.
'" rcardinality="'.$qType.
'"><render_choice>';
419 "SELECT * FROM b_learn_answer WHERE QUESTION_ID = '".intval(
$arParams[
"ID"]).
"' ORDER BY SORT ASC ";
424 while ($arAnwer =
$res->Fetch())
426 if ($arAnwer[
"CORRECT"] ==
"Y")
427 $cond .=
'<varequal respident="LID'.$res_id.
'">ANS'.$arAnwer[
"ID"].
'</varequal>';
428 $str .=
'<response_label ident="ANS'.$arAnwer[
"ID"].
'"><material><mattext>'.
htmlspecialcharsbx($arAnwer[
"ANSWER"]).
'</mattext></material></response_label>';
432 $str .=
"</render_choice></response_lid></presentation>";
434 $str .=
"<resprocessing>";
435 $str .=
"<respcondition><conditionvar>".$cond.
"</conditionvar><setvar>".
$arParams[
"POINT"].
"</setvar></respcondition>";
436 $str .=
"</resprocessing>";
439 $str .=
"<description>";
442 $str .=
"<![CDATA[".$this->_ReplaceImages(
$arParams[
"DESCRIPTION"], $res_id).
"]]>";
444 $str .=
"</description>";
446 $str .=
"<description_type>".$arParams[
"DESCRIPTION_TYPE"].
"</description_type>";
448 $str .=
"<self>".$arParams[
"SELF"].
"</self>";
449 $str .=
"<sort>".$arParams[
"SORT"].
"</sort>";
450 $str .=
"<active>".$arParams[
"ACTIVE"].
"</active>";
453 $str .=
"</item></questestinterop>";
460 $str =
"<".
"?xml version=\"1.0\" encoding=\"".$this->charset.
"\"?".
">\n"
461 .
'<content type="TMK">'
462 .
'<score>' . (int)
$arParams[
'SCORE'] .
'</score>'
static GetSite($COURSE_ID)
_ReplaceImages($text, $res_id)
CreateTMK($arParams, $res_id=1)
_GetResourceFiles($res_id)
_GetCourseContent($parentLessonId, $DEPTH_LEVEL=1)
CreateQTI($arParams, $res_id=1)
_CreateContent($TYPE, $arParams, $res_id)
CreatePackage($PACKAGE_DIR)
static IsPublishProhibited($in_lessonId, $in_contextCourseLessonId)
static GetListOfImmediateChilds($lessonId, $arOrder=array(), $arFilter=array(), $arSelectFields=array(), $arNavParams=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
RewriteFile($abs_path, $strContent)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
GetMessage($name, $aReplace=null)
MakeTimeStamp($datetime, $format=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
if(!empty($sellerData)) $dest