<?php
// 20240829
// Usage:
// Moodle → My courses → Course → Topic (#) → Settings → External url
// displays the whole course log (i.e. all sessions)
// Example:// http://127.0.0.1/www/ictnle.com3/xml4teaching/xml_load_file_course_log.php?file=../../sdata_offline/inc_xml_mdl/course_log_NLMKitspc2501.xml
require_once('../xml4teaching/xml4t_config.php');
echo "<html>\n";
include('inc/xml4t_heading.php');
echo "<body>\n";
 
$file = $_GET["file"];
$session_date =  $_GET["session_date"];
//$mdlid = $_GET["mdlid"];

// for xml_load_file_course_log.php ONLY
$sessions_log = file_get_contents($file); 
include('inc/xml4t_preg_replace_path_in_clog.php');
?>

<div id="main" class="main" type="text/css"> 
<div id="topic_area" class="topic_area" type="text/css"> 

<?php
// adapted for Moodle from inc_sbook/sbook_session_from_xml.inc
// xml file needs <root></root>

/***
// CREATE PAGE HEADING FROM XML 
// todo - load from xml
if (preg_match_all("#^<clog_course_details>$(.*?)^<\/clog_course_details>$#sim",$sessions_log,$matches)) {

if ($matches != NULL) { // doesn't seem to work
//echo "no matches <hr />\n";

      foreach ($matches[0] as $clog_course_details) {
$clog_course_details=simplexml_load_string($clog_course_details); 


      } // foreach ($matches[0] as $clog_course_detail)
    } // if ($matches != NULL) 
} // if (preg_match_all("#^<clog_course_details>$(.*?)^
***/

// CREATE MENU FOR SELECTION OF SESSIONS BY DATE

/**/
// PREPARE DISPLAY OF SELECTED SESSION FROM XML 
$session_date_to_display = $_GET["session_date"];

echo "<div id=\"sbook_floating_session_dates\">\n";
echo "<img src=\"".$xml4tpath0."pix/icons8-opened-folder-64.png\" width=\"35em\" border=\"0\" alt=\"floating menu\" /><br /><br />\n";

/***/
// WORDLIST 
// should be from plugins below - todo
//include (''.$xml4tpath.'sbook_plugins/wordlist_generated_from_xml_clog_sbook_for_sbook_session.inc');

// PLUGINS
/***
// worked - doesn't any more?
if (trim($clog_course_details->clog_plugins =="sbook_plugins/payment_history_generated_from_xml_clog_sbook.inc")) {
 include (''.$xml4tpath.'sbook_plugins/payment_history_generated_from_xml_clog_sbook.inc');
}
echo "<br />\n";
***/

include ('sbook_plugins/wordlist_from_xml_course_log.inc'); // todo - relocate at the top

// PLUGINS
/***/
if (trim($clog_course_details->clog_plugins != null)) {
//echo "Plugins: <br />\n";
foreach ($clog_course_details->clog_plugins as $clog_plugins) {
  $clog_plugins = trim($clog_plugins); // mandatory or else include won't find file!!!
$clog_plugins = explode ("\n", $clog_plugins);
//var_dump ($clog_plugins)."<hr />\n";
//include (''.$xml4tpath.'sbook_plugins/wordlist_generated_from_xml_clog_sbook_for_sbook_session.inc');
//include (''.$xml4tpath.'sbook_plugins/payment_history_generated_from_xml_clog_sbook.inc'); todo
foreach ($clog_plugins as $clog_plugin) {
  include ($clog_plugin);
//  echo " &nbsp; ";
} // foreach ($clog_plugins as $clog_plugin)
}
} // if (trim($clog_course_details->clog_plugins != null))
  echo "<br />\n";
/***/

// SESSION DATES
echo "<img src=\"".$xml4tpath0."pix/icons8-schedule-100.png\" width=\"35em\" border=\"0\" alt=\"session dates\" /> Sessions<br />\n";
if (preg_match_all("#^<clog_session>$(.*?)^<\/clog_session>$#sim",$sessions_log,$matches)) {
      foreach ($matches[0] as $clog_xml) {
$clog_xml=simplexml_load_string($clog_xml); // or die("Error: Cannot create object $ xml course details"    );

//include ('xml_load_file_sbook_session_for_mld.php');

////// START LOOP
$session_date = $clog_xml->clog_session_date;
$session_date_to_display = $clog_xml->clog_session_date;
$session_title = $clog_xml->clog_session_title;
$session_support_material = $clog_xml->clog_session_hw;

echo "<div class=\"popuptext\" id=\"myPopup\">";
echo "<div class=\"sbook_tooltip2\">";
//echo "<a class=\"sbook_floating_session_dates\" href=\"xml_load_file_course_log.php?file=".$file."&session_date=".$session_date_to_display."\">".$session_date_to_display."</a> ".$session_title."\n";
echo "<a class=\"sbook_floating_session_dates\" href=\"#".$session_date."\">".$session_date_to_display."</a> ".$session_title."\n";
echo "<div class=\"sbook_tooltip2text\" style=\"background-image: linear-gradient(to bottom right, #cdcdcd, #7b96a2);\">";

// DISPLAY SBOOK LESSONS FROM GIVEN DATE
// not needed after all - see $session_clog_sbook_ref_incl; 
// snippet from xml_load_file_sbook_session.inc
// new inc_sbook_xml directory + reference pattern → WHOLE FILE(s)

if (!empty($clog_xml->clog_sbook_ref_incl)) {
foreach ($clog_xml->clog_sbook_ref_incl as $clog_sbook_ref_incl) {
$list_of_ref = $clog_sbook_ref_incl;
//include("inc_sbook/xml_load_file_ref_sbook.inc");
$xml_reference_pattern = '/([A-C]{1}[0-9]{1}-[0-9]{2}-[0-9]{2}-[0-9]{2})/m'; 
if (preg_match_all($xml_reference_pattern,$list_of_ref,$matches)) {
foreach ($matches[0] as $ref) {
${'xml'.$ref}=simplexml_load_file("inc_sbook_xml/lesson_".$ref.".xml");// or die("Error: Cannot create object $ xml");

$sbook_front_page_image = trim(${'xml'.$ref}->sbook_front_page_image);
if (!empty($sbook_front_page_image)) {
$sbook_front_page_image = ${'xml'.$ref}->sbook_front_page_image;
echo "<img src=\"".$sbook_front_page_image."\" width=\"60em\" border=\"0\" alt=\"sBook lesson\" /> ";
}
$sbook_ref = trim(${'xml'.$ref}->sbook_ref);
if (!empty($sbook_ref)) {
$sbook_ref = ${'xml'.$ref}->sbook_ref;
$sbook_lesson = ${'xml'.$ref}->sbook_lesson;
echo "<strong>".$sbook_ref."</strong><br />";
}
if (${'xml'.$ref}->sbook_topic_unit[0] != null) {
$sbook_topic_unit = ${'xml'.$ref}->sbook_topic_unit;
echo "<strong>".$sbook_lesson."</strong><br />\n";
}
$sbook_lexical_material = trim(${'xml'.$ref}->sbook_lexical_material);
if (!empty($sbook_lexical_material)) {
$sbook_lexical_material = ${'xml'.$ref}->sbook_lexical_material;
echo "<img src=\"".$xml4tpath0."pix/icons8-dictionary-100.png\" width=\"20em\" border=\"0\" alt=\"vocab pre teach\" /> ". $sbook_lexical_material."<br />";
}
$sbook_functional_language = trim(${'xml'.$ref}->sbook_functional_language);
if (!empty($sbook_functional_language)) {
$sbook_functional_language = ${'xml'.$ref}->sbook_functional_language;
echo "<img src=\"".$xml4tpath0."pix/icons8-hammer-100.png\" width=\"20em\" border=\"0\" alt=\"functional language\"> ". $sbook_functional_language."<br />";
}
$sbook_grammar = trim(${'xml'.$ref}->sbook_grammar);
if (!empty($sbook_grammar)) {
$sbook_grammar = ${'xml'.$ref}->sbook_grammar;
echo "<img src=\"".$xml4tpath0."pix/icons8-automation-100.png\" width=\"35em\" border=\"0\" alt=\"grammar focus\" /> ". $sbook_grammar."<br />";
}

} // end foreach
} // end if preg_match_all

} // end foreach ($clog_xml->clog_sbook_ref_incl
} // end if (!empty($clog_xml->clog_sbook_ref_incl))
// end snippet from xml_load_file_sbook_session.inc


// DISPLAY PDF(S) FROM GIVEN DATE
if (preg_match_all("#pdf\">(.*?).pdf<\/a>#sim",$session_support_material,$session_support_materials_matched)) {
  echo "<br />";
echo "<img src=\"".$xml4tpath0."pix/icons8-magazine-100.png\" width=\"20em\" border=\"0\" alt=\"support material\" /> Support material: <br />\n";
  
foreach ($session_support_materials_matched[0] as $session_support_material) {
  $session_support_material = preg_replace('/pdf">/m','',$session_support_material);
  $session_support_material = preg_replace("/-/m"," ",$session_support_material);
  $session_support_material = preg_replace("/_/m"," ",$session_support_material);
  $session_support_material = preg_replace("/.pdf<\/a>/m","",$session_support_material);
  $session_support_material = preg_replace("/$/m","<br />\n",$session_support_material);

echo $session_support_material."<br />\n";
} // end foreach
} // if (preg_match_all("#pdf\">


// warning - will look only for 1st occurrence of support_material - todo
foreach ($clog_xml->clog_support_material->clog_activity as $clog_activity) {

// DISPLAY GRAMMATICAL MATERIAL FROM GIVEN DATE
if($clog_activity->activity_type == "textbook") {
foreach ($clog_activity->activity_contents as $activity_contents) {
if (preg_match_all("#Grammar: (.*?)^#sim",$activity_contents,$session_grammatical_materials_matched)) {
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-automation-100.png\" width=\"20em\" border=\"0\" alt=\"grammar\" /> Grammar review: <br />\n";
foreach ($session_grammatical_materials_matched[0] as $session_grammatical_material) {
$session_grammatical_material = preg_replace('/Grammar: /m','',$session_grammatical_material);
$session_grammatical_material = preg_replace("/$/m","\n",$session_grammatical_material);
echo $session_grammatical_material."<br />\n";
}}}}
// implemented 
if (($clog_activity->activity_type == "grammar") && (!empty(trim($clog_activity->activity_title))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-automation-100.png\" width=\"20em\" border=\"0\" alt=\"grammar\" /> Grammar presentation: <br />\n";
foreach ($clog_activity->activity_title as $activity_title) {
echo $activity_title."<br />\n";
}}
// implemented 
if ((!empty(trim($clog_activity->grammar))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-automation-100.png\" width=\"20em\" border=\"0\" alt=\"grammar\" /> Grammar review: <br />\n";
foreach ($clog_activity->grammar as $grammar) {
echo $grammar."<br />\n";
}}

// DISPLAY LEXICAL MATERIAL (vocab) FROM GIVEN DATE
if($clog_activity->activity_type == "textbook") {
foreach ($clog_activity->activity_contents as $activity_contents) {
if (preg_match_all("#Lexical material: (.*?)^#sim",$activity_contents,$session_lexical_materials_matched)) {
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-dictionary-100.png\" width=\"20em\" border=\"0\" alt=\"lexical material\" /> Lexical material: <br />\n";
foreach ($session_lexical_materials_matched[0] as $session_lexical_material) {
$session_lexical_material = preg_replace('/Lexical material: /m','',$session_lexical_material);
$session_lexical_material = preg_replace("/$/m","\n",$session_lexical_material);
echo $session_lexical_material."<br />\n";
}}}}
// not implemented (yet?)
if (($clog_activity->activity_type == "vocab") && (!empty(trim($clog_activity->activity_title))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-dictionary-100.png\" width=\"20em\" border=\"0\" alt=\"lexical material\" /> Lexical material: <br />\n";
foreach ($clog_activity->activity_title as $activity_title) {
echo $activity_title."<br />\n";
}}
// implemented 
if ((!empty(trim($clog_activity->vocab))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-dictionary-100.png\" width=\"20em\" border=\"0\" alt=\"lexical material\" /> Lexical material: <br />\n";
foreach ($clog_activity->vocab as $vocab) {
echo $vocab."<br />\n";
}}

// DISPLAY FUNCTIONAL LANGUAGE FROM GIVEN DATE
if($clog_activity->activity_type == "textbook") {
foreach ($clog_activity->activity_contents as $activity_contents) {
if (preg_match_all("#Functional language: (.*?)^#sim",$activity_contents,$session_functional_languages_matched)) {
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-hammer-100.png\" width=\"20em\" border=\"0\" alt=\"functional language\" /> Functional language: <br />\n";
foreach ($session_functional_languages_matched[0] as $session_functional_language) {
$session_functional_language = preg_replace('/Functional language: /m','',$session_functional_language);
$session_functional_language = preg_replace("/$/m","\n",$session_functional_language);
echo $session_functional_language."<br />\n";
}}}}
// not implemented (yet?)
if (($clog_activity->activity_type == "functional_language") && (!empty(trim($clog_activity->activity_title))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-hammer-100.png\" width=\"20em\" border=\"0\" alt=\"functional language\" /> Functional language: <br />\n";
foreach ($clog_activity->activity_title as $activity_title) {
echo $activity_title."<br />\n";
}}
// implemented 
if ((!empty(trim($clog_activity->functional_language))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-hammer-100.png\" width=\"20em\" border=\"0\" alt=\"functional language\" /> Functional language: <br />\n";
foreach ($clog_activity->functional_language as $functional_language) {
echo $functional_language."<br />\n";
}}

// DISPLAY METHODOLOGY FROM GIVEN DATE
if($clog_activity->activity_type == "textbook") {
foreach ($clog_activity->activity_contents as $activity_contents) {
if (preg_match_all("#Methodology: (.*?)^#sim",$activity_contents,$session_methodology_notes_matched)) {
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-graduation-cap-100-unfilled.png\" width=\"20em\" border=\"0\" alt=\"methodology\" /> Methodology: <br />\n";
foreach ($session_methodology_notes_matched[0] as $session_methodology_note) {
$session_methodology_note = preg_replace('/Methodology: /m','',$session_methodology_note);
$session_methodology_note = preg_replace("/$/m","\n",$session_methodology_note);
echo $session_methodology_note."<br />\n";
}}}}
// not implemented (yet?)
if (($clog_activity->activity_type == "methodology") && (!empty(trim($clog_activity->activity_title))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-graduation-cap-100-unfilled.png\" width=\"20em\" border=\"0\" alt=\"methodology\" /> Methodology: <br />\n";
foreach ($clog_activity->activity_title as $activity_title) {
echo $activity_title."<br />\n";
}}
// implemented 
if ((!empty(trim($clog_activity->methodology ))) && ($clog_activity->activity_status !== "wip")){
  echo "<br />";
  echo "<img src=\"".$xml4tpath0."pix/icons8-graduation-cap-100-unfilled.png\" width=\"20em\" border=\"0\" alt=\"methodology\" /> Methodology: <br />\n";
foreach ($clog_activity->methodology as $methodology ) {
echo $methodology ."<br />\n";
}}

} // foreach ($clog_xml->clog_support_material->clog_activity as $clog_activity)


echo "</div><!-- end tooltip2text -->\n";
echo "</div><!-- end tooltip2 -->\n";
echo "</div><!-- close popuptext -->\n";
// end display pdfs

// END LOOP (session dates)
}// end foreach ($matches[0] as $clog_xml) 
} //end if preg_match_all

echo "</div>\n"; // end 2 of \"sbook_floating_session_dates\">\n";
echo "<br />\n";

if (preg_match_all("#^<clog_session>$(.*?)^<\/clog_session>$#sim",$sessions_log,$matches)) {
      foreach ($matches[0] as $clog_xml) {
$clog_xml=simplexml_load_string($clog_xml); // or die("Error: Cannot create object $ xml course details"    );

$session_date = $clog_xml->clog_session_date;
echo "<a id=\"".$session_date."\" name=\"".$session_date."\">&nbsp;</a>\n";

/* copy pasted from inc_sbook/xml_load_file_sbook_session.inc */
if ($clog_xml->clog_session_status == "future") {
  echo "<!-- future lessons are hidden -->\n";
} 
else
  {
if (trim($clog_xml->clog_session_status =='lc')) {
  echo "<h2><strike>".$clog_xml->clog_session_date."</strike> LATE CANCELLATION</h2> ";
$session_date_for_payment_history = $clog_xml->clog_session_date."(late cancellation)";
}
    
if ((trim($clog_xml->clog_session_status !='lc')) && (!empty($clog_xml->clog_session_date_cancelled) && !empty($clog_xml->clog_session_date))) {
  //echo "<div id=\"topic_title\" type=\"text/css\"><img src=\"".$xml4tpath0."pix/icons8-pin-100.png\" width=\"35em\" border=\"0\" alt=\"Session title\" /> ".$clog_xml->clog_session_title."</div>";
  echo "<div id=\"topic_title\" type=\"text/css\"><a href=\"\" class=\"topic_title\"><img src=\"".$xml4tpath0."pix/ictnle_logo.png\" width=\"35em\" border=\"0\" alt=\"Session title\" /> ".$clog_xml->clog_session_title."</a></div>";
  ///
echo "<div id=\"topic_reference\" type=\"text/css\">";
$clog_last_update = $clog_course_details->clog_last_update;
if (trim($clog_last_update) != null) {
  echo "last update: ".$clog_last_update;
}
else {
//echo "today: ".`date +%Y%m%d`;
} 
echo "</div><br />\n";
///
    echo "<h2>".$clog_xml->clog_session_date." (rescheduled ".$clog_xml->clog_session_date_cancelled.")</h2> ";
$session_date_for_attendance_costs = $clog_xml->clog_session_date."(rescheduled)";
}

if ((trim($clog_xml->clog_session_status !='lc')) && (trim(empty($clog_xml->clog_session_date_cancelled))) && (!empty($clog_xml->clog_session_date))) {
  // 20240126
  //echo "<div id=\"topic_title\" type=\"text/css\"><img src=\"".$xml4tpath0."pix/icons8-pin-100.png\" width=\"35em\" border=\"0\" alt=\"Session title\" /> ".$clog_xml->clog_session_title."</div>";
  echo "<div id=\"topic_title\" type=\"text/css\"><img src=\"".$xml4tpath0."pix/ictnle_logo.png\" width=\"35em\" border=\"0\" alt=\"Session title\" /> ".$clog_xml->clog_session_title."</div>";
  ///

echo "<div id=\"topic_reference\" type=\"text/css\">";
$clog_last_update = $clog_course_details->clog_last_update;
if (trim($clog_last_update) != null) {
  echo "last update: ".$clog_last_update;
}
else {
//echo "today: ".`date +%Y%m%d`;
} 
echo "</div><br />\n";

///
  echo "<h2>".$clog_xml->clog_session_date."</h2> ";
$session_date_for_attendance_costs = $clog_xml->clog_session_date;
}

if (!empty($clog_xml->clog_session_credit)) {
    echo " <img src=\"".$xml4tpath0."pix/icons8-hand-receiving-money-100.png\" width=\"20em\" border=\"0\" alt=\"credit\"> ".$clog_xml->clog_session_credit." &nbsp; ";
//$session_credit_for_attendance_costs = $clog_xml->clog_session_credit;
}

echo "&nbsp; <img src=\"".$xml4tpath0."pix/icons8-time-100.png\" width=\"20em\" border=\"0\" alt=\"time\"> ";

if (!empty($clog_xml->clog_session_time)) {
echo " ".$clog_xml->clog_session_time." &nbsp; ";
}

if (!empty($clog_xml->clog_session_ach)) {
echo " ".$clog_xml->clog_session_ach."ach &nbsp; ";
$session_ach_for_attendance_costs = $clog_xml->clog_session_ach;
}

if (!empty($clog_xml->clog_session_balance)) {
    echo " <img src=\"".$xml4tpath0."pix/icons8-coins-100.png\" width=\"20em\" border=\"0\" alt=\"balance\"> ".$clog_xml->clog_session_balance."ach ";
}
include ("".$xml4tpath."sbook_plugins/attendance_costs_generated_from_xml_clog_sbook.inc");

echo "<hr align=\"center\">";
//}
echo "<h3>Prep</h3>\n";
echo "<pre class=\"homework\"><div class=\"clog_hw\">";
    
foreach ($clog_xml->clog_session_hw_activity as $clog_session_hw_activity) {
if (!empty(trim($clog_session_hw_activity->activity->session_date))) {
  //echo "<img src=\"".$xml4tpath0."pix/icons8-construction-worker-100.png\" width=\"35em\" border=\"0\" alt=\"homework\"> <a class=\"../sbook_floating_session_dates\" href=\"pg.php?content=inc_sbook/sbook_session.inc&member=$member&session_date=". trim($clog_session_hw_activity->activity->session_date)."#".trim($clog_session_hw_activity->activity->hw_anchor)."\" target=\"about_blank\"> ".trim($clog_session_hw_activity->activity->activity_title)." (see session ".trim($clog_session_hw_activity->activity->session_date).")</a>\n";
  // opens in a new tab w/o iframe ← todo
  echo "<img src=\"".$xml4tpath0."pix/icons8-construction-worker-100.png\" width=\"35em\" border=\"0\" alt=\"homework\"> <a class=\"../sbook_floating_session_dates\" href=\"#".trim($clog_session_hw_activity->activity->hw_anchor)."\" target=\"about_blank\"> ".trim($clog_session_hw_activity->activity->activity_title)." (see session ".trim($clog_session_hw_activity->activity->session_date).")</a>\n";
  echo trim($clog_session_hw_activity->activity->instructions)." \n";
  echo "<br />";
}
  }

   /// UPDATED PATH FOR MDL - option 2
    $hw = trim($clog_xml->clog_session_hw);
     $string_to_replace = 'src="pix\\/';
     //$string_to_add = 'src="'.$xml4tpath0.'pix/';
     $string_to_add = 'src="'.$xml4tpath.'pix/';
     $hw = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $hw);
echo $hw."\n";

/***
foreach ($clog_xml->clog_session_hw_review->list_of_reviews as $list_of_reviews) {
include (''.$xml4tpath.'sbook_plugins/csv_load_homework.inc');
}
***/
echo "</div></pre>\n";

// e.g. guidelines for srs
if (!empty($clog_xml->clog_incl)) {
include ($clog_xml->clog_incl);
}

// new inc_sbook_xml directory + reference pattern → WHOLE FILE(s)
// EITHER
// <clog_sbook_ref_incl>B1-00-00-09</clog_sbook_ref_incl>
// <clog_sbook_ref_incl>B1-00-00-10</clog_sbook_ref_incl>
// OR
// <clog_sbook_ref_incl>B1-00-00-09 B1-00-00-10</clog_sbook_ref_incl>

/***
if (!empty($clog_xml->clog_sbook_ref_incl)) {
foreach ($clog_xml->clog_sbook_ref_incl as $clog_sbook_ref_incl) {
$list_of_ref = $clog_sbook_ref_incl;
include("inc_sbook/xml_load_file_ref_sbook.inc");
}
}
***/

/***
if ((!empty($clog_xml->clog_sbook_ref_incl->clog_sbook_ref)) && (!empty($clog_xml->clog_sbook_ref_incl->clog_sbook_ref_selection))) {
foreach ($clog_xml->clog_sbook_ref_incl->clog_sbook_ref as $clog_sbook_ref) {
$list_of_ref = $clog_sbook_ref;

//foreach ($list_of_ref->clog_sbook_ref_selection as $clog_sbook_ref_selection) {
foreach ($clog_xml->clog_sbook_ref_incl->clog_sbook_ref_selection as $clog_sbook_ref_selection) {
$list_of_ref_selection = $clog_sbook_ref_selection;
include("inc_sbook/xml_load_file_ref_sbook_selection.inc");
}
}
}
***/

// workaround
/***
if ((!empty($clog_xml->clog_sbook_ref_incl2->clog_sbook_ref)) && (!empty($clog_xml->clog_sbook_ref_incl2->clog_sbook_ref_selection))) {
foreach ($clog_xml->clog_sbook_ref_incl2->clog_sbook_ref as $clog_sbook_ref) {
$list_of_ref = $clog_sbook_ref;

//foreach ($list_of_ref->clog_sbook_ref_selection as $clog_sbook_ref_selection) {
foreach ($clog_xml->clog_sbook_ref_incl2->clog_sbook_ref_selection as $clog_sbook_ref_selection) {
$list_of_ref_selection = $clog_sbook_ref_selection;
include("inc_sbook/xml_load_file_ref_sbook_selection.inc");
}
}
}
***/

// <clog_sbook_incl>10-0-2 10-0-3</clog_sbook_incl> also possible but lexical material from 10-0-2 will be included in 10-0-3
// hence better have 2 separate xml entries
/***
if (!empty($clog_xml->clog_sbook_incl)) {
foreach ($clog_xml->clog_sbook_incl as $clog_sbook_incl) {
$list_of_ref = $clog_sbook_incl;
//include("inc/xml_load_file_ref_sbook.inc");
include("inc_sbook/xml_load_file_ref_sbook.inc"); // 20200220-1206
}
}
***/

// uefa
/***
if (!empty($clog_xml->clog_uefa_ref_incl)) {
foreach ($clog_xml->clog_uefa_ref_incl as $clog_uefa_ref_incl) {
$list_of_ref = $clog_uefa_ref_incl;
include("inc_sbook/xml_load_file_ref_uefa.inc"); // 20210304-1818
}
}
***/

if (($clog_xml->clog_session_status == "tbc") || ($clog_xml->clog_session_status == "lc")) {
//echo "<h3>Lesson plan</h3>\n";
echo "<pre class=\"lesson_plan_tbc\">\n";
}

else {
echo "<h3>Lesson plan</h3>\n";
echo "<pre class=\"lesson_plan\">\n";
}

if (!empty($clog_xml->clog_session_warmer)) {
echo "<u>warmer</u><div class=\"clog_warmer\">";
echo trim($clog_xml->clog_session_warmer);
echo "</div>\n";
}
else {
  echo "<!-- no warmer to display\n -->";
}

/***
$clog_session_flipped_lessons_contents_list_of_ref = trim($clog_xml->clog_session_flipped_lessons_contents->list_of_ref);
if (!empty($clog_session_flipped_lessons_contents_list_of_ref)) {
  echo "<u>flipped lesson contents (review of Efekta course)</u>\n";
  // todo for more than one ref
foreach ($clog_xml->clog_session_flipped_lessons_contents->list_of_ref as $list_of_ref) {
echo $list_of_ref."<br />\n";
include("inc/xml_load_file_ref.inc");
}
}
***/

echo "<!--<u>support materials covered</u>--><div class=\"clog_support_materials_covered\">";

foreach ($clog_xml->clog_support_material as $clog_support_material) {

// 1st loop
if (!empty($clog_support_material->clog_book_title)) {
echo "<img src=\"".$xml4tpath0."pix/icons8-magazine-100.png\" width=\"35em\" border=\"0\" alt=\"file already downloaded\"> ".$clog_support_material->clog_book_title." ".$clog_support_material->clog_book_level."\n";

    if (!empty($clog_support_material->clog_book_unit)) {
    echo $clog_support_material->clog_book_unit."\n\n";
    } // endif not empty clog_book_unit
} // endif not empty clog_book_title

// 2nd loop inside 1st loop! this version doesn't need mdlid
foreach ($clog_support_material->clog_activity as $clog_activity) {

if (($clog_activity->activity_type == "textbook") 
    && ($clog_activity->activity_status != "wip")) {

  include ('inc/xml4t_activity_textbook.php');

  $txt = trim($clog_activity->activity_contents);
  include ('inc/xml4t_txt_preg_replace.php');
  echo $txt."\n"; // new contents with updated string, i.e. icons
//echo "<div contenteditable=\"true\">".$txt."</div>\n";

  include ('inc/xml4t_save_contents_editable.php');
    echo "<br />";
}

// no loop for moodle in this file
  include ('inc/xml4t_activity_types.php');


// ACTIVITY BACKGROUND todo
// is not a plugin
// mostly used in xml_load_file_ref_sbook.inc (but not only! ← update plugins)
if (($clog_activity->activity_type == 'lead_in' 
    && $clog_activity->activity_status == 'active') 
    || ($clog_activity->activity_type == 'lead_in_2roles' // v.seldom used
    && $clog_activity->activity_status == 'active')) {

// create a unique name for css div
// <div class=\"activity_background_$sbook_ref"."_"."$activity_background_trimmed\">
$activity_background = ($clog_activity->activity_background);
//$activity_background = ($activity->activity_background)."_".($activity->activity_id);
$activity_background_trimmed = preg_replace ('/pix02\//m','',$activity_background);
$activity_background_trimmed = preg_replace ('/.jpg/m','',$activity_background_trimmed);
?>

<style type="text/css">
div.activity_background_<?php echo $sbook_ref.'_'.$activity_background_trimmed; ?> {
background: url(<?php echo $activity_background; ?>) no-repeat ;
/*background: linear-gradient(to right, white, transparent 90%); */
/*width: 98%;
height: 35em; */
background-size: cover; /*contain;  */
position: relative; 
/*z-index: 100; */
opacity: 0.9;
filter: alpha(opacity=90);
margin-right : 0%; 
}
@media only print {
div.activity_background_<?php echo $sbook_ref.'_'.$activity_background_trimmed; ?> {
width: 100%;
margin : 0em;
margin-right : -8%; 
/*opacity: 0.2;
filter: alpha(opacity=20); */
}
}
</style>

<?php
//    SBOOK - DEPRECATED?
//    here was sbook_column_role_play_a (...)
}
} //foreach ($clog_support_material->clog_activity as $clog_activity) 
echo "<br />";
} // foreach ($clog_support_material->clog_activity as $clog_activity)
echo "</div>\n";

// include ('sbook_plugins/wordlist_selection_from_xml_course_log.inc'); // only works from selection w/ mdlid ← fix or update later
include ('inc/xml4t_new_expressions.php');
include ('inc/xml4t_deco_favourite_mistakes.php');

echo "</pre>\n";
echo "<div id=\"not_to_print_area03\"><p align=\"center\"><a style=\"not_to_print_area03\" id=\"#top\" href=\"#top\">[top]</a></p></div>\n";

} //end if ($clog_xml->clog_session_status == "future") 


// END LOOP
 //} if trim date_rescheduled
}// end foreach ($matches[0] as $clog_xml) 
} //end if preg_match_all


echo "</body>\n";
echo "</html>\n";
?>
