<?php
// 20240918
$xml4tpath="../xml4teaching/"; 
// sbook_plugins 
$xml4tpath0="../../moodledata/";
// inc_html_mdl inc_xml_mdl films inc_themes mindmaps pix tmp_pdf
$xml4tpathmedia="../../../bups/bup_vet_books_cds_dvds/"; // local hard disk
$xml4tpathmedia2="../../../films/virals_for_elt/"; // local hard disk

echo "<html>\n";
echo "<head>\n";

echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"".$xml4tpath0."inc_themes/default.css\" title=\"default\" />\n";
echo "<script src=\"".$xml4tpath."js/sidenav.js\"></script>\n";
echo "<script src=\"".$xml4tpath."js/toggle_visibility.js\"></script>\n";
/*** Drag and Drop interactive - multiple droppables to one target
https://codepen.io/griffininsight/pen/HDFBa  
order of js files below matters! ***/
echo "<script src=\"".$xml4tpath."js/jquery.min.js\"></script>\n";
echo "<script src=\"".$xml4tpath."js/jquery-ui.min.js\"></script>\n";
echo "<script src=\"".$xml4tpath."js/tpunch.js\"></script>\n";
echo "<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>\n";

echo "</head>\n";
echo "<body>\n";
 
$file = $_GET["file"];
$session_date =  $_GET["session_date"];
//$mdlid = $_GET["mdlid"];

$sessions_log = file_get_contents($file);

/// UPDATED PATH FOR MDL
   // → needn't update file for T / Cl bc are just in-place replacements
    //$string_to_replace = 'src=\\"pix\\/vznaniya_logo_3.png\\"';
    //$string_to_replace = 'pix\\/';
    $string_to_replace = 'src="pix\\/';
    $string_to_add = 'src="'.$xml4tpath0.'pix/';
    $sessions_log = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $sessions_log);

    $string_to_replace = 'src="mindmaps\\/';
    $string_to_add = 'src="'.$xml4tpath0.'mindmaps/';
    $sessions_log = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $sessions_log);
//echo "<pre>".$sessions_log."</pre>\n";
///
?>

<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
echo "<div id=\"sbook_floating_session_datesLLLLLLLLLLLLL\">\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";
***/

// 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\" /> Session dates<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); 

/*
    /// UPDATED PATH FOR MDL
    $string_to_replace = 'pix\\/';
    //$string_to_replace = 'src="pix\\/';
    //$string_to_replace = 'src=\\"pix\\/vznaniya_logo_3.png\\"';
    $string_to_add = 'src="'.$xml4tpath0.'pix/';
    $clog_xml = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $clog_xml);
    ///
*/

// START LOOP
//if (((trim($clog_xml->clog_session_status !='future')) && (trim($clog_xml->clog_session_status !='lc')) && (trim(empty($clog_xml->clog_session_date_cancelled))) && (!empty($clog_xml->clog_session_date))) OR  ((trim($clog_xml->clog_session_status !='future')) && (trim($clog_xml->clog_session_status !='lc')) && (trim(!empty($clog_xml->clog_session_date_cancelled))) && (empty($clog_xml->clog_session_date)) && (!empty($clog_xml->clog_session_date_rescheduled)))) {

$session_date_to_display = $clog_xml->clog_session_date;
//echo "<a class=\"sbook_floating_session_dates\" href=\"xml_load_file_course_log.php?file=".$file."&session_date=".$session_date.">".$session_date_to_display."XXXXXXXXXXXX</a>\n";

$session_title = $clog_xml->clog_session_title;
//$session_clog_sbook_ref_incl = $clog_xml->clog_sbook_ref_incl;
$session_support_material = $clog_xml->clog_session_hw;

//$session_functional_language = $clog_xml->clog_support_material->clog_activity->activity_contents;
/*
$session_lexical_material = $clog_xml->clog_support_material->clog_activity->activity_contents;
$session_grammatical_material = $clog_xml->clog_support_material->clog_activity->activity_contents;
$session_methodology_note = $clog_xml->clog_support_material->clog_activity->activity_contents;
*/

  //var_dump ($session_support_material); 
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.">".$session_date." ".$session_title."YYYYYYYYYY</a>\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)

// todo 20240903
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
 //} if trim date_rescheduled
}// end foreach ($matches[0] as $clog_xml) 
} //end if preg_match_all

// LINK TO COURSE LOG
// snippet from /inc/restricted_area.inc 
/***/

/******** NOT FOR MOODLE *********/
/*
$param2 ="%".$member."%";
$stmt = $db2->prepare("SELECT * FROM members WHERE member LIKE ?") or die ('failed to prepare');
$stmt->execute(array($param2));
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {

      //if ($row['profile'] == 'demo')  // todo
  if ($row['profile'] == 'student') {

    $param1 ="%course admin%";
    $param2 ="%".$member."%";
    $param3 ="%course log%";
    $param4 ="%.xml%"; // filename suffix of new format
    $stmt2 = $db2->prepare("SELECT * FROM cci_cel_courses WHERE category LIKE ? AND member LIKE ? AND file_name LIKE ? AND url LIKE ?") or die ('failed to prepare');
    $stmt2->execute(array($param1, $param2, $param3, $param4));
    while($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
    echo "<img src=\"".$xml4tpath0."pix/sbook_course_log_icon01.png\" width=\"35em\" border=\"0\" alt=\"course log\" /> <a class=\"strong\" href=\"pg.php?content=inc_sbook/sbook_session.inc&show=course_log&member=".$member."\">" . $row2['file_name']. " - </a>\n"; // 20210206-1837
    }

    $param1 ="%course admin%";
    $param2 ="%".$member."%";
    $param3 ="%course log%";
    $param4 ="%.inc%"; // filename suffix of old format
    $stmt2 = $db2->prepare("SELECT * FROM cci_cel_courses WHERE category LIKE ? AND member LIKE ? AND file_name LIKE ? AND url LIKE ?") or die ('failed to prepare');
    $stmt2->execute(array($param1, $param2, $param3, $param4));
    while($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
    echo "<img src=\"".$xml4tpath0."pix/sbook_course_log_icon01.png\" width=\"35em\" border=\"0\" alt=\"course log\" /> <a class=\"strong\" href=\"pg.php?content=inc_sbook/sbook_session.inc&show=course_log&member=".$member."\">" . $row2['file_name']. " - </a>\n"; // 20210206-1837
      //echo "<img src=\"".$xml4tpath0."pix/sbook_course_log_icon01.png\" width=\"35em\" border=\"0\" alt=\"course log\" /> <a class=\"strong\" href=\"pg.php?content=inc_sbook/sbook_session.inc&member=".$member."\">" . $row2['file_name']. " - </a>\n"; // 20210206-1837
      //echo "refers to your previous course<!-- in a deprecated, html format-->. It is available for archiving needs.<br /><br />\n";
      }
  
  } //if ($row['profile'] == 'student') 
else 
      {
        echo "no course logs available";
      }

} // while($row = $stmt->fetch(PDO::FETCH_ASSOC))
// end of snippet
echo "<br />\n";
echo "<br />\n";

*/

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


/**/
// PREPARE DISPLAY OF SELECTED SESSION FROM XML 
// reinitialise AFTER dropdown menu selection
$session_date_to_display = $_GET["session_date"];


// DISPLAY FROM EITHER FLOATING MENU OR RESTRICTED AREA (show)
if ((isset($session_date_to_display)) OR ($_GET["show"] == 'last_session')) { 

// FIND XML SESSION BY DATE
if (preg_match_all("#<clog_session_date>$session_date_to_display<\/clog_session_date>(.*?)^<\/clog_session>#sim",$sessions_log,$matches)) {
      foreach ($matches[0] as $match) {
  // put back <clog_session> missed out during selection
  // needed to generate a valid xml for simple_xml_load_string!
$string = $match;
$pattern = "/<clog_session_date>/";
$replacement = "<clog_session>\n<clog_session_date>";
$match = preg_replace($pattern,$replacement,$string);
//       print_r ($match);
$clog_xml=simplexml_load_string($match); 
  //include ('xml_load_file_course_log.php'); // todo 20240903
// include ('inc_lamp/xml_load_file_sbook_session_for_mld.php');
  //include ('xml_load_file_sbook_session_for_mld.php');
  //include ('inc_sbook/xml_load_file_sbook_session.inc'); // 20221130 
 //include ('inc_sbook/xml_load_file_sbook_session2.inc'); // 20221130 
      }// end foreach ($matches[0] as $clog_xml) 
} // end if preg_match_all
else {
  echo "<!-- There was no session on this date. -->";
}
} // end if (isset($session_date_to_display))

/***/
// option 1
// DISPLAY LATEST LESSON (SESSION) BY DEFAULT
// skip for mdl?
if ((!isset($session_date_to_display)) AND ($_GET["show"] == 'last_session')) { 
$clog_xml=simplexml_load_string($sessions_log); 
$clog_xml = $clog_xml->clog_session;

// bugs if some lessons were rescheduled!
// workaround
// clog_session_date_rescheduled -> clog_session_date
// clog_session_date_cancelled > change in xml_load_file_sbook_session.inc line ~ 22 

$session_date_default = $clog_xml->clog_session_date[1]; // is NOT [0]
/***
// $session_date_default = $clog_xml->clog_session_date[1].$clog_xml->clog_session_date_rescheduled[0]; // is NOT [0]
  
if ((trim($clog_xml->clog_session_status !='future')) && (trim($clog_xml->clog_session_status !='lc')) && (trim(empty($clog_xml->clog_session_date_cancelled))) && (!empty($clog_xml->clog_session_date))) {
$session_date_default = $clog_xml->clog_session_date[1]; // is NOT [0]
}
if ((trim($clog_xml->clog_session_status !='future')) && (trim($clog_xml->clog_session_status !='lc')) && (!empty(trim($clog_xml->clog_session_date_rescheduled)))) {
$session_date_default = $clog_xml->clog_session_date_rescheduled[1]; // is NOT [0]
} 
***/

// include ('inc_sbook/xml_load_file_sbook_session.inc'); mdl todo?

} // if ((!isset($session_date_to_display)) AND ($_GET["show"] == 'last_session')) 
/***/



/***/
// option 2
// DISPLAY ALL SESSIONS BY DEFAULT (w/o filtering by date) - works


// //
/******* not for mdl ? *******/
/***/

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";
***/

// 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 "<p><p><p><p><img src=\"".$xml4tpath0."pix/icons8-schedule-100.png\" width=\"35em\" border=\"0\" alt=\"session dates\" /> Session dates 2<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"    );
// skip inc/xml_load_clog.inc

//include ('xml_load_file_sbook_session_for_mld.php');

////// START LOOP
$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=\"pg.php?content=xml_load_file_course_log.php?file=".$file."&session_date=".$session_date_to_display."\">".$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

// LINK TO COURSE LOG
// was
//$stmt2 = $db2->prepare("SELECT * FROM cci_cel_courses WHERE category LIKE ? AND member LIKE ? AND file_name LIKE ? AND url LIKE ?") or die ('failed to prepare');

echo "<img src=\"".$xml4tpath0."pix/sbook_course_log_icon01.png\" width=\"35em\" border=\"0\" alt=\"course log\" /><a class=\"strong\" href=\"xml_load_file_course_log.php?file=".$file."&session_date=".$session_date.">".$session_date."ZZZZZZZZZZZZZ</a>\n";

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

// 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";


/***/
/******* not for mdl ? *******/

// //

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"    );

/* 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))) {
  // 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_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_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";
  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!
foreach ($clog_support_material->clog_activity as $clog_activity) {

if (($clog_activity->activity_type == "textbook") && ($clog_activity->activity_status != "wip")) {
   /// UPDATED PATH FOR MDL - option 3
// todo for each plugin?...
   /// or else use UPDATED PATH FOR MDL - option 1
// xml_multi_dd_row
}

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

if (!empty($clog_activity->audio_file)
    && $clog_activity->activity_status == 'active') {
$audio_file = trim($clog_activity->audio_file);
///
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->audio_file));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/audio_player.inc");
///
}

if (!empty($clog_activity->pdf_file)
//if (!empty($clog_activity->pdf_file) && (file_exists($pdf_file)) 
    && $clog_activity->activity_status == 'active') {
$pdf_file = trim($clog_activity->pdf_file);
$pdf_file = $xml4tpath0.$pdf_file;
//$pdf_file = $clog_activity->pdf_file;
// todo    
//clearstatcache();
//if (file_exists($pdf_file)) { 
//if (false!==file($pdf_file)){ 
///
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->pdf_file));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/pdf_file.inc");
///
//} // if (false!==file($pdf_file))
}
//} // if (file_exists($pdf_file))

/*
if (!empty($clog_activity->pdf_file2)) {
$pdf_file = trim($clog_activity->pdf_file2);
///
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->pdf_file2));
$activity = $clog_activity;
include("sbook_plugins/pdf_file.inc");
///
}
*/

// THESE DON'T HAVE A PATH TO PIX IN THE ORIGINAL XML FILE
// THEY ARE JUST IN-PLACE REPLACEMENTS like iabbrev
    $txt = trim($clog_activity->activity_contents);

    $string_to_replace = 'T \\/ Cl';
    $string_to_add = '<img src="'.$xml4tpath0.'pix/icons8-collaboration-100.png" width="35em" border="0" alt="speaking" /> ';
    $txt = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $txt);

    $string_to_replace = 'Grammar: ';
    $string_to_add = '<img src="'.$xml4tpath0.'pix/icons8-automation-100.png" width="35em" border="0" alt="grammar focus" /> ';
    $txt = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $txt);

    $string_to_replace = 'Functional language: ';
    $string_to_add = '<img src="'.$xml4tpath0.'pix/icons8-hammer-100.png" width="35em" border="0" alt="functional language" /> ';
    $txt = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $txt);

    $string_to_replace = 'Lexical material: ';
    $string_to_add = '<img src="'.$xml4tpath0.'pix/icons8-dictionary-100.png" width="35em" border="0" alt="lexical material" /> ';
    $txt = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $txt);

    $string_to_replace = 'Methodology: ';
    $string_to_add = '<img src="'.$xml4tpath0.'pix/icons8-graduation-cap-100-unfilled.png" width="35em" border="0" alt="methodology" /> ';
    $txt = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $txt);

    $search = '^(.*).ogg$';
    //$txt = preg_replace ('/'.$search.'/m', '<audio id="audio" controls><source src="../../bups/bup_vet_books_cds_dvds/$1.ogg" type="audio/ogg"></audio>', $txt);
    $txt = preg_replace ('/'.$search.'/m', '<audio id="audio" controls><source src="'.$xml4tpathmedia.'$1.ogg" type="audio/ogg"></audio>', $txt);

    $search = '^(.*).mp3$';
    $txt = preg_replace ('/'.$search.'/m', '<audio id="audio" controls><source src="'.$xml4tpathmedia.'$1.mp3" type="audio/mp3"></audio>', $txt);

    // todo for on-line version
    $search = '^(.*).mp4$';
//if (file_exists("../../bups/bup_vet_books_cds_dvds/".$search)) {
//if (file_exists("../../bups/bup_vet_books_cds_dvds/$1.mp4")) {
    // $txt = preg_replace ('/'.$search.'/m', '<video width="240" height="180" controls><source src="../../bups/bup_vet_books_cds_dvds/$1.mp4" type="video/mp4"></video>', $txt); /*pref */
    $txt = preg_replace ('/'.$search.'/m', '<video width="240" height="180" controls><source src="'.$xml4tpathmedia.'$1.mp4" type="video/mp4"></video>', $txt);
//}


  echo $txt."\n"; // new contents with updated string, i.e. icons
//echo "<div contenteditable=\"true\">".$txt."</div>\n"; // new contents with updated string, i.e. icons

/*** 20221129-2310
// wip
    //include ($xml4tpath."js/saveContentsEditable.js"); // included in inc/heading.inc
    include ("inc_sbook/save_new_contents_from_div2save.php");

//$text = $txt;
echo "<div id=\"div2save\" contenteditable=\"true\" onblur=\"saveContentsEditable()\">".$text.$txt."\n";
    //include ($myFile);
    include ("tmp_files/annotated_clog.xml");
    echo "</div>\n";
// end wip

***/

    echo "<br />";
}

// check if really useful...
if (($clog_activity->activity_type == "textbook") 
    && ($clog_activity->activity_status != "wip")
    && (!empty($clog_activity->activity_contents1)) 
    && (!empty($clog_activity->activity_contents2))) {

    $txt1 = trim($clog_activity->activity_contents1);
echo "<div class=\"flex-container\"><div contenteditable=\"true\" style=\"width: 45%; padding-left: 0.5em; font-size: 85%;\">".$txt1."</div>\n";

    $txt2 = trim($clog_activity->activity_contents2);
echo "<div style=\"width: 3%; padding-left: 0.5em; font-size: 85%;\">&nbsp;</div>\n";
echo "<div contenteditable=\"true\" style=\"width: 45%; padding-left: 0.5em; font-size: 85%;\">".$txt2."</div>\n";
    echo "</div>";
    echo "<br />";
echo "<div style=\"clear: both;\"></div>\n";
}




if ($clog_activity->activity_type == "functional_language" 
    && $clog_activity->activity_status == 'active') {
  echo "<br /><img src=\"".$xml4tpath0."pix/icons8-hammer-100.png\" width=\"35em\" border=\"0\" alt=\"file already downloaded\"> ".trim($clog_activity->activity_title)."\n";
  echo trim($clog_activity->activity_contents)."\n";
}


// edit ← T / Cl interaction pattern 
// → screen sharing
// prep ← indiv / SSS interaction pattern
// → concurrent editing (todo) + save into xml / on-line database (todo)
if ($clog_activity->activity_type == "mingling_patterns"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/mingling_patterns.inc");
}


if ($clog_activity->activity_type == "stopwatch_by_dwyl"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/stopwatch_by_dwyl.inc");
}

if ($clog_activity->activity_type == "audio_player"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/audio_player.inc");
}


// <!-- lead in / semi controlled practice -->
if ($clog_activity->activity_type == "edit_ol_qa"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_ol_qa.inc");
}

// <!-- lead in / semi controlled practice -->
if ($clog_activity->activity_type == "edit_ol_qa_graded"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_ol_qa_graded.inc");
}

if ($clog_activity->activity_type == "edit_match_qa"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_match_qa.inc");
}

if ($clog_activity->activity_type == "edit_reading"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_reading.inc");
}

if ($clog_activity->activity_type == "edit_reading_floating"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_reading_floating.inc");
}

if ($clog_activity->activity_type == "edit_short_reading_floating"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_short_reading_floating.inc");
}

if ($clog_activity->activity_type == "prep_short_reading_floating"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/prep_short_reading_floating.inc");
}


// <!-- controlled practice - match vocab from text w/ definitions -->
if ($clog_activity->activity_type == "edit_text_for_reading_task"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_text_for_reading_task.inc");
}

if ($clog_activity->activity_type == "edit_ol_qa_writing"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_ol_qa_writing.inc");
}

// deprecated - used in nlmkgroup only - need to be retro replaced
if ($clog_activity->activity_type == "shuffled_words_in_sentences"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/shuffled_words_in_sentences.inc");
}


// <!-- freer practice -->
if ($clog_activity->activity_type == "edit_1qa"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_1qa.inc");
}

// <!-- freer practice -->
if ($clog_activity->activity_type == "edit_2columns_2qa"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_2columns_2qa.inc");
}


// <!-- free practice writing h/w -->
if ($clog_activity->activity_type == "prep_ol_qa"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/prep_ol_qa.inc");
}

if ($clog_activity->activity_type == "prep_ol_qa_graded"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/prep_ol_qa_graded.inc");
}

if ($clog_activity->activity_type == "prep_match_qa"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/prep_match_qa.inc");
}


if ($clog_activity->activity_type == "prep_ol_qa_writing"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/prep_ol_qa_writing.inc");
}

// <!-- free practice writing h/w -->
// essays
if ($clog_activity->activity_type == "prep_contents"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/prep_contents.inc");
}

// <!-- freer practice -->
if ($clog_activity->activity_type == "prep_2columns_2qa"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/prep_2columns_2qa.inc");
}

if ($clog_activity->activity_type == "edit_ol_qa_show_hide"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_ol_qa_show_hide.inc");
}

if ($clog_activity->activity_type == "edit_ol_qa_show_hide_row"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/edit_ol_qa_show_hide_row.inc");
}


if ($clog_activity->activity_type == "vocab_focus_3_columns"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->qa->qs[0]));
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/vocab_focus_3_columns.inc");
}


/***
  // was used in course logs xml only
// check if not deprecated - keep as bup 20210416-2009
if ($clog_activity->activity_type == "edit_notes02") {
$edit_notes02_ref = $clog_activity->activity_id;
$contents_edit_notes02_ref = trim($clog_activity->activity_contents);
include("sbook_plugins/edit_notes02.inc");
}

// check if not deprecated - keep as bup 20210416-2009
if ($clog_activity->activity_type == "edit_notes03") {
$edit_notes03_ref = $clog_activity->activity_id;
echo "<img src=\"".$xml4tpath0."pix/icons8-cafe-100.png\" width=\"35em\" border=\"0\" alt=\"speaking\" /> ";
echo $clog_activity->activity_title."<br />";
//echo "<span class=\"sbook_instructions\">".$clog_activity->instructions."</span>";
echo $clog_activity->instructions;
echo "<ol>";
include("sbook_plugins/edit_notes03.inc");
echo "</ol>\n";
}
***/

// decks in clog ↔ decks02 in sbook
if ($clog_activity->activity_type == "decks"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_deck.inc");
//include("sbook_plugins/csv_load_deck02.inc");
}

if ($clog_activity->activity_type == "decks03"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_deck03.inc");
}

if ($clog_activity->activity_type == "shuffled_boxes"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/shuffled_boxes.inc");
}

// 20230205-2231
// works but need to explode space instead of using &nbsp;
// see lesson_C1-00-13-01.xml
if ($clog_activity->activity_type == "shuffled_boxes02"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/shuffled_boxes02.inc");
}


if ($clog_activity->activity_type == "shuffled_boxes03"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/shuffled_boxes03.inc");
}



if ($clog_activity->activity_type == "shuffled_boxes_csv"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/shuffled_boxes_csv.inc");
}

if ($clog_activity->activity_type == "shuffled_letters"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/shuffled_letters.inc");
}

if ($clog_activity->activity_type == "shuffled_words"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/shuffled_words.inc");
}



if ($clog_activity->activity_type == "deck_shuffled_lines"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_deck_shuffled_lines.inc");
}

if ($clog_activity->activity_type == "shuffled_lines"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/shuffled_lines.inc");
}


if ($clog_activity->activity_type == "deck_shuffled_lines_halign"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_deck_shuffled_lines_halign.inc");
}

if ($clog_activity->activity_type == "prep_deck_shuffled_lines_halign"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_prep_deck_shuffled_lines_halign.inc");
}

if ($clog_activity->activity_type == "deck_shuffled_lines_valign"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_deck_shuffled_lines_valign.inc");
}

if ($clog_activity->activity_type == "xml_multi_dd_column" 
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/xml_multi_dd_column.inc");
}

if ($clog_activity->activity_type == "xml_multi_dd_row"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/xml_multi_dd_row.inc");
}

if ($clog_activity->activity_type == "xml_multi_dd_row_n2"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/xml_multi_dd_row_n2.inc");
}


if ($clog_activity->activity_type == "xml_multi_dd_row_n3"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/xml_multi_dd_row_n3.inc");
}

if ($clog_activity->activity_type == "xml_multi_dd_row_n4"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/xml_multi_dd_row_n4.inc");
}


if ($clog_activity->activity_type == "xml_multi_dd_row_n5"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/xml_multi_dd_row_n5.inc");
}


if ($clog_activity->activity_type == "deck_shuffled"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_deck_shuffled.inc");
}

if ($clog_activity->activity_type == "deck_shuffled_monochrome"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_deck_shuffled_monochrome.inc");
}


// wip
if ($clog_activity->activity_type == "move_contents"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',mb_substr($clog_activity->activity_contents, 0, 30)));
// How to get first n characters from a string? ← e.g. 5 characters
// $result = mb_substr($myStr, 0, 5);
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/move_contents.inc");
}

// wip
if ($clog_activity->activity_type == "move_html5_video"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',mb_substr($clog_activity->activity_contents, 0, 30)));
// How to get first n characters from a string? ← e.g. 5 characters
// $result = mb_substr($myStr, 0, 5);
$activity = $clog_activity;
include("".$xml4tpath."sbook_plugins/move_html5_video.inc");
}



// 20230120 from xml_load_file_ref_sbook.inc
// broken
$activity = $clog_activity;
if ($clog_activity->activity_type == "match_2_columns"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/match_2_columns.inc");
}


if ($clog_activity->activity_type == "edit_role_play"
    && $clog_activity->activity_status == 'active') {
$uniq_div_from_activity_title = trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_id)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_title)).trim(preg_replace("/[^\da-z]/i", '',$clog_activity->activity_contents)); // 20210506-2349
$activity = $clog_activity;
$cards_ref = $clog_activity->activity_id; // deprecated?
$list_of_decks = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/edit_role_play.inc");
}


/***/
if ($clog_activity->activity_type == 'role_play' 
    && $clog_activity->activity_status == 'active') {
echo "<div class=\"flex-container\">";
    echo "<div class=\"sbook_left_column\">\n";
        //echo "<div class=\"sbook_role_play_icon\"> <a id=\"".$clog_activity->hw_anchor."\" name=\"".$clog_activity->hw_anchor."\">&nbsp; ".$clog_activity->activity_title."<a/></div>";
        echo "<a id=\"".$clog_activity->hw_anchor."\" name=\"".$clog_activity->hw_anchor."\"><div class=\"sbook_role_play_icon\"></a> &nbsp; ".$clog_activity->activity_title."</div>";
    echo "</div><!-- end sbook_left_column -->\n";

    echo "<div class=\"sbook_middle_right_column\">\n";
    echo "<pre class=\"sbook_lesson_plan\">";
        echo "<span class=\"sbook_exercise_no\">".$clog_activity->activity_id."</span> <span class=\"sbook_instructions\">".$clog_activity->instructions."</span>";
  $instructions_demo = trim($clog_activity->instructions_demo);
  if (!empty($clog_activity->instructions_demo))  {
    echo "<div class=\"sbook_instructions_demo\">".$clog_activity->instructions_demo."</div><br />";
  }
   echo "</pre>";
    echo "</div><!-- end sbook_middle_right_column -->\n";
echo "</div> <!-- end flex-container -->\n";

    echo "<pre class=\"sbook_lesson_plan\">";
echo "<div class=\"sbook_div_role_play\">\n";
echo "<div class=\"flex-container\">\n";

$sbook_role_play_role_b_task = trim ($clog_activity->role_b->task);
if (empty($sbook_role_play_role_b_task))  {
//echo "<strong>Role play</strong>\n";
} else {
echo "<div contenteditable=\"true\" class=\"sbook_column_role_play_a\">\n";
echo "<strong>Role A</strong><br />\n";
}

echo $clog_activity->role_a->task."<br />\n";
echo "<em>".$clog_activity->role_a->ans."</em>\n";

if (empty($sbook_role_play_role_b_task))  {
echo "<!-- no div to close at end of column_role_play_a -->\n";
} 
else {
  echo "</div> <!-- end of column_role_play_a -->\n";
}

if (!empty($clog_activity->role_b->task))  {
//if ($clog_activity->role_b->task != null) {
echo "<div contenteditable=\"true\" class=\"sbook_column_role_play_b\">\n";
echo "<strong>Role B</strong><br />\n";
echo $clog_activity->role_b->task."<br />\n";
echo "<em>".$clog_activity->role_b->ans."</em>\n";
echo "</div> <!-- end of column_role_play_b -->\n";
}

echo "<div class=\"sbook_voc_box_for_role_plays\">\n";
echo "<strong>Practise expressions below <span class=\"smaller_text\">(hover with mouse to show definition)</span>:</strong><br />\n";

//$voc_to_recycle = (${'xml'.$ref}->sbook_expressions);
$voc_to_recycle = $clog_xml->clog_expressions;
$voc_to_recycle = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $voc_to_recycle); // mandatory
$voc_to_recycle = preg_replace ('/=/m', ' &nbsp; </span><div class="voc_to_recycle">', $voc_to_recycle);
$voc_to_recycle = preg_replace ('/^/m', '<span class="new_expressions">', $voc_to_recycle);
$voc_to_recycle = preg_replace ('/$/m', '</div> &nbsp; ', $voc_to_recycle);
$voc_to_recycle = preg_replace('/^<span class="new_expressions"><\/div> &nbsp; /m', '', $voc_to_recycle);
$voc_to_recycle = preg_replace('/^<\/div> &nbsp; /m', '', $voc_to_recycle);
$voc_to_recycle = trim(preg_replace('/\s\s+/', ' ', $voc_to_recycle));
echo $voc_to_recycle;
//echo "<pre class=\"lesson_plan\">"; // check for softbook if not using same layout
echo "</div> <!-- end of voc_box_for_role_plays -->\n";
echo "</div> <!-- end of flex-container -->\n";
/***/
echo "</div><!-- /class role_play -->\n";
   echo "</pre>";
//}
} // end ROLE PLAY
/***/

// is not a plugin - is in xml_load_file_ref_sbook.inc
if (($clog_activity->activity_type == 'lead_in' 
    && $clog_activity->activity_status == 'active') 
    || ($clog_activity->activity_type == 'lead_in_2roles' 
    && $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
//    echo "<div class=\"sbook_background_image\"><img class=\"sbook01\" src=\"".$activity->activity_background."\" alt=\"background image\">";
echo "<div class=\"flex-container\">";
    echo "<div class=\"sbook_left_column\">\n";
        echo "<div class=\"sbook_collaboration\"> &nbsp; ".$clog_activity->activity_title."</div>";
    echo "</div><!-- end sbook_left_column -->\n";

    echo "<div class=\"sbook_middle_right_column\">\n";
    echo "<div class=\"activity_background_$sbook_ref"."_"."$activity_background_trimmed\">";
    echo "<pre class=\"sbook_lesson_plan\">";

        echo "<span class=\"sbook_exercise_no\">".$clog_activity->activity_id."</span> <span class=\"sbook_instructions_white\">".$clog_activity->instructions."</span>";
  $instructions_demo = trim($clog_activity->instructions_demo);
  if (!empty($clog_activity->instructions_demo))  {
    echo "<div class=\"sbook_instructions_demo\">".$clog_activity->instructions_demo."</div><br />";
  }

$student_a = trim ($clog_activity->student_a->qa->qs);
if (!empty($student_a))  {
echo "<div class=\"flex-container\">\n";
echo "<div class=\"sbook_column_role_play_a\">\n";

echo "<button id=\"button_toggle_visibility_type01\" onclick=\"toggle_visibility('toggle_type01_student_a_".$clog_activity->activity_id."');\"><img src=\"".$xml4tpath0."pix/icons8-weightlifting-100.png\" width=\"35em\" border=\"0\" alt=\"Student A\" />Student A</button>";
echo "<div id='toggle_type01_student_a_".$clog_activity->activity_id."' style=\"display:none;\">\n";

echo "<div class=\"toggle_type01\">";

        echo "<ol>";
foreach($clog_activity->student_a->qa as $qa) { 
  //echo "<li>".$qa->qs."</li>";
  echo "<li class=\"question_sbook_white\">".$qa->qs."</li>";
  //include ('inc/xml_show_definition.inc');
if ($qa->ans != null) {
  //echo "<span class=\"show_key_sbook\">".$qa->ans."</span><br />\n";
  echo "<br /><span class=\"show_key_sbook_white\">".$qa->ans."</span><br />\n"; // use <br /> to cope w/ display: inline-block
}
}
        echo "</ol>";
  echo "</div> <!-- end of column_role_play_a -->\n";
echo "</div><!-- /class toggle_type01 -->\n";
echo "</div><!-- /toggle_visibility_type01 -->\n";

echo "<div class=\"sbook_column_role_play_b\">\n";
echo "<button id=\"button_toggle_visibility_type01\" onclick=\"toggle_visibility('toggle_type01_student_b_".$clog_activity->activity_id."');\"><img src=\"".$xml4tpath0."pix/icons8-lightweight-100.png\" width=\"35em\" border=\"0\" alt=\"Student B\" />Student B</button>";
echo "<div id='toggle_type01_student_b_".$clog_activity->activity_id."' style=\"display:none;\">\n";
echo "<div class=\"toggle_type01\">";
        echo "<ol>";
foreach($clog_activity->qa as $qa) { 
  echo "<li class=\"question_sbook_white\">".$qa->qs."</li>";
  //include ('inc/xml_show_definition.inc');
if ($qa->ans != null) {
  //echo "<span class=\"show_key_sbook\">".$qa->ans."</span><br />\n";
  echo "<br /><span class=\"show_key_sbook_white\">".$qa->ans."</span><br />\n"; // use <br /> to cope w/ display: inline-block
}
}
        echo "</ol>";
    //echo "</div><!-- end of background image -->";
  echo "</div> <!-- end of column_role_play_b -->\n";
echo "</div><!-- /class toggle_type01 -->\n";
echo "</div><!-- /toggle_visibility_type01 -->\n";

echo "</div>"; // endif class=\"flex-container\">\n";

} else {

        echo "<ol>";
foreach($clog_activity->qa as $qa) { 
  echo "<li class=\"question_sbook_white\">".$qa->qs."</li>";
  //include ('inc/xml_show_definition.inc');
if ($qa->ans != null) {
  //echo "<span class=\"show_key_sbook\">".$qa->ans."</span><br />\n";
  echo "<br /><span class=\"show_key_sbook_white\">".$qa->ans."</span><br />\n"; // use <br /> to cope w/ display: inline-block
}
}
        echo "</ol>";
    //echo "</div><!-- end of background image -->";
} // end else if not empty graded contents role a

    echo "</pre>";
    echo "</div>"; // end of <div class=\"activity_background\">";
    echo "</div><!-- end sbook_middle_right_column -->\n";
echo "</div> <!-- end flex-container -->\n";
//  echo "</div><!-- end of background image -->";

//echo "<div style=\"page-break-after:always\"></div>\n";
} // end if activity is lead_in





if ($clog_activity->activity_type == "review"
    && $clog_activity->activity_status == 'active') {
// todo for each csv in XXXXXXXXXXX
// workaround = create as many activity types == review as needed - check
$review_ref = $clog_activity->activity_id;
$list_of_reviews = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/csv_load_review.inc");
}

if (($clog_activity->activity_type == "grammar")
    && $clog_activity->activity_status == 'active' 
    && ($clog_activity->activity_status != "wip")) {
// hide 2nd occurrence due to bug in js or else every 2nd grammar activity doesn't display
//echo "<!-- no grammar contents to display -->";
    // create a unique id with title - not actually needed any more but cleaner
    $grammar_title = $clog_activity->activity_title;
    $string_to_replace = ' ';
    $string_to_add = '_';
    $grammar_title_wo_spaces = preg_replace ('/'.$string_to_replace.'/m', ''.$string_to_add.'', $grammar_title);
    
$grammar_ref = $clog_activity->activity_id;
${'txt_'.$grammar_ref.'_'.$grammar_title_wo_spaces} = trim($clog_activity->activity_contents);
include("sbook_plugins/show_hide_grammar_w_title_wo_spaces_disabled.inc");
// display 1st occurrence
  echo "<img src=\"".$xml4tpath0."pix/icons8-automation-100.png\" width=\"35em\" border=\"0\" alt=\"target language presentation - grammar\"> ".trim($clog_activity->activity_title)." ";
$grammar_ref = $clog_activity->activity_id;
${'txt_'.$grammar_ref} = trim($clog_activity->activity_contents);
include("".$xml4tpath."sbook_plugins/show_hide_grammar.inc");
}

if ((trim($clog_xml->clog_session_status !='lc')) && (trim($clog_xml->clog_session_status !='tbc')) && ($clog_activity->activity_type == "uefadvd") && ($clog_activity->activity_status != "wip")) {
$list_of_uefa_ref = trim($clog_activity->activity_contents);
//echo $list_of_uefa_ref;
echo "</div></pre>\n";
include("".$xml4tpath."inc_sbook/xml_load_file_ref_uefa.inc"); // 20210304-1818
echo "<pre class=\"lesson_plan\"><div class=\"clog_support_materials_covered\">\n";
}

if ($clog_activity->activity_type == "quarterly_test"
    && $clog_activity->activity_status == 'active') {
  echo "<br /><img src=\"".$xml4tpath0."pix/icons8-quiz-100.png\" width=\"35em\" border=\"0\" alt=\"Quarterly test\"> ".trim($clog_activity->activity_title)."\n";
echo "<div id=\"print_only_icon\">\n";
$test_ref = $clog_activity->activity_id;
$include_heading = "no";
include ("".$xml4tpath."sbook_plugins/xml_load_quarterly_test_from_xml_and_csv.inc");
echo "</div id=\"print_only_icon\">\n";
}

if ($clog_activity->activity_type == "quarterly_test_feedback"
    && $clog_activity->activity_status == 'active') {
  echo "<br /><img src=\"".$xml4tpath0."pix/icons8-quiz-100.png\" width=\"35em\" border=\"0\" alt=\"Quarterly test feedback\"> ".trim($clog_activity->activity_title)."\n";
$include_heading = "no";
$test_ref = $clog_activity->activity_id;
include ("".$xml4tpath."sbook_plugins/xml_load_quarterly_test_from_xml_and_csv_feedback.inc");
}


if ($clog_activity->activity_type == "quarterly_test_logs"
    && $clog_activity->activity_status == 'active') {
  echo "<br /><img src=\"".$xml4tpath0."pix/icons8-quiz-100.png\" width=\"35em\" border=\"0\" alt=\"Quarterly test logs\"> ".trim($clog_activity->activity_title)."<br />\n";
$include_heading = "no";
foreach (($clog_activity->sbook_test_logs) as $test_log_ref) {
//var_dump ($test_log_ref);
include ("".$xml4tpath."sbook_plugins/xml_load_quarterly_test_logs.inc");
}

echo "<br />";
} 


} //foreach ($clog_support_material->clog_activity as $clog_activity) 
echo "<br />";
} // foreach ($clog_support_material->clog_activity as $clog_activity)
echo "</div>\n";


echo "<u>new expressions</u><div class=\"clog_expressions\">";
// expressions from course log by default
echo trim($clog_xml->clog_expressions);

// INCLUDE EXPRESSIONS FROM SBOOK FILES
// snippet from xml_load_file_ref_sbook.inc
  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("".$xml4tpath."inc_sbook_xml/lesson_".$ref.".xml");// or die("Error: Cannot create object $ xml");
$voc_to_recycle = (${'xml'.$ref}->sbook_expressions);
echo "\n".trim($voc_to_recycle);
} // 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_ref_sbook.inc


// INCLUDE EXPRESSIONS FROM EFEKTA FILES
// snippet below from xml_load_file_ref_efekta.inc
if (!empty($clog_xml->clog_efekta_incl)) { // 20210127-1826
foreach ($clog_xml->clog_efekta_incl as $clog_efekta_incl) {
$list_of_ref = $clog_efekta_incl;
// include("inc/xml_load_file_ref_sbook.inc"); // 20210127-1832
//include("inc_sbook/xml_load_file_ref_efekta.inc"); // 20210127-1832

$xml_reference_pattern = '/([0-9]{2}-[0-6]{1}-[0-4]{1})/m'; // 20210128-1231 includes Preliminaries to flipped lessons > 00-0-0  > Flipped lessons 
if (preg_match_all($xml_reference_pattern,$list_of_ref,$matches)) {
foreach ($matches[0] as $ref) {

//${'xml'.$ref}=simplexml_load_file("inc_xml/lesson_".$ref.".xml");  
  ${'xml_'.$all_ref}=simplexml_load_file("".$xml4tpath."inc_xml/lesson_".$ref.".xml");
if (${'xml_'.$all_references}->sbook_lexical_material[0] != null) {
       $new_expressions = (${'xml_'.$all_references}->sbook_expressions."\n");
       echo "\n".trim($new_expressions);

} // if (${'xml_'.$all_references}->sbook_lexical_material[0] != null) 
  /* don't forget at the end of file */
} // end foreach
} // end if preg_match_all

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

echo "</div>\n";

echo "<u>deco - delayed error correction / favourite mistakes</u><div class=\"clog_deco\">";
if (!isset($clog_ref)) {
// workaround when not using xml_load_clog.inc
$deco_ref = $clog_xml->clog_session_date;
}
else {
// loaded in inc/xml_load_clog.inc
  $deco_ref = $clog_ref;
}
${'txt_'.$deco_ref} = trim($clog_xml->clog_deco);

include("".$xml4tpath."sbook_plugins/show_hide_mistakes.inc");
echo "</div>\n";

echo "<u>pig - pronunciation & intonation guidelines</u><div class=\"clog_pig\">";
echo trim ($clog_xml->clog_pig);
echo "</div>\n";

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";
?>
