14 "chapter_id",
"course_id",
"lesson_id",
"question_id",
15 "created_by",
'created_user_name',
'linked_lesson_id',
16 'childs_cnt',
'is_childs',
'description',
'description_type',
18 var
$arPicture = Array(
"detail_picture",
"preview_picture",
"file_id");
19 var
$arDate = Array(
"active_from",
"active_to");
26 'PREVIEW_PICTURE',
'PREVIEW_TEXT',
'PREVIEW_TEXT_TYPE',
27 'DETAIL_PICTURE',
'DETAIL_TEXT',
'DETAIL_TEXT_TYPE',
28 'LAUNCH',
'KEYWORDS');
35 if (mb_substr($PACKAGE_DIR, -1, 1) ==
"/")
36 $PACKAGE_DIR = mb_substr($PACKAGE_DIR, 0, -1);
38 $this->package_dir =
$_SERVER[
"DOCUMENT_ROOT"].$PACKAGE_DIR;
41 if (!is_dir($this->package_dir))
43 $this->LAST_ERROR =
GetMessage(
"LEARNING_BAD_PACKAGE").
"<br>";
48 if (!is_file($this->package_dir.
"/imsmanifest.xml"))
50 $this->LAST_ERROR =
GetMessage(
"LEARNING_MANIFEST_NOT_FOUND").
"<br>";
57 $this->LAST_ERROR =
GetMessage(
"LEARNING_BAD_SITE_ID").
"<br>";
64 if (!$this->objXML->Load($this->package_dir.
"/imsmanifest.xml"))
66 $this->LAST_ERROR =
GetMessage(
"LEARNING_MANIFEST_NOT_FOUND").
"<br>";
79 if ($this->LAST_ERROR <>
'')
82 if (!
$title = $this->objXML->SelectNodes(
"/manifest/organizations/organization/item/title"))
84 $this->LAST_ERROR =
GetMessage(
"LEARNING_BAD_NAME");
90 "SITE_ID" => $this->arSITE_ID,
100 $this->LAST_ERROR = $e->GetString();
105 if (!$r->Load($this->package_dir.
"/res1.xml"))
108 if (!
$data = $r->SelectNodes(
"/coursetoc/"))
119 $this->LAST_ERROR = $e->GetString();
123 CheckDirPath(
$_SERVER[
"DOCUMENT_ROOT"].
"/".(COption::GetOptionString(
"main",
"upload_dir",
"upload")).
"/learning/".$this->COURSE_ID);
125 $this->package_dir.
"/resources/res1",
126 $_SERVER[
"DOCUMENT_ROOT"] .
"/" . (COption::GetOptionString(
"main",
"upload_dir",
"upload")) .
"/learning/" . $this->COURSE_ID .
"/res1",
136 if ($this->LAST_ERROR <>
'')
141 if (
$items = $this->objXML->SelectNodes(
"/manifest/organizations/organization/item/"))
143 $arItems =
$items->__toArray();
144 $arItems = $arItems[
"#"][
"item"];
148 foreach ($arItems as
$ar)
150 $type = mb_substr(
$ar[
"@"][
"identifier"], 0, 3);
151 $res_id =
$ar[
"@"][
"identifierref"];
167 if ($PARENT_ID === 0)
170 $linkToParentLessonId = (int) $PARENT_ID;
172 $createUnilesson =
false;
180 $createUnilesson =
true;
188 $createUnilesson =
true;
194 "LESSON_ID" => $linkToParentLessonId
203 "COURSE_ID" => $this->COURSE_ID
219 if (!$r->Load($this->package_dir.
"/".mb_strtolower($RES_ID).
".xml"))
227 (
$data = $r->SelectNodes(
"/questestinterop/item/presentation/"))
229 (
$resp = $r->SelectNodes(
"/questestinterop/item/resprocessing/"))
233 $arData =
$data->__toArray();
234 $arResp =
$resp->__toArray();
236 if (
is_set($arData[
"#"][
"material"][0][
"#"],
"mattext"))
237 $arQ[
"NAME"] = $arData[
"#"][
"material"][0][
"#"][
"mattext"][0][
"#"];
239 if (
is_set($arData[
"#"][
"material"][0][
"#"],
"matimage"))
241 $imageDescription =
'';
242 if (
is_set($arData[
"#"][
"material"][0][
"#"],
'image_description'))
243 $imageDescription = $arData[
"#"][
"material"][0][
"#"][
'image_description'][0][
'#'];
245 $arQ[
"FILE_ID"] = Array(
246 "MODULE_ID" =>
"learning",
247 "name" =>basename($arData[
"#"][
"material"][0][
"#"][
"matimage"][0][
"@"][
"uri"]),
248 "tmp_name" => $this->package_dir.
"/".$arData[
"#"][
"material"][0][
"#"][
"matimage"][0][
"@"][
"uri"],
249 "size" =>@filesize($this->package_dir.
"/".$arData[
"#"][
"material"][0][
"#"][
"matimage"][0][
"@"][
"uri"]),
250 "type" => $arData[
"#"][
"material"][0][
"#"][
"matimage"][0][
"@"][
"imagtype"],
251 'description' => $imageDescription
255 if (
is_set($arData[
"#"][
"response_lid"][0][
"@"],
"rcardinality"))
257 switch ($arData[
"#"][
"response_lid"][0][
"@"][
"rcardinality"])
260 $arQ[
"QUESTION_TYPE"] =
'M';
263 $arQ[
"QUESTION_TYPE"] =
'T';
266 $arQ[
"QUESTION_TYPE"] =
'R';
269 $arQ[
"QUESTION_TYPE"] =
'S';
274 if (
is_set($arResp[
"#"][
"respcondition"][0][
"#"],
"setvar"))
275 $arQ[
"POINT"] = $arResp[
"#"][
"respcondition"][0][
"#"][
"setvar"][0][
'#'];
278 if ($bx = $r->SelectNodes(
"/questestinterop/item/bitrix/"))
292 $arCorrect = Array();
294 is_set($arResp[
"#"][
"respcondition"][0][
"#"],
"conditionvar")
296 is_set($arResp[
"#"][
"respcondition"][0][
"#"][
"conditionvar"][0][
"#"],
"varequal")
300 foreach ($arResp[
"#"][
"respcondition"][0][
"#"][
"conditionvar"][0][
"#"][
"varequal"] as
$ar)
301 $arCorrect[] =
$ar[
"#"];
304 if (
is_set($arData[
"#"][
"response_lid"][0][
"#"],
"render_choice")
306 is_set($arData[
"#"][
"response_lid"][0][
"#"][
"render_choice"][0][
"#"],
"response_label")
310 foreach ($arData[
"#"][
"response_lid"][0][
"#"][
"render_choice"][0][
"#"][
"response_label"] as
$ar)
315 "QUESTION_ID" => $PARENT_ID,
317 "CORRECT" => (in_array(
$ar[
"@"][
"ident"],$arCorrect) ?
"Y":
"N"),
318 "ANSWER" =>
$ar[
"#"][
"material"][0][
"#"][
"mattext"][0][
"#"],
322 $res = ($AswerID > 0);
326 $this->arWarnings[
$TYPE][] = Array(
"TITLE" =>
$TITLE,
"TEXT" =>$e->GetString());
334 $this->arWarnings[
$TYPE][] = Array(
"TITLE" =>
$TITLE,
"TEXT" =>$e->GetString());
349 if (
$data = $r->SelectNodes(
"/content/"))
364 if ($createUnilesson ===
false)
371 $bProhibitPublish =
false;
390 if (isset(
$arFields[
'META_PUBLISH_PROHIBITED']))
392 if (
$arFields[
'META_PUBLISH_PROHIBITED'] ===
'Y')
393 $bProhibitPublish =
true;
395 unset(
$arFields[
'META_PUBLISH_PROHIBITED']);
400 $arFieldsNames = array_keys($arUnilessonFields);
401 foreach ($arFieldsNames as $fieldName)
403 if ( ! in_array(mb_strtoupper($fieldName), $this->arLessonWritableFields) )
404 unset ($arUnilessonFields[$fieldName]);
410 $linkToParentLessonId,
414 if ($bProhibitPublish && (
$ID > 0))
423 $this->arWarnings[
$TYPE][] = Array(
"TITLE" =>
$TITLE,
"TEXT" =>$e->GetString());
432 $upload_dir = COption::GetOptionString(
"main",
"upload_dir",
"upload");
434 $arStopList =
array();
435 foreach(
$arFields[
"#"] as $field => $arValue)
437 if (in_array($field, $arStopList))
440 if (in_array($field, $this->arUnsetFields) && ($itemType !==
'TMK') && ($itemType !==
'QUE'))
442 if ( ! ($itemType ===
'TES' && in_array($field, $this->arPreventUnsetFieldsForTest)) )
446 if (in_array($field, $this->arDraftFields) && ($itemType !==
'TMK'))
448 if (
is_set($arValue[0][
"#"],
"cdata-section"))
450 $arRes[mb_strtoupper($field)] = preg_replace(
451 "~([\"'])(cid:resources/(.+?))(\\1)~is",
452 "\\1/".$upload_dir.
"/learning/".$this->COURSE_ID.
"/\\3\\1",
453 $arValue[0][
"#"][
"cdata-section"][0][
"#"]);
456 elseif (isset($arValue[0][
"#"]))
458 $arRes[mb_strtoupper($field)] = preg_replace(
459 "~([\"'])(cid:resources/(.+?))(\\1)~is",
460 "\\1/".$upload_dir.
"/learning/".$this->COURSE_ID.
"/\\3\\1",
466 if (in_array($field, $this->arDate) && $arValue[0][
"#"] <>
'')
468 $time = date(
"His", $arValue[0][
"#"]);
469 $arRes[mb_strtoupper($field)] = ConvertTimeStamp($arValue[0][
"#"],
$time ==
"000000" ?
"SHORT" :
"FULL");
473 if (in_array($field, $this->arPicture) && intval($arValue[0][
"#"]) > 0)
475 $file = $this->package_dir.
"/dbresources/".$arValue[0][
"#"];
477 if (method_exists(
'CFile',
'GetImageSize'))
479 $aImage = @CFile::GetImageSize($file);
480 if($aImage ===
false)
483 if (function_exists(
"image_type_to_mime_type"))
484 $image_type_to_mime_type = image_type_to_mime_type($aImage[2]);
492 "MODULE_ID" =>
"learning",
493 "name" =>$arValue[0][
"#"],
495 "size" =>@filesize($file),
496 "type" => $image_type_to_mime_type
499 if (isset(
$arFields[
"#"][$field .
'_description'][0][
'#']))
501 $arRes[mb_strtoupper($field)][
'description'] =
$arFields[
"#"][$field .
'_description'][0][
'#'];
502 $arStopList[] = $field .
'_description';
508 $arRes[mb_strtoupper($field)] = $arValue[0][
"#"];
524 $this->package_dir.
"/resources",
525 $_SERVER[
"DOCUMENT_ROOT"] .
"/" . (COption::GetOptionString(
"main",
"upload_dir",
"upload")) .
"/learning/" . $this->COURSE_ID,
535 $ext = mb_strtolower(pathinfo($file, PATHINFO_EXTENSION));
541 $type =
'image/jpeg';
561 $type =
'application/octet-stream';
576 4 =>
"application/x-shockwave-flash",
581 9 =>
"application/octet-stream",
583 11 =>
"application/octet-stream",
584 12 =>
"application/octet-stream",
585 13 =>
"application/x-shockwave-flash",
587 15 =>
"image/vnd.wap.wbmp",
590 if(!empty($aTypes[
$type]))
591 return $aTypes[
$type];
593 return "application/octet-stream";
static CourseGetLinkedLesson($courseId)
_MakeItems($TITLE, $TYPE, $RES_ID, $PARENT_ID)
static ImageTypeToMimeTypeByFileName($file)
CreateContent($arItems=Array(), $PARENT_ID=0)
$arPreventUnsetFieldsForTest
_MakeFields(&$arFields, $itemType=null)
__construct($PACKAGE_DIR, $arSITE_ID)
static ImageTypeToMimeType($type)
static CopyDirFiles($path_from, $path_to, $ReWrite=True, $Recursive=False)
static Add($arFields, $isCourse=false, $parentLessonId=true, $arProperties=array('SORT'=> 500), $isCheckPermissions=true, $checkPermissionsForUserId=-1)
static PublishProhibitionSetTo($in_lessonId, $in_contextCourseLessonId, $in_isProhibited)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if( $site[ 'SERVER_NAME']==='') if($site['SERVER_NAME']==='') $arProperties