12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750 |
- <?php
- function deleteitem($id)
- {
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
-
- $sql = "SELECT display_order, parent_item_id FROM $tbl_lp_item WHERE id=$id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- if (mysql_num_rows($result) == 0)
- {
- return false;
- }
- $row = mysql_fetch_row($result);
- $display_order = $row[0];
- $parent_item_id = $row[1];
-
- $sql = "DELETE FROM $tbl_learnpath_item WHERE id='$id'";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- if ($result === false)
- {
- return false;
- }
-
- $sql = "UPDATE $tbl_learnpath_item SET display_order = display_order-1 WHERE display_order > $display_order AND parent_item_id = $parent_item_id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $sql = "UPDATE $tbl_learnpath_chapter SET display_order = display_order-1 WHERE display_order > $display_order AND parent_item_id = $parent_item_id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
-
- return true;
- }
- function deletemodule($parent_item_id)
- {
- global $learnpath_id;
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
-
- $sql = "SELECT * FROM $tbl_learnpath_chapter WHERE lp_id=$learnpath_id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- while ($row = mysql_fetch_array($result))
- {
- if ($row['parent_item_id'] == $parent_item_id)
- {
-
- if (deletemodule($row['id']) === false)
- {
- return false;
- }
- }
- }
-
- $sql = "SELECT display_order, parent_item_id FROM $tbl_learnpath_chapter WHERE id=$parent_item_id and lp_id=$learnpath_id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- if (mysql_num_rows($result) == 0)
- {
- return false;
- }
- $row = mysql_fetch_row($result);
- $display_order = $row[0];
- $parent_id = $row[1];
-
- $sql = "DELETE FROM $tbl_learnpath_chapter WHERE (id=$parent_item_id and lp_id=$learnpath_id)";
- $result = api_sql_query($sql, __FILE__, __LINE__);
-
- $sql2 = "DELETE FROM $tbl_learnpath_item WHERE parent_item_id=$parent_item_id";
- $result = api_sql_query($sql2, __FILE__, __LINE__);
-
- $sql = "UPDATE $tbl_learnpath_item SET display_order = display_order-1 WHERE display_order > $display_order AND parent_item_id = $parent_id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $sql = "UPDATE $tbl_learnpath_chapter SET display_order = display_order-1 WHERE display_order > $display_order AND parent_item_id = $parent_id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- return true;
- }
- function deletepath($path_id)
- {
- $tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
- $sql = "DELETE FROM $tbl_learnpath_main WHERE lp_id='$path_id'";
- $result = api_sql_query($sql, __FILE__, __LINE__);
-
-
- $sql = "SELECT * FROM $tbl_learnpath_chapter WHERE lp_id=$path_id";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- while ($row = mysql_fetch_array($result))
- {
- deletemodule($row['id']);
- }
- }
- function moveitem($direction, $id, $moduleid, $type = 'item')
- {
- global $learnpath_id;
- $tbl_learnpath_item = Database::get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database::get_course_table(TABLE_LEARNPATH_CHAPTER);
- $tree = get_learnpath_tree($learnpath_id);
- $orig_order = 0;
- $orig_type = '';
- $orig_id = $id;
- foreach ($tree[$moduleid] as $row)
- {
-
- if (($row['id'] == $id) && ($row['type'] == $type))
- {
- $orig_order = $row['display_order'];
- $orig_type = $row['type'];
- break;
- }
- }
- $dest_order = 0;
- $dest_type = '';
- $dest_id = 0;
- if ($direction == "up")
- {
- if (!empty ($tree[$moduleid][$orig_order -1]))
- {
- $dest_order = $orig_order -1;
- $dest_type = $tree[$moduleid][$orig_order -1]['type'];
- $dest_id = $tree[$moduleid][$orig_order -1]['id'];
- }
- else
- {
- return false;
- }
- }
- else
- {
-
- if (!empty ($tree[$moduleid][$orig_order +1]))
- {
- $dest_order = $orig_order +1;
- $dest_type = $tree[$moduleid][$orig_order +1]['type'];
- $dest_id = $tree[$moduleid][$orig_order +1]['id'];
- }
- else
- {
- return false;
- }
- }
- $sql1 = '';
- $sql2 = '';
- if ($orig_type == 'chapter')
- {
- $sql1 = "UPDATE $tbl_learnpath_chapter SET display_order = ".$dest_order." WHERE (id=$orig_id and parent_item_id=$moduleid)";
- }
- elseif ($orig_type == 'item')
- {
- $sql1 = "UPDATE $tbl_learnpath_item SET display_order = ".$dest_order." WHERE (id=$orig_id and parent_item_id=$moduleid)";
- }
- else
- {
- return false;
- }
- if ($dest_type == 'chapter')
- {
- $sql2 = "UPDATE $tbl_learnpath_chapter SET display_order = ".$orig_order." WHERE (id='$dest_id' and parent_item_id=$moduleid)";
- }
- elseif ($dest_type == 'item')
- {
- $sql2 = "UPDATE $tbl_learnpath_item SET display_order = ".$orig_order." WHERE (id='$dest_id' and parent_item_id=$moduleid)";
- }
- else
- {
- return false;
- }
- api_sql_query($sql1, __FILE__, __LINE__);
- api_sql_query($sql2, __FILE__, __LINE__);
- }
- function movemodule($direction, $id)
- {
- global $learnpath_id;
- $tbl_learnpath_chapter = Database :: get_course_learnpath_chapter_table();
- if ($direction == "up")
- {
- $sortDirection = "DESC";
- }
- else
- {
- $sortDirection = "ASC";
- }
-
- $sql = "SELECT * FROM $tbl_learnpath_chapter where (lp_id=$learnpath_id AND parent_item_id = 0) ORDER BY display_order $sortDirection";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $previousrow = "";
-
-
-
- while ($row = mysql_fetch_array($result))
- {
-
- if (!empty ($this_cat_order))
- {
- $next_cat_order = $row["display_order"];
- $next_cat_id = $row["id"];
- $sql1 = "UPDATE $tbl_learnpath_chapter SET display_order = '$next_cat_order' WHERE (id='$this_cat_id' and lp_id=$learnpath_id)";
- $sql2 = "UPDATE $tbl_learnpath_chapter SET display_order = '$this_cat_order' WHERE (id='$next_cat_id' and lp_id=$learnpath_id)";
- api_sql_query($sql1, __FILE__, __LINE__);
- api_sql_query($sql2, __FILE__, __LINE__);
- unset ($this_cat_order);
- unset ($this_cat_id);
- unset ($next_cat_order);
- unset ($next_cat_id);
- break;
- }
-
- if ($row["id"] == $id)
- {
- $this_cat_order = $row["display_order"];
- $this_cat_id = $id;
- }
- }
- }
- function insert_item($type = 'item', $name, $chapter_description = '', $parent_id = 0, $learnpath_id = 0, $params = null)
- {
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
-
- $sql = "SELECT * FROM $tbl_learnpath_chapter
- WHERE lp_id=$learnpath_id
- AND parent_item_id = $parent_id
- ORDER BY display_order DESC";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $row = mysql_fetch_array($result);
- $last_chapter_order = $row["display_order"];
-
- $sql = "SELECT * FROM $tbl_learnpath_item
- AND parent_item_id = $parent_id
- ORDER BY display_order DESC";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $row = mysql_fetch_array($result);
- $last_item_order = $row["display_order"];
- $new_order = max($last_chapter_order, $last_item_order) + 1;
- if ($type === 'chapter')
- {
- $sql = "INSERT INTO $tbl_learnpath_chapter
- (lp_id, chapter_name, chapter_description, display_order)
- VALUES ('".domesticate($learnpath_id)."',
- '".domesticate(htmlspecialchars($chapter_name))."',
- '".domesticate(htmlspecialchars($chapter_description))."',
- $new_order )";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- if ($result === false)
- {
- return false;
- }
- $id = Database :: get_last_insert_id();
- }
- elseif ($type === 'item')
- {
- $sql = "INSERT INTO $tbl_learnpath_item
- (parent_item_id, item_type, item_id, display_order)
- VALUES ('".domesticate($parent_id)."',
- '".domesticate(htmlspecialchars($item_type))."',
- '".domesticate(htmlspecialchars($item_id))."',
- $new_order )";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- if ($result === false)
- {
- return false;
- }
- $id = Database :: get_last_insert_id();
- }
- return $id;
- }
- function array_learnpath_categories()
- {
-
- global $learnpath_id;
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
- $sql = "SELECT * FROM $tbl_learnpath_chapter WHERE (lp_id=$learnpath_id) ORDER BY display_order ASC";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- while ($row = mysql_fetch_array($result))
- {
- $array_learnpath_categories[] = array ($row["id"], $row["chapter_name"]);
- }
-
- return $array_learnpath_categories;
- }
- function display_learnpath_chapters($parent_item_id = 0, $tree = array (), $level = 0)
- {
-
- global $color2;
- global $xml_output;
- global $learnpath_id;
- $tbl_lp_item = Database::get_course_table('lp_item');
-
-
-
- $lang_move_down = get_lang('_move_down');
- $lang_move_up = get_lang('lang_move_up');
- $lang_edit_learnpath_module = get_lang('lang_edit_learnpath_module');
- $lang_delete_learnpath_module = get_lang('lang_delete_learnpath_module');
- $lang_nochapters = get_lang('lang_nochapters');
- $lang_prerequisites = get_lang('lang_prerequisites');
- $lang_prerequisites_limit = get_lang('lang_prerequisites_limit');
- $lang_add_learnpath_item = get_lang('lang_add_learnpath_item');
- $lang_add_item = get_lang('lang_add_item');
- $lang_title_and_desc = get_lang('lang_title_and_desc');
- $lang_change_order = get_lang('lang_change_order');
- $lang_add_prereqi = get_lang('lang_add_prereqi');
- $lang_add_title_and_desc = get_lang('lang_add_title_and_desc');
- $lang_delete = get_lang('Delete');
- if ($parent_item_id === 0)
- {
-
- $tree = get_learnpath_tree($learnpath_id);
- $num_modules = count($tree);
-
- if ($num_modules == 0)
- {
-
-
- }
- else
- {
- echo " <tr align='center' valign='top'>\n"." <td><b> $lang_title_and_desc </b></td>\n"." <td><b> $lang_add_item </b></td>\n";
- if (is_prereq($learnpath_id))
- {
- echo " <td bgcolor='#ddddee'><b> $lang_prerequisites_limit </b></td>\n";
- }
- else
- echo " <td><b> $lang_prerequisites </b></td>\n";
- echo " <td colspan='2'><b> $lang_change_order </b></td><td><b> $lang_add_prereqi </b></td>\n"." <td><b> $lang_add_title_and_desc </b></td><td><b> $lang_delete </b></td>\n"." </tr>\n";
- }
- }
- $i = 1;
- $counter = 0;
- $num_modules = count($tree[$parent_item_id]);
-
- if (isset ($tree[$parent_item_id]))
- {
- foreach ($tree[$parent_item_id] as $row)
- {
- if ($row['item_type'] === 'dokeos_chapter')
- {
- $xml_output .= "<chapter>";
- $xml_output .= "<chaptertitle>".$row["title"]."</chaptertitle>";
- $xml_output .= "<chapterdescription>".$row["description"]."</chapterdescription>";
- $counter ++;
- if (($counter % 2) == 0)
- {
- $oddclass = "row_odd";
- }
- else
- {
- $oddclass = "row_even";
- }
-
- echo '<tr class="'.$oddclass.'">'."\n".' <td>'.str_repeat(" >", $level)."<img src='../img/documents.gif' alt='folder'/><a href='".api_get_self()."?lp_id=$learnpath_id&parent_item_id=".$row['id']."&action=add_sub_item'><b> ".$row['title']."</b></a>"."<br /><i><div align='justify'> ".str_repeat(" ", $level)."</i></td>\n".' <td align="center"><a href="'.api_get_self()."?lp_id=$learnpath_id&parent_item_id=".$row['id']."&action=add_sub_item\"><img src='../img/0.gif' width='13' height='13' border='0' title='$lang_add_learnpath_item'></a></td>\n"." <td";
- if (is_prereq($learnpath_id))
- {
- echo " bgcolor='#ddddee'";
- }
- echo ">".$row['prerequisite']."</td>\n";
-
- if (is_allowed_to_edit())
- {
- $myaction = 'move_item';
- if ($i < $num_modules)
- {
-
-
- echo " <td align=center>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=".$myaction."&direction=down&moduleid=".$parent_item_id."&id=".$row["id"]."'>"."<img src=\"../img/down.gif\" border=\"0\" title=\"$lang_move_down\">"."</a></td>\n";
- }
- else
- {
- echo ' <td align="center"> </td>'."\n";
- }
- if ($i > 1)
- {
-
- echo ' <td align="center">'."<a href='".api_get_self()."?lp_id=$learnpath_id&action=".$myaction."&direction=up&moduleid=".$parent_item_id."&id=".$row["id"]."'>"."<img src=\"../img/up.gif\" border=\"0\" title=\"$lang_move_up\">"."</a>"."</td>\n";
- }
- else
- {
- echo ' <td align="center"> </td>'."\n";
- }
- echo " <td align='center'> </td>\n";
-
- echo " <td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=edititem&id=".$row["id"]."'>"."<img src=\"../img/edit.gif\" border=\"0\" title=\"$lang_edit_learnpath_module\">"."</a>"."</td>\n";
-
-
- echo " <td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=delete_item&id=".$row["id"]."' onclick=\"return confirmation('".$row['title']."');\">"."<img src=\"../img/delete.gif\" border=\"0\" title=\"$lang_delete_learnpath_module\">"."</a>"."</td>\n";
- }
- echo "</tr>\n";
- $i ++;
- $xml_output .= "<items>";
-
- display_learnpath_chapters($row['id'], $tree, $level +1);
- $xml_output .= "</items>";
- $xml_output .= "</chapter>";
- }
- else
- {
- $row_items = $row;
- echo "<tr>\n <td colspan='2' valign='top'>";
-
- display_addedresource_link_in_learnpath($row_items["item_type"], $row_items["ref"], '', $row_items["id"], 'builder', 'icon', $level);
- if ($row_items["description"])
- {
- echo "<div align='justify'><font color='#999999'> {$row_items['description']}</font>";
- }
- echo "</td>";
- if (is_prereq($learnpath_id))
- {
- echo '<td bgcolor="#EEEEFF">';
- }
- else
- {
- echo "<td>";
- }
- if (is_allowed_to_edit())
- {
- if ($row_items["prerequisite"] <> '')
- {
- $prereq = $row_items["prerequisite"];
-
-
-
- $sql_items2 = "SELECT * FROM $tbl_lp_item WHERE id='$prereq'";
- $result_items2 = api_sql_query($sql_items2, __FILE__, __LINE__);
- $number_items2 = Database::num_rows($result_items2);
- if ($number_items2 == 0)
- {
- echo "<font color='red'>$lang_prereq_deleted_error</font>";
- }
- $row_items2 = mysql_fetch_array($result_items2);
- display_addedresource_link_in_learnpath($row_items2["item_type"], $row_items2["ref"], '', $row_items2["id"], 'builder', '', 0);
- if ((($row_items2["item_type"] == TOOL_QUIZ) or ($row_items2["item_type"] == 'HotPotatoes')) and ($row_items['prerequisite']))
- {
-
- }
-
-
- }
- echo "</font></td>";
- $xml_output .= "<element_type>".$row_items["item_type"]."</element_type>";
- $xml_output .= "<element_id>".$row_items["item_id"]."</element_id>";
-
- if ($i < $num_modules)
- {
- echo "<td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=moveitem&type=item&direction=down&moduleid=".$parent_item_id."&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9>"."<img src=\"../img/down.gif\" border=\"0\" title=\"$lang_move_down\">"."</a>"."</td>";
- }
- else
- {
- echo "<td width='30' align='center'> </td>";
- }
- if ($i > 1)
- {
- echo "<td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=moveitem&type=item&direction=up&moduleid=".$parent_item_id."&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9>"."<img src=\"../img/up.gif\" border=\"0\" title=\"$lang_move_up\">"."</a>";
- }
- else
- {
- echo "<td width='30' align='center'> </td>";
- }
- echo "</td>"."<td align='center'>";
-
- echo "<a href='".api_get_self()."?lp_id=$learnpath_id&action=edititemprereq&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9>"."<img src=\"../img/scormpre.gif\" border=\"0\" title=\"$lang_add_prereq\">"."</a>"."</td>";
-
- echo "<td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=edititem&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9>"."<img src=\"../img/edit.gif\" border=\"0\" title=\"$lang_edit_learnpath_item\">"."</a>"."</td>";
-
- echo "<td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=deleteitem&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9>"."<img src=\"../img/delete.gif\" border=\"0\" title=\"$lang_delete_learnpath_item\" onclick=\"return confirmation('".$row_items["item_type"]."');\">"."</a>";
- }
- $i ++;
- echo "</td></tr>";
- }
- }
- }
- }
- function display_all_learnpath()
- {
- global $tbl_tool, $color2;
- global $xml_output, $lang_edit_learnpath, $lang_delete_learnpath, $lang_publish, $lang_no_publish, $lang_add_learnpath_chapter_to_path;
- $tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
- $sql = "SELECT * FROM $tbl_learnpath_main ORDER BY learnpath_name";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $i = 1;
- $num_modules = mysql_num_rows($result);
- while ($row = mysql_fetch_array($result))
- {
-
- echo "<tr><td bgcolor=\"$color2\" width=400><b> ";
- echo "<a href='learnpath_handler.php?&lp_id={$row['lp_id']}'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9>{$row['learnpath_name']}</a>";
- echo "</b><br><i><div class=text align=justify>{$row['learnpath_description']}</div></i></td>";
-
- if (is_allowed_to_edit())
- {
- echo "<td bgcolor=\"$color2\" align=center><a href='learnpath_handler.php?lp_id={$row['lp_id']}&action=add&type=learnpathcategory'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src='../img/0.gif' width='13' height='13' border='0' title='$lang_add_learnpath_chapter_to_path'></a></td>";
- echo "<td bgcolor=\"$color2\" align=center><a href='".api_get_self()."?action=editpath&id=".$row["lp_id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/edit.gif\" border=\"0\" title=\"$lang_edit_learnpath\"></a></td>";
- echo "<td bgcolor=\"$color2\" align=center><a href='".api_get_self()."?action=deletepath&id=".$row["lp_id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/delete.gif\" border=\"0\" title=\"$lang_delete_learnpath\" onclick=\"return confirmation('".$row2['learnpath_name']."');\"></a></td>";
- $id = $row["lp_id"];
- $sql2 = "SELECT * FROM $tbl_learnpath_main where lp_id=$id";
- $result2 = api_sql_query($sql2, __FILE__, __LINE__);
- $row2 = mysql_fetch_array($result2);
- $name = $row2['learnpath_name'];
- $sql3 = "SELECT * FROM $tbl_tool where (name=\"$name\" and image='scormbuilder.gif')";
- $result3 = api_sql_query($sql3, __FILE__, __LINE__);
- $row3 = mysql_fetch_array($result3);
- if (($row3["visibility"]) == '1')
- {
- echo "<td bgcolor=\"$color2\" align=center><a href='".api_get_self()."?action=publishpath&set=i&id=".$row["lp_id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/visible.gif\" border=\"0\" title=\"$lang_no_publish\"></a></td>";
- }
- else
- {
- echo "<td bgcolor=\"$color2\" align=center><a href='".api_get_self()."?action=publishpath&set=v&id=".$row["lp_id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/invisible.gif\" border=\"0\" title=\"$lang_publish\"></a></td>";
- }
- }
- $i ++;
- echo "<tr><td> </td></tr>";
- }
- }
- function display_learnpath_items($categoryid)
- {
- global $xml_output;
- global $lang_prerequisites, $lang_move_down, $lang_move_up, $lang_edit_learnpath_item, $lang_delete_learnpath_item, $learnpath_id, $lang_add_prereq, $lang_prereq_deleted_error, $lang_pre_short, $langThisItem;
- $tbl_lp_item = Database::get_course_table('lp_item');
- $sql_items = "SELECT * FROM $tbl_lp_item WHERE parent_item_id='$categoryid' ORDER BY display_order ASC";
- $result_items = api_sql_query($sql_items,__FILE__,__LINE__);
- $number_items = Database::num_rows($result_items);
- $i = 1;
- error_log('Selected item under '.$categoryid,0);
- while ($row_items = Database::fetch_array($result_items))
- {
- echo "<tr><td colspan='2' valign='top'>";
- display_addedresource_link_in_learnpath($row_items["item_type"], $row_items["ref"], '', $row_items["id"], 'builder', 'icon');
- if ($row_items["description"])
- {
- echo "<div align='justify'><font color='#999999'> {$row_items['description']}</font>";
- }
- echo "</td>";
- if (is_prereq($learnpath_id))
- {
- echo '<td bgcolor="#EEEEFF">';
- }
- else
- {
- echo "<td>";
- }
- if (is_allowed_to_edit())
- {
- error_log('Is allowed to edit item'.$row_items['id'],0);
-
-
- if ($row_items["prerequisite"] <> '')
- {
- $prereq = $row_items["prerequisite"];
-
-
-
- $sql_items2 = "SELECT * FROM $tbl_lp_item WHERE id='$prereq'";
- $result_items2 = api_sql_query($sql_items2);
- $number_items2 = Database::num_rows($result_items2);
- if ($number_items2 == 0)
- {
- echo "<font color=red>$lang_prereq_deleted_error</font>";
- }
- $row_items2 = Database::fetch_array($result_items2);
- display_addedresource_link_in_learnpath($row_items2["item_type"], $row_items2["ref"], '', $row_items2["id"], 'builder', '');
- if ((($row_items2["item_type"] == 'Exercise') or ($row_items2["item_type"] == 'HotPotatoes')) and ($row_items['prerequisites']))
- {
- echo " ({$row_items2['title']})";
- }
-
-
- }
- echo "</font></td>";
- $xml_output .= "<element_type>".$row_items["item_type"]."</element_type>";
- $xml_output .= "<element_id>".$row_items["id"]."</element_id>";
-
- if ($i < $number_items)
- {
- echo "<td align='center'><a href='".api_get_self()."?lp_id=$learnpath_id&action=moveitem&direction=down&moduleid=".$categoryid."&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/down.gif\" border=\"0\" title=\"$lang_move_down\"></a></td>";
- }
- else
- {
- echo "<td width='30' align='center'> </td>";
- }
- if ($i > 1)
- {
- echo "<td align='center'><a href='".api_get_self()."?lp_id=$learnpath_id&action=moveitem&direction=up&moduleid=".$categoryid."&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/up.gif\" border=\"0\" title=\"$lang_move_up\"></a>";
- }
- else
- {
- echo "<td width='30' align='center'> </td>";
- }
- echo "</td><td align='center'>";
-
- echo "<a href='".api_get_self()."?lp_id=$learnpath_id&action=edititemprereq&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/scormpre.gif\" border=\"0\" title=\"$lang_add_prereq\"></a></td>";
-
- echo "<td align='center'><a href='".api_get_self()."?lp_id=$learnpath_id&action=edititem&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/edit.gif\" border=\"0\" title=\"$lang_edit_learnpath_item\"></a></td>";
-
- echo "<td align='center'>";
- echo "<a href='".api_get_self()."?lp_id=$learnpath_id&action=deleteitem&id=".$row_items["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9><img src=\"../img/delete.gif\" border=\"0\" title=\"$lang_delete_learnpath_item\" onclick=\"return confirmation('".$langThisItem."');\"></a>";
- }
- $i ++;
- echo "</td></tr>";
- }
- }
- function learnpath_items($itemid)
- {
- global $xml_output;
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $sql_items = "SELECT parent_item_id FROM $tbl_lp_item WHERE id='$itemid'";
- $moduleid_sql = api_sql_query($sql_items);
- $moduleid_array = mysql_fetch_array($moduleid_sql);
- $moduleid = $moduleid_array["parent_item_id"];
- $sql_items = "SELECT * FROM $tbl_lp_item WHERE parent_item_id='$moduleid' ORDER BY display_order ASC";
- $result_items = api_sql_query($sql_items);
- $ar = mysql_fetch_array($result_items);
- while ($ar != '')
- {
- $result[] = $ar;
- $ar = mysql_fetch_array($result_items);
- }
- return $result;
- }
- function learnpath_chapters($learnpath_id)
- {
- global $xml_output, $learnpath_id;
-
- $tbl_lp_item = Database::get_course_table('lp_item');
-
- $sql_items = "SELECT * FROM $tbl_lp_item WHERE lp_id='$learnpath_id' AND item_type='dokeos_chapter' ORDER BY display_order ASC";
-
- $result_items = api_sql_query($sql_items, __FILE__, __LINE__);
- $ar = mysql_fetch_array($result_items);
- while ($ar != '')
- {
- $result[] = $ar;
- $ar = mysql_fetch_array($result_items);
- }
- return $result;
- }
- function is_prereq($learnpath_id)
- {
- global $xml_output;
- $tbl_lp_item = Database::get_course_table('lp_item');
-
- $prereq = false;
- $sql_items = "SELECT * FROM $tbl_lp_item WHERE lp_id='$learnpath_id' AND parent_item_id=0 ORDER BY display_order ASC";
- $result_items = api_sql_query($sql_items,__FILE__,__LINE__);
- while ($ar = Database::fetch_array($result_items))
- {
- $c = $ar['id'];
- $sql_items2 = "SELECT * FROM $tbl_lp_item WHERE lp_id = $learnpath_id AND parent_item_id='$c' ORDER BY display_order ASC";
- $result_items2 = api_sql_query($sql_items2,__FILE__,__LINE__);
- while ($ar2 = Database::fetch_array($result_items2))
- {
- if ($ar2['prerequisite'] != '')
- {
- $prereq = true;
- }
- }
- }
- return ($prereq);
- }
- function prereqcheck($id_in_path)
- {
-
- global $learnpath_id, $_user;
- global $langPrereqToEnter, $langPrereqTestLimit1, $langPrereqTestLimit2, $langPrereqTestLimitNow, $langPrereqFirstNeedTo, $langPrereqModuleMinimum1, $langPrereqModuleMinimum2;
- $tbl_learnpath_user = Database :: get_course_table(TABLE_LEARNPATH_USER);
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
-
- $prereq = false;
-
- $sql_items = "SELECT * FROM $tbl_learnpath_item WHERE id='$id_in_path'";
- $result_items = api_sql_query($sql_items);
- $row = mysql_fetch_array($result_items);
-
- if ($row['prereq_type'] == 'i')
- {
-
-
- $id_in_path3 = $row['prereq_id'];
- $prereq_limit = $row['prereq_completion_limit'];
-
- if ($_user['user_id'] == '')
- {
- $user_id = '0';
- }
- else
- {
- $user_id = $_user['user_id'];
- }
- $sql_items3 = "SELECT * FROM $tbl_learnpath_user WHERE (learnpath_item_id='$id_in_path3' and user_id=$user_id)";
- $result_items3 = api_sql_query($sql_items3);
- $row3 = mysql_fetch_array($result_items3);
-
- $stepname = display_addedresource_link_in_learnpath($row['item_type'], $row['ref'], '', $id_in_path, 'builder', 'nolink');
-
- $stepname = trim($stepname);
-
- $sql6 = "SELECT * FROM $tbl_learnpath_item WHERE (id='$id_in_path3')";
- $result6 = api_sql_query($sql6);
- $row6 = mysql_fetch_array($result6);
-
- $prereqname = display_addedresource_link_in_learnpath($row6['item_type'], $row6['ref'], '', $id_in_path3, 'builder', 'nolink');
-
- $limitok = true;
-
- if ($prereq_limit)
- {
-
- if ($row3['score'] < $prereq_limit)
- {
-
- $prereq = $langPrereqToEnter.$stepname.$langPrereqTestLimit1."$prereq_limit".$langPrereqTestLimit2.$prereqname.". (".$langPrereqTestLimitNow.$row3['score'].")";
- }
- else
- {
-
- $prereq = false;
- }
- }
- else
- {
-
- if ($row3['status'] == "completed" or $row3['status'] == 'passed')
- {
-
- $prereq = false;
- }
- else
- {
-
- $prereq = $langPrereqToEnter.$stepname.$langPrereqFirstNeedTo.$prereqname.'.';
- }
- }
- }
- elseif ($row['prereq_type'] == 'c')
- {
-
-
- $id_in_path2 = $row['prereq_id'];
-
- $sql_items3 = "SELECT * FROM $tbl_lp_item WHERE parent_item_id='$id_in_path2'";
- $result_items3 = api_sql_query($sql_items3);
- $allcompleted = true;
- while ($row3 = mysql_fetch_array($result_items3))
- {
-
-
- $id_in_path4 = $row3['id'];
- if ($_user['user_id'] == '')
- {
- $user_id = '0';
- }
- else
- {
- $user_id = $_user['user_id'];
- }
-
- $sql_items4 = "SELECT * FROM $tbl_learnpath_user WHERE (learnpath_item_id='$id_in_path4' and user_id=$user_id)";
- $result_items4 = api_sql_query($sql_items4);
- $row4 = mysql_fetch_array($result_items4);
-
- if ($row4['status'] != "completed" and $row4['status'] != 'passed')
- {
- $allcompleted = false;
- }
- }
- if ($allcompleted)
- {
-
- $prereq = false;
- }
- else
- {
-
- $sql5 = "SELECT * FROM $tbl_learnpath_chapter WHERE (lp_id='$learnpath_id' and id='$id_in_path2')";
- $result5 = api_sql_query($sql5);
- $row5 = mysql_fetch_array($result5);
- $prereqmodulename = trim($row5['chapter_name']);
- $prereq = $langPrereqModuleMinimum1.$prereqmodulename.$langPrereqModuleMinimum2;
- }
- }
- else
- {
-
- $prereq = false;
- }
-
- return ($prereq);
- }
- function get_learnpath_tree($learnpath_id)
- {
-
-
-
-
- $tbl_lp_item = Database::get_course_table('lp_item');
- $tree = array ();
- $chapters = array ();
-
-
-
-
- $all_items_by_chapter = array ();
- $sql = "SELECT * FROM $tbl_lp_item WHERE lp_id = ".$learnpath_id." AND item_type='dokeos_chapter' ORDER BY display_order";
-
- $res = api_sql_query($sql, __FILE__, __LINE__);
-
- while ($row = Database::fetch_array($res))
- {
- $chapters[] = $row;
-
- if (empty ($row['parent_item_id']))
- {
- $row['parent_item_id'] = 0;
- }
-
- $all_items_by_chapter[$row['parent_item_id']][$row['display_order']] = $row;
- $all_items_by_chapter[$row['parent_item_id']][$row['display_order']]['type'] = 'dokeos_chapter';
- }
-
- foreach ($chapters as $row)
- {
-
- $sql = "SELECT * FROM $tbl_lp_item WHERE lp_id = $learnpath_id AND parent_item_id = ".$row['id']." ORDER BY display_order";
-
- $res = api_sql_query($sql, __FILE__, __LINE__);
-
- while ($myrow = mysql_fetch_array($res, MYSQL_ASSOC))
- {
-
-
- $all_items_by_chapter[$row['id']][$myrow['display_order']] = $myrow;
- $all_items_by_chapter[$row['id']][$myrow['display_order']]['type'] = 'item';
- }
- }
-
- foreach ($all_items_by_chapter as $key => $subrow)
- {
- ksort($all_items_by_chapter[$key]);
- }
-
-
- return $all_items_by_chapter;
- }
- function get_ordered_items_list($tree, $chapter = 0, $include_chapters = false)
- {
- $list = array ();
- foreach ($tree[$chapter] as $order => $elem)
- {
- if ($elem['type'] == 'chapter')
- {
- if ($include_chapters === true)
- {
- $list[] = array ('id' => $elem['id'], 'type' => $elem['type']);
- }
- $res = get_ordered_items_list($tree, $elem['id'], $include_chapters);
- foreach ($res as $elem)
- {
- $list[] = $elem;
- }
- }
- elseif ($elem['type'] == 'item')
- {
- $list[] = array ('id' => $elem['id'], 'type' => $elem['type'], 'item_type' => $elem['item_type'], 'parent_item_id' => $elem['parent_item_id'], 'item_id' => $elem['item_id']);
- }
- }
- return $list;
- }
- function display_toc_chapter_contents($tree, $parent_item_id = 0, $learnpath_id, $uid, $wrap, $level = 0)
- {
-
- $tbl_learnpath_user = Database :: get_course_table(TABLE_LEARNPATH_USER);
- $num = 0;
- $num_completed = 0;
- foreach ($tree[$parent_item_id] as $order => $elem)
- {
- $bold = false;
- if (!empty ($_SESSION['cur_open']) && ($elem['id'] == $_SESSION['cur_open']))
- {
- $bold = true;
- }
- if ($elem['type'] === 'chapter')
- {
- if ($wrap)
- {
- echo str_repeat(" ", $level).shorten(strip_tags($elem['chapter_name']), (35 - 3 * $level))."<br />\n";
- }
- else
- {
- echo "<tr><td colspan='3'>".str_repeat(" ", $level).shorten($elem['chapter_name'], (35 - 3 * $level))."</td></tr>\n";
- }
- if ($wrap)
- {
- if ($elem['chapter_description'] != '')
- {
- echo "<div class='description'>".str_repeat(" ", $level)." ".shorten($elem['chapter_description'], (35 - 3 * $level))."</div>\n";
- }
- }
- else
- {
- if ($elem['chapter_description'] != '')
- {
- echo "<tr><td colspan='3'><div class='description'>".str_repeat(" ", $level)." ".shorten($elem['chapter_description'], (35 - 3 * $level))."</div></td></tr>\n";
- }
- }
- list ($a, $b) = display_toc_chapter_contents($tree, $elem['id'], $learnpath_id, $uid, $wrap, $level +1);
- $num += $a;
- $num_completed += $b;
- }
- elseif ($elem['type'] === 'item')
- {
-
- $sql0 = "SELECT * FROM $tbl_learnpath_user WHERE (user_id='".$uid."' and learnpath_item_id='".$elem['id']."' and lp_id='".$learnpath_id."')";
- $result0 = api_sql_query($sql0, __FILE__, __LINE__);
- $row0 = mysql_fetch_array($result0);
- $completed = '';
- if (($row0['status'] == 'completed') or ($row0['status'] == 'passed'))
- {
- $completed = 'completed';
- $num_completed ++;
- }
- if ($wrap)
- {
- echo str_repeat(" ", $level)."<a name='{$elem['id']}' />\n";
- }
- else
- {
- echo "<tr><td>".str_repeat(" ", $level-1)."<a name='{$elem['id']}' />\n";
- }
- if ($wrap)
- {
- $icon = 'wrap';
- }
- if ($bold)
- {
- echo "<b>";
- }
- display_addedresource_link_in_learnpath($elem['item_type'], $elem['ref'], $completed, $elem['id'], 'player', $icon);
- if ($bold)
- {
- echo "</b>";
- }
- if ($wrap)
- {
- echo "<br />\n";
- }
- else
- {
- echo "</td></tr>\n";
- }
- $num ++;
- }
- }
- return array ($num, $num_completed);
- }
- function get_tracking_table($learnpath_id, $user_id, $parent_item_id = 0, $tree = false, $level = 0, $counter = 0)
- {
- $tbl_learnpath_chapter = Database :: get_course_learnpath_chapter_table();
- $tbl_learnpath_item = Database :: get_course_learnpath_item_table();
- $tbl_learnpath_user = Database :: get_course_learnpath_user_table();
-
- $include_chapters = true;
- if (!is_array($tree))
- {
-
- $tree = get_learnpath_tree($learnpath_id);
- }
- foreach ($tree[$parent_item_id] as $order => $elem)
- {
- if (($counter % 2) == 0)
- {
- $oddclass = 'row_odd';
- }
- else
- {
- $oddclass = 'row_even';
- }
- if ($elem['type'] == 'chapter')
- {
- if ($include_chapters === true)
- {
-
- echo "<tr class='$oddclass'><td colspan = '3'>".str_repeat(' ', $level * 2 + 2).$elem['chapter_name']."</td></tr>\n";
- }
- $counter ++;
-
- get_tracking_table($learnpath_id, $user_id, $elem['id'], $tree, $level +1, $counter);
- }
- elseif ($elem['type'] == 'item')
- {
- $sql = "SELECT * FROM $tbl_learnpath_user "."WHERE user_id = $user_id "."AND lp_id = $learnpath_id "."AND learnpath_item_id = ".$elem['id'];
- $res = api_sql_query($sql, __FILE__, __LINE__);
- $myrow = mysql_fetch_array($res);
- if (($myrow['status'] == 'completed') || ($myrow['status'] == 'passed'))
- {
- $color = 'blue';
- $statusmessage = get_lang('Complete');
- }
- else
- {
- $color = 'black';
- $statusmessage = get_lang('Incomplete');
- }
- $link = get_addedresource_link_in_learnpath($elem['item_type'], $elem['id'], $elem['item_id']);
-
-
- echo "<tr class='$oddclass'>"."<td class='mystatus'>".str_repeat(" ", $level * 2 + 2);
-
- display_addedresource_link_in_learnpath($elem['item_type'], $elem['ref'], $myrow['status'], $elem['id'], 'player', 'wrap');
-
- echo "<td>"."<font color='$color'><div class='mystatus'>".$statusmessage."</div></font>"."</td>"."<td>"."<div class='mystatus' align='center'>". ($myrow['score'] == 0 ? '-' : $myrow['score'])."</div>"."</td>"."</tr>\n";
- $counter ++;
- }
- }
-
- return true;
- }
- function is_empty($id)
- {
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
- $sql = "SELECT * FROM $tbl_learnpath_chapter WHERE lp_id=$id ORDER BY display_order ASC";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $num_modules = mysql_num_rows($result);
- $empty = true;
- if ($num_modules != 0)
- {
- while ($row = mysql_fetch_array($result))
- {
- $num_items = 0;
- $parent_item_id = $row['id'];
- $sql2 = "SELECT * FROM $tbl_learnpath_item WHERE (parent_item_id=$parent_item_id) ORDER BY display_order ASC";
- $result2 = api_sql_query($sql2, __FILE__, __LINE__);
- $num_items = mysql_num_rows($result2);
- if ($num_items > 0)
- {
- $empty = false;
- }
- }
- }
- return ($empty);
- }
- function exporttofile($filename, $LPname, $LPid, $content)
- {
- global $circle1_files;
-
- global $expdir;
- if (!$handle = fopen($expdir.'/'.$filename, 'w'))
- {
- echo "Cannot open file ($filename)";
- }
- if (fwrite($handle, $content) === FALSE)
- {
- echo "Cannot write to file ($filename)";
- exit;
- }
- fclose($handle);
- $circle1_files[0][] = $filename;
- $circle1_files[1][] = $LPname;
- $circle1_files[2][] = $LPid;
- }
- function export_exercise($item_id)
- {
- global $expdir, $_course, $_configuration, $_SESSION, $_SERVER, $language_interface, $langExerciseNotFound, $langQuestion, $langOk;
- $exerciseId = $item_id;
- require_once ('../exercice/exercise.class.php');
- require_once ('../exercice/question.class.php');
- require_once ('../exercice/answer.class.php');
- require_once ('../exercice/exercise.lib.php');
-
- define('UNIQUE_ANSWER', 1);
- define('MULTIPLE_ANSWER', 2);
- define('FILL_IN_BLANKS', 3);
- define('MATCHING', 4);
- define('FREE_ANSWER', 5);
- include_once (api_get_path(LIBRARY_PATH).'/text.lib.php');
- $TBL_EXERCISES = Database :: get_course_table(TABLE_QUIZ_TEST);
-
-
-
- if (isset ($_SESSION['objExercise']))
- {
- api_session_unregister('objExercise');
- unset ($objExercise);
- }
- if (isset ($_SESSION['objQuestion']))
- {
- api_session_unregister('objQuestion');
- unset ($objQuestion);
- }
- if (isset ($_SESSION['objAnswer']))
- {
- api_session_unregister('objAnswer');
- unset ($objAnswer);
- }
- if (isset ($_SESSION['questionList']))
- {
- api_session_unregister('questionList');
- unset ($questionList);
- }
- if (isset ($_SESSION['exerciseResult']))
- {
- api_session_unregister('exerciseResult');
- unset ($exerciseResult);
- }
-
- if (!isset ($_SESSION['objExercise']))
- {
-
- $objExercise = new Exercise();
- $sql = "SELECT title,description,sound,type,random,active FROM $TBL_EXERCISES WHERE id='$exerciseId'";
-
- if (!$objExercise->read($exerciseId) || (!$objExercise->selectStatus() && !$is_allowedToEdit && ($origin != 'learnpath')))
- {
- die($langExerciseNotFound);
- }
-
- api_session_register('objExercise');
- }
- $exerciseTitle = $objExercise->selectTitle();
- $exerciseDescription = $objExercise->selectDescription();
- $exerciseSound = $objExercise->selectSound();
- $randomQuestions = $objExercise->isRandom();
- $exerciseType = $objExercise->selectType();
- if (!isset ($_SESSION['questionList']))
- {
-
- $questionList = $randomQuestions ? $objExercise->selectRandomList() : $objExercise->selectQuestionList();
-
- api_session_register('questionList');
- }
- $nbrQuestions = sizeof($questionList);
-
- if (!$questionNum || $_POST['questionNum'])
- {
-
- if (!$questionNum)
- {
- $questionNum = 1;
- }
- else
- {
- $questionNum ++;
- }
- }
- $exerciseTitle = api_parse_tex($exerciseTitle);
- $test .= "<h3>".$exerciseTitle."</h3>";
- if (!empty ($exerciseSound))
- {
- $test .= "<a href=\"../document/download.php?doc_url=%2Faudio%2F".$exerciseSound."\"&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9 target=\"_blank\"><img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=".get_lang("Sound")."\" /></a>";
- }
- $exerciseDescription = api_parse_tex($exerciseDescription);
-
- $scriptfilename = "Exercice".$item_id.".js";
- $s = "<script type=\"text/javascript\" src='../js/".$scriptfilename."'></script>";
- $test .= $s;
- $content = "function evaluate() {
- alert('Test evaluated.');
- }
- ";
- if (!$handle = fopen($expdir.'/js/'.$scriptfilename, 'w'))
- {
- echo "Cannot open file ($scriptfilename)";
- }
- if (fwrite($handle, $content) === FALSE)
- {
- echo "Cannot write to file ($filename)";
- exit;
- }
- fclose($handle);
-
- $s = "
- <p>$exerciseDescription</p>
- <table width='100%' border='0' cellpadding='1' cellspacing='0'>
- <form method='post' action=''><input type=\"hidden\" name=\"SQMSESSID\" value=\"36812c2dea7d8d6e708d5e6a2f09b0b9\" />
- <input type='hidden' name='formSent' value='1' />
- <input type='hidden' name='exerciseType' value='".$exerciseType."' />
- <input type='hidden' name='questionNum' value='".$questionNum."' />
- <input type='hidden' name='nbrQuestions' value='".$nbrQuestions."' />
- <tr>
- <td>
- <table width='100%' cellpadding='4' cellspacing='2' border='0'>";
- $exerciseType = 1;
- $test .= $s;
- $i = 0;
- foreach ($questionList as $questionId)
- {
- $i ++;
-
- if ($exerciseType == 2)
- {
-
- if ($questionNum != $i)
- {
- continue;
- }
- else
- {
-
- if (isset ($exerciseResult[$questionId]))
- {
-
- $objQuestionTmp = new Question();
-
- $objQuestionTmp->read($questionId);
- $questionName = $objQuestionTmp->selectTitle();
-
- unset ($objQuestionTmp);
- $test .= '<tr><td>'.get_lang("AlreadyAnswered").' "'.$questionName.'"</td></tr>';
- break;
- }
- }
- }
- $s = "<tr bgcolor='#e6e6e6'><td valign='top' colspan='2'>".$langQuestion." ";
- $s .= $i;
- if ($exerciseType == 2)
- $s .= ' / '.$nbrQuestions;
- $s .= '</td></tr>';
- $test .= $s;
-
- $test .= showQuestion($questionId, false, 'export');
- }
- $s = "</table></td></tr><tr><td><br/><input type='button' value='".$langOk."' onClick=\"javascript:evaluate();alert('Evaluated.');\">";
- $s .= "</td></tr></form></table>";
- $s .= "<script type='text/javascript'> loadPage(); </script>";
- $b = 2;
- $test .= $s;
- return ($test);
- }
- function exportitem($id, $item_id, $item_type, $add_scorm_communications = false)
- {
- global $circle1_files, $expdir, $_course, $_SESSION, $GLOBALS;
- global $timeNoSecFormat, $dateFormatLong, $language_interface, $langPubl, $langDone, $langThisCourseDescriptionIsEmpty, $lang_course_description, $lang_introduction_text, $_cid, $langHotPotatoesFinished, $lang_author, $lang_date, $lang_groups, $lang_users, $lang_ass, $lang_dropbox, $test, $langQuestion;
-
- require_once (api_get_path(LIBRARY_PATH)."database.lib.php");
-
- include_once ('exercise.class.php');
- include_once ('question.class.php');
- include_once ('answer.class.php');
- include_once ('exercise.lib.php');
- include_once ('../lang/english/announcements.inc.php');
- include_once ("../lang/".$language_interface."/announcements.inc.php");
- include_once ('../lang/english/course_description.inc.php');
- include_once ("../lang/".$language_interface."/course_description.inc.php");
- include_once ('../lang/english/resourcelinker.inc.php');
- include_once ("../lang/".$language_interface."/resourcelinker.inc.php");
- include_once ('../lang/english/learnpath.inc.php');
- include_once ("../lang/".$language_interface."/learnpath.inc.php");
- include_once ('../lang/english/exercice.inc.php');
- include_once ("../lang/".$language_interface."/exercice.inc.php");
- include_once (api_get_path(LIBRARY_PATH).'text.lib.php');
- include_once ("../resourcelinker/resourcelinker.inc.php");
- include_once (api_get_path(LIBRARY_PATH)."events.lib.inc.php");
- $LPname = display_addedresource_link_in_learnpath($item_type, $item_id, '', $id, 'builder', 'nolink');
- $expcontent = "<!--
- This is an exported file from Dokeos Learning Path belonging to a Scorm compliant content package.
- Do not modify or replace individually.
-
- Export module author : Denes Nagy <darkden@evk.bke.hu>
-
- -->
-
- ";
-
- $scocomfiles = "<script type='text/javascript' src='../js/APIWrapper.js'></script>"."<script type='text/javascript' src='../js/SCOFunctions.js'></script>";
- $expcontent .= '<html><head><link rel="stylesheet" href="../css/default.css" type="text/css" media="screen,projection" />'.$scocomfiles.'</head><body>';
- $donebutton .= "<script type='text/javascript'>
- /* <![CDATA[ */
- loadPage();
- var studentName = '!';
- var lmsStudentName = doLMSGetValue( 'cmi.core.student_name' );
- if ( lmsStudentName != '' )
- {
- studentName = ' ' + lmsStudentName + '!';
- }
- /* ]]> */
- </script>
- <br /><br />
- <form><input type=\"hidden\" name=\"SQMSESSID\" value=\"36812c2dea7d8d6e708d5e6a2f09b0b9\" />
- <table cols='3' width='100%' align='center'>
- <tr>
- <td align='middle'><input type = 'button' value = ' ".$langDone." ' onclick = \"doQuit('completed')\" id='button2' name='button2'></td>
- </tr>
- </table>
- </form>";
-
- switch ($item_type)
- {
-
- case "Agenda" :
-
- $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
- $sql = "SELECT * FROM ".$TABLEAGENDA." where (id=$item_id)";
- $result = api_sql_query($sql, __FILE__, __LINE__);
-
- $expcontent .= "<table id=\"agenda_list\" >";
- $barreMois = "";
-
- while ($myrow = mysql_fetch_array($result))
- {
-
- if ($barreMois != date("m", strtotime($myrow["start_date"])))
- {
-
- $barreMois = date("m", strtotime($myrow["start_date"]));
-
- $expcontent .= "<tr><td id=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".ucfirst(format_locale_date("%B %Y", strtotime($myrow["start_date"])))."</td></tr>";
- }
-
- $db_date = (int) date(d, strtotime($myrow["start_date"]));
- if ($_GET["day"] <> $db_date)
- {
- $expcontent .= "<tr><td class=\"data\" colspan='2'>";
- }
- else
- {
- $expcontent .= "<tr><td class=\"datanow\" colspan='2'>";
- }
-
- $expcontent .= "<a name=\"".(int) date(d, strtotime($myrow["start_date"]))."\"></a>";
-
- $expcontent .= ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))." ";
- $expcontent .= ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_time"])))."";
-
- if ($myrow["duration"] == "")
- {
- $expcontent .= "<br />";
- }
- else
- {
- $expcontent .= " / ".$lang_lasting." ".$myrow["duration"]."<br/>";
- }
-
- $expcontent .= $myrow["title"];
- $expcontent .= "</td></tr>";
-
- $content = $myrow["content"];
-
- $content = make_clickable($content);
- $content = api_parse_tex($content);
-
- $expcontent .= "<tr><td class=\"text\" colspan='2'>";
- $expcontent .= $content;
- $expcontent .= "</td></tr>";
-
-
-
- }
-
- $expcontent .= "<tr></table>";
- break;
-
- case "Ad_Valvas" :
-
- $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
- $sql = "SELECT * FROM $tbl_announcement where id='$item_id'";
- $result = api_sql_query($sql, __FILE__, __LINE__);
-
- $expcontent .= "<table class=\"data_table\">";
-
- while ($myrow = mysql_fetch_array($result))
- {
-
- $content = $myrow[1];
-
-
- $content = make_clickable($content);
- $content = api_parse_tex($content);
-
- $last_post_datetime = $myrow['end_date'];
- list ($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
- list ($year, $month, $day) = explode("-", $last_post_date);
- list ($hour, $min) = explode(":", $last_post_time);
- $announceDate = mktime($hour, $min, 0, $month, $day, $year);
-
- if ($announceDate > $_SESSION['user_last_login_datetime'])
- {
- $colorBecauseNew = " color=\"red\" ";
- }
- else
- {
- $colorBecauseNew = " ";
- }
-
- $expcontent .= "<tr>\n"."<td class=\"cell_header\">\n"."<font ".$colorBecauseNew.">".$langPubl." : ".ucfirst(format_locale_date($dateFormatLong, strtotime($last_post_date)))."</font>\n"."</td>\n"."</tr>\n"."<tr>\n"."<td>\n".$content."</td>\n"."</tr>\n";
- }
-
- $expcontent .= "</table>";
- break;
-
- case "Course_description" :
-
- $tbl_course_description = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
- $result = api_sql_query("SELECT id, title, content FROM ".$tbl_course_description." ORDER BY id", __FILE__, __LINE__);
-
- if (mysql_num_rows($result))
- {
-
- $expcontent .= "<hr noshade=\"noshade\" size=\"1\" />";
-
- while ($row = mysql_fetch_array($result))
- {
-
- $expcontent .= "<h4>".$row['title']."</h4>";
-
- $content = make_clickable(nl2br($row['content']));
- $content = api_parse_tex($content);
-
- $expcontent .= $content;
- }
- }
- else
- {
-
- $expcontent .= "<br /><h4>$langThisCourseDescriptionIsEmpty</h4>";
- }
- break;
-
- case "Document" :
-
- $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
- $sql_query = "SELECT * FROM $tbl_document WHERE id=$item_id";
- $sql_result = api_sql_query($sql_query, __FILE__, __LINE__);
- $myrow = mysql_fetch_array($sql_result);
-
- $orig = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$myrow["path"];
-
- $pathname = explode("/", $myrow["path"]);
- $last = count($pathname) - 1;
- $filename = 'data/'.$filename.$pathname[$last];
- $copyneeded = true;
-
-
- $extension = explode(".", $pathname[$last]);
-
-
-
-
- if (preg_match('/.*(\.htm(l)?)$/i', $pathname[$last]))
- {
-
-
-
-
-
-
-
- $file = file_get_contents($orig);
-
-
- $match = GetSRCTags($orig);
-
- for ($i = 0; $i < count($match); $i ++)
- {
-
- list ($key, $srctag) = each($match);
- $src = $srctag;
-
- if (stristr($src, "http") === false)
- {
-
-
- $src = urldecode($src);
-
- $src = preg_replace('/^\.\//', '', $src);
-
- $src = str_replace('mp3player.swf?son=', '', $src);
-
- $src = str_replace('?0', '', $src);
-
-
-
-
-
- $source = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.dirname($myrow['path']).'/'.$src;
- $dest = $expdir.'/data/'.$src;
-
- rcopy($source, $dest);
- }
- }
-
-
-
- if ($add_scorm_communications === true)
- {
- if ($bodyclose = strpos($file, '</body>'))
- {
- $file = substr_replace($file, $scocomfiles.$donebutton, $bodyclose, 7);
- }
- elseif ($htmlclose = strpos($file, '</html>'))
- {
- $file = substr_replace($file, $scocomfiles.$donebutton, $htmlclose, 7);
- $file .= '</html>';
- }
- else
- {
- $file .= $scocomfiles.$donebutton;
- }
- }
-
-
- $filename = str_replace('.htm', $id.'.htm', $filename);
-
-
- exporttofile($filename, $LPname, $id, $file);
-
- $copyneeded = false;
- }
-
- if ($copyneeded)
- {
- copy($orig, $expdir.'/'.$filename);
- $circle1_files[0][] = $filename;
- $circle1_files[1][] = $LPname;
- $circle1_files[2][] = $id;
- }
-
- return;
-
- case "Introduction_text" :
-
- $TBL_INTRO = Database :: get_course_tool_intro_table();
- $result = api_sql_query("SELECT * FROM ".$TBL_INTRO." WHERE id=1");
- $myrow = mysql_fetch_array($result);
- $intro = $myrow["intro_text"];
-
- $expcontent .= "<br />".$intro;
- break;
-
- case "HotPotatoes" :
-
- $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
- $result = api_sql_query("SELECT * FROM $tbl_document WHERE id=$item_id", __FILE__, __LINE__);
- $myrow = mysql_fetch_array($result);
-
- $testfile = api_get_path(SYS_COURSE_PATH).$_course['path']."/document".urldecode($myrow['path']);
-
- $content = file_get_contents($testfile);
-
- $pathname = explode("/", $myrow["path"]);
- $last = count($pathname) - 1;
- $filename = 'data/'.$filename.$pathname[$last];
-
-
- $match = GetSRCTags($testfile);
-
- foreach ($match as $src)
- {
-
- if (stristr($src, "http") === false)
- {
-
-
- $src = urldecode($src);
- $src = str_replace('./', '', $src);
-
- $src = str_replace('mp3player.swf?son=', '', $src);
-
- $src = str_replace('?0', '', $src);
-
-
-
-
-
- $source = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.dirname($myrow['path']).'/'.$src;
- $dest = $expdir.'/data/'.$src;
-
- rcopy($source, $dest);
- }
- }
-
- $closewindow = "<html><head><link rel='stylesheet' type='text/css' href='../css/default.css'></head><body>"."<br /><div class='message'>$langHotPotatoesFinished</div></body></html>";
-
-
-
- $mit = "function Finish(){";
- $js_content = "var SaveScoreVariable = 0; // This variable is included by Dokeos LP export\n"."function mySaveScore() // This function is included by Dokeos LP export\n"."{\n"." if (SaveScoreVariable==0)\n"." {\n"." SaveScoreVariable = 1;\n".
-
- " exitPageStatus = true;\n"." computeTime();\n"." doLMSSetValue( 'cmi.core.score.raw', Score );\n"." doLMSSetValue( 'cmi.core.lesson_status', 'completed' );\n"." doLMSCommit();\n"." doLMSFinish();\n".
-
-
- " }\n"."}\n"."function Finish(){\n"." mySaveScore();";
- $start = "<script type='text/javascript'> loadPage(); </script>";
-
- $content = str_replace($mit, $js_content, $content);
-
- $content = str_replace("</script>", "</script>".$scocomfiles.$start, $content);
-
-
- $filename = str_replace('.htm', $id.'.htm', $filename);
- exporttofile($filename, $LPname, $id, $content);
- return;
-
- case "Exercise" :
-
- $expcontent .= export_exercise($item_id);
- break;
-
- case "Post" :
-
- $tbl_posts =Database::get_course_table(TABLE_FORUM_POST);
- $tbl_posts_text =Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE);
- $result = api_sql_query("SELECT * FROM $tbl_posts where post_id=$item_id", __FILE__, __LINE__);
- $myrow = mysql_fetch_array($result);
-
- $sql_titel = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
- $result_titel = api_sql_query($sql_titel, __FILE__, __LINE__);
- $myrow_titel = mysql_fetch_array($result_titel);
- $posternom = $myrow['nom'];
- $posterprenom = $myrow['prenom'];
- $posttime = $myrow['post_time'];
- $posttext = $myrow_titel['post_text'];
- $posttitle = $myrow_titel['post_title'];
- $posttext = str_replace('"', "'", $posttext);
-
- $expcontent .= "<table border='0' cellpadding='3' cellspacing='1' width='100%'>
- <tr>
- <td colspan='2' bgcolor='#e6e6e6'><b>$posttitle</b><br />$posttext</td>
- </tr>
- <tr>
- <td colspan='2'></td>
- </tr>
- <tr>
- <td bgcolor='#cccccc' align='left'>$lang_author : $posterprenom $posternom</td>
- <td align='right' bgcolor='#cccccc'>$lang_date : $posttime</td>
- </tr>
- <tr><td colspan='2' height='10'></td></tr>
- </table>";
- break;
-
- case "Forum" :
- case "Thread" :
- case "Dropbox" :
- case "Assignments" :
- case "Groups" :
- case "Users" :
-
- $langItemMissing1 = "There was a ";
- $langItemMissing2 = "page (step) here in the original Dokeos Learning Path.";
- $expcontent .= "<div class='message'>$langItemMissing1 $item_type $langItemMissing2</div>";
- break;
-
- case "Link _self" :
- case "Link _blank" :
-
- $TABLETOOLLINK = Database :: get_course_link_table();
- $result = api_sql_query("SELECT * FROM $TABLETOOLLINK WHERE id=$item_id", __FILE__, __LINE__);
- $myrow = mysql_fetch_array($result);
- $thelink = $myrow["url"];
-
- if ($item_type == "Link _blank")
- {
- $target = "_blank";
- }
-
- $expcontent .= "<a href='$thelink?SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9' target='".$target."'>$LPname</a>";
-
- $item_type = "Link";
-
-
-
- break;
- }
-
-
- if ($item_type != 'Exercise' and ($add_scorm_communications === true))
- {
- $expcontent .= $donebutton;
- }
-
- $expcontent .= "</body></html>";
-
- $filename = $item_type.$id.".htm";
-
- exporttofile('data/'.$filename, $LPname, $id, $expcontent);
- }
- function exportdescription($id, $item_type, $description)
- {
- global $expdir;
- $filename = $item_type.$id.".desc";
- $expcontent = $description;
- exporttofile($expdir.$filename, 'description_of_'.$item_type.$id, 'description_of_item_'.$id, $expcontent);
- }
- function deldir($dir)
- {
- $dh = opendir($dir);
- while ($file = readdir($dh))
- {
- if ($file != "." && $file != "..")
- {
- $fullpath = $dir."/".$file;
- if (!is_dir($fullpath))
- {
- unlink($fullpath);
- }
- else
- {
- deldir($fullpath);
- }
- }
- }
- closedir($dh);
- if (rmdir($dir))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function exportpath($learnpath_id)
- {
-
- global $_course, $circle1_files, $LPnamesafe, $LPname, $expdir;
-
- $tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
-
- $add_scorm_button = true;
-
- include_once (api_get_path(LIBRARY_PATH)."fileUpload.lib.php");
- $sql = "SELECT * FROM $tbl_learnpath_main WHERE (lp_id=$learnpath_id)";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $row = mysql_fetch_array($result);
- $LPname = $row['learnpath_name'];
- $LPnamesafe = replace_dangerous_char($LPname, 'strict');
-
- $expdir = api_get_path('SYS_COURSE_PATH').$_course['path']."/temp/".$LPnamesafe;
- $fromdir = '../scorm/export/';
- deldir($expdir);
- mkdir($expdir);
- mkdir($expdir.'/css');
- mkdir($expdir.'/data');
- mkdir($expdir.'/js');
- mkdir($expdir.'/data/images');
- mkdir($expdir.'/data/audio');
- mkdir($expdir.'/data/videos');
- $circle1 = array (
- 'Chapter', 'Agenda', 'Ad_Valvas', 'Course_description', 'Document', 'Introduction_text', 'Link _self', 'Link _blank', 'Forum', 'Thread', 'Post', 'Exercise', 'HotPotatoes', 'Assignments', 'Dropbox', 'Users', 'Groups');
-
-
- $sql = "SELECT * FROM $tbl_learnpath_chapter
- WHERE (lp_id=$learnpath_id and parent_item_id=0)
- ORDER BY display_order ASC";
-
-
-
- $result = api_sql_query($sql, __FILE__, __LINE__);
-
- while ($row = mysql_fetch_array($result))
- {
-
- $parent_item_id = $row['id'];
-
-
- $sql2b = "SELECT * FROM $tbl_learnpath_item WHERE (parent_item_id=$parent_item_id) ORDER BY display_order ASC";
- $result2b = api_sql_query($sql2b, __FILE__, __LINE__);
- while ($row2 = mysql_fetch_array($result2b))
- {
-
- $tobeexported = false;
- for ($i = 0; $i < count($circle1) && !$tobeexported; $i ++)
- {
-
- if ($circle1[$i] == $row2['item_type'])
- {
- $tobeexported = true;
- }
- }
-
- if ($tobeexported)
- {
- exportitem($row2['id'], $row2['item_id'], $row2['item_type'], $add_scorm_button);
-
- }
- }
- }
-
- $filename = 'default.css';
- copy('../css/'.$filename, $expdir.'/css/'.$filename);
- $filename = 'ims_xml.xsd';
- copy($fromdir.$filename, $expdir.'/'.$filename);
- $filename = 'imscp_v1p1.xsd';
- copy($fromdir.$filename, $expdir.'/'.$filename);
- $filename = 'imsmd_v1p2.xsd';
- copy($fromdir.$filename, $expdir.'/'.$filename);
- $filename = 'APIWrapper.js';
- copy($fromdir.$filename, $expdir.'/js/'.$filename);
- $filename = 'SCOFunctions.js';
- copy($fromdir.$filename, $expdir.'/js/'.$filename);
-
-
-
- createimsmanifest($circle1_files, $learnpath_id);
-
- include_once (api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
-
- $zip_folder = new PclZip(api_get_path('SYS_COURSE_PATH').$_course['path']."/temp/".$LPnamesafe.".zip");
- $zip_folder->create(api_get_path('SYS_COURSE_PATH').$_course['path']."/temp/".$LPnamesafe."/", PCLZIP_OPT_REMOVE_PATH, api_get_path('SYS_COURSE_PATH').$_course['path']."/temp/");
-
-
-
- $zipfoldername = api_get_path('SYS_COURSE_PATH').$_course['path']."/temp/".$LPnamesafe;
- $zipfilename = $zipfoldername.".zip";
- DocumentManager :: file_send_for_download($zipfilename, false, basename($LPnamesafe.".zip"));
-
- include_once (api_get_path(LIBRARY_PATH)."fileManage.lib.php");
-
- my_delete($zipfilename);
- my_delete($zipfoldername);
-
-
- return ($circle1_files);
- }
- function exportSCORM($scormname, $course)
- {
- global $_course;
-
- $tmpname = api_get_path('SYS_COURSE_PATH').$_course['path']."/scorm";
- $zipfoldername = $tmpname.$scormname;
- $zipfilename = $zipfoldername.".zip";
-
- include_once (api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
- $zip_folder = new PclZip($zipfilename);
- $list = 1;
-
- $list = $zip_folder->create($zipfoldername."/", PCLZIP_OPT_REMOVE_PATH, $tmpname);
- if ($list == 0)
- {
-
- }
-
- DocumentManager :: file_send_for_download($zipfilename, false, basename($scormname.".zip"));
-
- include_once (api_get_path(LIBRARY_PATH)."fileManage.lib.php");
- my_delete($zipfilename);
- }
- function xmltagwrite($tagname, $which, $data, $linebreak = "yes")
- {
- switch ($which)
- {
- case "open" :
- $tag = "<".$tagname;
- $i = 0;
- while ($data[0][$i])
- {
- $tag .= " ".$data[0][$i]."=\"".$data[1][$i]."\"";
- $i ++;
- }
- if ($tagname == 'file')
- {
- $closing = '/';
- }
- $tag .= $closing.">";
- if ($linebreak != 'no_linebreak')
- {
- $tag .= "\n";
- }
- break;
- case "close" :
- $tag = "</".$tagname.">";
- if ($linebreak != 'no_linebreak')
- {
- $tag .= "\n";
- }
- break;
- case "full" :
- $tag = "<".$tagname;
- $tag .= ">".$data."</".$tagname.">";
- if ($linebreak != 'no_linebreak')
- {
- $tag .= "\n";
- }
- break;
- }
- return $tag;
- }
- function createimsmanifest($circle1_files, $learnpath_id)
- {
- global $_course, $LPname, $expdir, $LPnamesafe;
-
- $tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
- $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
- $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
- include_once ('../metadata/md_funcs.php');
-
-
-
-
- $mycharset = 'ISO-8859-1';
- $header = '<?xml version="1.0" encoding="'.$mycharset.'"?>'."\n<manifest identifier='".$LPnamesafe."' version='1.1'\n xmlns='http://www.imsproject.org/xsd/imscp_rootv1p1p2'\n xmlns:adlcp='http://www.adlnet.org/xsd/adlcp_rootv1p2'\n xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n xsi:schemaLocation='http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd\n http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd\n http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd'>\n";
- $org .= xmltagwrite('metadata', 'open');
- $org .= " ".xmltagwrite('schema', 'full', 'ADL SCORM');
- $org .= " ".xmltagwrite('schemaversion', 'full', '1.2');
- $org .= xmltagwrite('metadata', 'close');
- $defaultorgname = 'default_org';
- $attributes[0][0] = 'default';
- $attributes[1][0] = $defaultorgname;
- $org .= xmltagwrite('organizations', 'open', $attributes);
- $attributes[0][0] = 'identifier';
- $attributes[1][0] = $defaultorgname;
- $org .= " ".xmltagwrite('organization', 'open', $attributes);
- $org .= " ".xmltagwrite('title', 'full', $LPname);
-
- $i = 0;
- $previous_item_id = '00';
- while ($circle1_files[0][$i])
- {
-
-
- $sql = "SELECT * FROM $tbl_learnpath_item WHERE (id=".$circle1_files[2][$i].")";
- $result = api_sql_query($sql, __FILE__, __LINE__);
- $row = mysql_fetch_array($result);
- $parent_item_id = $row['parent_item_id'];
- if ($parent_item_id != $previous_item_id)
- {
-
- $sql2 = "SELECT * FROM $tbl_learnpath_chapter WHERE (id=".$parent_item_id.")";
- $result2 = api_sql_query($sql2, __FILE__, __LINE__);
- $row2 = mysql_fetch_array($result2);
- $chapter_name = $row2['chapter_name'];
- $attributes = '';
- $attributes[0][] = 'identifier';
- $attributes[1][] = 'chapter_'.$row2['id'];
- $attributes[0][] = 'isvisible';
- $attributes[1][] = '1';
- if ($previous_item_id != '00')
- {
- $org .= " ".xmltagwrite('item', 'close');
- }
- $org .= " ".xmltagwrite('item', 'open', $attributes);
- $org .= " ".xmltagwrite('title', 'full', $chapter_name);
- if ($row2['chapter_description'] != '')
- {
-
- $attributes = '';
- $attributes[0][] = 'identifier';
- $attributes[1][] = 'chapter_'.$row2['id'].'_desc';
- $attributes[0][] = 'isvisible';
- $attributes[1][] = '1';
- $org .= " ".xmltagwrite('item', 'open', $attributes);
- $org .= " ".xmltagwrite('title', 'full', ' '.$row2['chapter_description']);
- $org .= " ".xmltagwrite('item', 'close');
- }
- }
- $previous_item_id = $parent_item_id;
-
- $attributes = '';
- $attributes[0][] = 'identifier';
- $attributes[1][] = 'item_'.$circle1_files[2][$i];
- $attributes[0][] = 'identifierref';
- $attributes[1][] = 'item_ref_'.$circle1_files[2][$i];
- $attributes[0][] = 'isvisible';
- $attributes[1][] = '1';
- $org .= " ".xmltagwrite('item', 'open', $attributes);
- $org .= " ".xmltagwrite('title', 'full', $circle1_files[1][$i]);
- if ($row['prereq_id'] != '')
- {
- $attributes = '';
- $attributes[0][] = 'type';
- $attributes[1][] = 'aicc_script';
- $org .= " ".xmltagwrite('adlcp:prerequisites', 'open', $attributes, "no_linebreak");
- if ($row['prereq_type'] == 'i')
- {
- $org .= 'item_'.$row['prereq_id'];
- }
- if ($row['prereq_type'] == 'c')
- {
- $org .= 'chapter_'.$row['prereq_id'];
- }
- $org .= xmltagwrite('adlcp:prerequisites', 'close', $attributes);
- }
- if ($row['description'] != '')
- {
-
- $attributes = '';
- $attributes[0][] = 'identifier';
- $attributes[1][] = 'item_'.$circle1_files[2][$i].'_desc';
- $attributes[0][] = 'isvisible';
- $attributes[1][] = '1';
- $org .= " ".xmltagwrite('item', 'open', $attributes);
- $org .= " ".xmltagwrite('title', 'full', ' '.$row['description']);
- $org .= " ".xmltagwrite('item', 'close');
- }
- $mds = new mdstore(TRUE);
- if (($mdt = $mds->mds_get($row['item_type'].'.'.$row['item_id'])))
- if (($mdo = strpos($mdt, '<metadata>')) && ($mdc = strpos($mdt, '</metadata>')))
- $org .= " ".substr($mdt, $mdo, $mdc - $mdo +11)."\n";
- $org .= " ".xmltagwrite('item', 'close');
- $i ++;
- }
- if ($circle1_files)
- {
- $org .= " ".xmltagwrite('item', 'close');
- }
- $org .= " ".xmltagwrite('organization', 'close');
- $org .= xmltagwrite('organizations', 'close');
- $org .= xmltagwrite('resources', 'open');
-
- $i = 0;
- while ($circle1_files[0][$i])
- {
- $attributes = '';
- $attributes[0][] = 'identifier';
- $attributes[1][] = 'item_ref_'.$circle1_files[2][$i];
- $attributes[0][] = 'type';
- $attributes[1][] = 'webcontent';
- $attributes[0][] = 'adlcp:scormtype';
- $attributes[1][] = 'sco';
- $attributes[0][] = 'href';
- $attributes[1][] = $circle1_files[0][$i];
- $org .= " ".xmltagwrite('resource', 'open', $attributes);
- $org .= " ".xmltagwrite('metadata', 'open');
- $org .= " ".xmltagwrite('schema', 'full', 'ADL SCORM');
- $org .= " ".xmltagwrite('schemaversion', 'full', '1.2');
- $org .= " ".xmltagwrite('metadata', 'close');
- $attributes = '';
- $attributes[0][] = 'href';
- $attributes[1][] = $circle1_files[0][$i];
- $org .= " ".xmltagwrite('file', 'open', $attributes);
- $org .= " ".xmltagwrite('resource', 'close');
- $i ++;
- }
- $org .= xmltagwrite('resources', 'close');
- $org .= xmltagwrite('manifest', 'close');
- $manifest = $header.$org;
- exporttofile('imsmanifest.xml', 'Manifest file', '0', $manifest);
- }
- function GetSRCTags($fileName)
- {
- if (!($fp = fopen($fileName, "r")))
- {
-
- return false;
- }
-
- $contents = fread($fp, filesize($fileName));
- fclose($fp);
- $matches = array ();
- $srcList = array ();
-
- preg_match_all('/src(\s)*=(\s)*[\'"]([^\'"]*)[\'"]/mi', $contents, $matches);
- foreach ($matches[3] as $match)
- {
- if (!in_array($match, $srcList))
- {
- $srcList[] = $match;
- }
- }
- if (count($srcList) == 0)
- {
- return false;
- }
- return $srcList;
- }
- function CopyNCreate($source, $dest)
- {
- if (strcmp($source, $dest) == 0)
- return false;
- $dir = "";
- $tdest = explode('/', $dest);
- for ($i = 0; $i < sizeof($tdest) - 1; $i ++)
- {
- $dir = $dir.$tdest[$i]."/";
- if (!is_dir($dir))
- if (!mkdir($dir))
- return false;
- }
- if (!copy($source, $dest))
- return false;
- return true;
- }
- function rcopy($source, $dest)
- {
-
- if (!file_exists($source))
- {
-
- return false;
- }
- if (is_dir($source))
- {
-
-
-
- if (strrpos($source, '/') == sizeof($source) - 1)
- {
- $source = substr($source, 0, size_of($source) - 1);
- }
- if (strrpos($dest, '/') == sizeof($dest) - 1)
- {
- $dest = substr($dest, 0, size_of($dest) - 1);
- }
- if (!is_dir($dest))
- {
- $res = @ mkdir($dest);
- if ($res === true)
- {
- return true;
- }
- else
- {
-
- if (rcopy(substr($source, 0, strrpos($source, '/')), substr($dest, 0, strrpos($dest, '/'))))
- {
- return @ mkdir($dest);
- }
- else
- {
- return false;
- }
- }
- }
- return true;
- }
- else
- {
-
-
- if (!@ copy($source, $dest))
- {
-
- $res = rcopy(dirname($source), dirname($dest));
- if ($res === true)
- {
-
- return @ copy($source, $dest);
- }
- else
- {
- return false;
-
- }
- }
- else
- {
-
- return true;
- }
- }
- }
- ?>
|