diff --git a/backup/cc/cc112moodle.php b/backup/cc/cc112moodle.php
index 79928ba8afa..eb15d00c646 100644
--- a/backup/cc/cc112moodle.php
+++ b/backup/cc/cc112moodle.php
@@ -177,6 +177,28 @@ class cc112moodle extends cc2moodle {
return $result . $blti_mod;
}
+ /**
+ * (non-PHPdoc)
+ * @see cc2moodle::get_module_visible()
+ */
+ protected function get_module_visible($identifier) {
+ //Should item be hidden or not
+ $mod_visible = 1;
+ if (!empty($identifier)) {
+ $xpath = static::newx_path(static::$manifest, static::$namespaces);
+ $query = '/imscc:manifest/imscc:resources/imscc:resource[@identifier="' . $identifier . '"]';
+ $query .= '//lom:intendedEndUserRole/lom:value';
+ $intendeduserrole = $xpath->query($query);
+ if (!empty($intendeduserrole) && ($intendeduserrole->length > 0)) {
+ $role = trim($intendeduserrole->item(0)->nodeValue);
+ if ((strcasecmp('Instructor', $role) === 0) || (strcasecmp('Mentor', $role) === 0)) {
+ $mod_visible = 0;
+ }
+ }
+ }
+ return $mod_visible;
+ }
+
protected function create_node_course_modules_mod () {
$labels = new cc_label();
$resources = new cc11_resource();
diff --git a/backup/cc/cc2moodle.php b/backup/cc/cc2moodle.php
index a13362b4d0d..9410a80b336 100644
--- a/backup/cc/cc2moodle.php
+++ b/backup/cc/cc2moodle.php
@@ -426,6 +426,30 @@ class cc2moodle {
}
+ /**
+ *
+ * Is activity visible or not
+ * @param string $identifier
+ * @return number
+ */
+ protected function get_module_visible($identifier) {
+ //Should item be hidden or not
+ $mod_visible = 1;
+ if (!empty($identifier)) {
+ $xpath = static::newx_path(static::$manifest, static::$namespaces);
+ $query = '/imscc:manifest/imscc:resources/imscc:resource[@identifier="' . $identifier . '"]';
+ $query .= '//lom:intendedEndUserRole/voc:vocabulary/lom:value';
+ $intendeduserrole = $xpath->query($query);
+ if (!empty($intendeduserrole) && ($intendeduserrole->length > 0)) {
+ $role = trim($intendeduserrole->item(0)->nodeValue);
+ if (strcasecmp('Instructor', $role) == 0) {
+ $mod_visible = 0;
+ }
+ }
+ }
+ return $mod_visible;
+ }
+
protected function create_node_course_sections_section_mods_mod ($root_parent) {
$sheet_course_sections_section_mods_mod = static::loadsheet(SHEET_COURSE_SECTIONS_SECTION_MODS_MOD);
@@ -459,13 +483,15 @@ class cc2moodle {
'[#mod_instance_id#]',
'[#mod_type#]',
'[#date_now#]',
- '[#mod_indent#]');
+ '[#mod_indent#]',
+ '[#mod_visible#]');
$replace_values = array($child['index'],
$child['instance'],
$child['moodle_type'],
time(),
- $indent);
+ $indent,
+ $this->get_module_visible($child['resource_indentifier']));
$node_course_sections_section_mods_mod .= str_replace($find_tags, $replace_values, $sheet_course_sections_section_mods_mod);
}
diff --git a/backup/cc/entity.resource.class.php b/backup/cc/entity.resource.class.php
index b2f7b879920..6de81164296 100644
--- a/backup/cc/entity.resource.class.php
+++ b/backup/cc/entity.resource.class.php
@@ -132,32 +132,33 @@ class cc_resource extends entities {
$cdir = getcwd();
chdir($dirpath);
try {
- $doc->loadHTML($mod_alltext);
- $xpath = new DOMXPath($doc);
- $attributes = array('href', 'src', 'background', 'archive', 'code');
- $qtemplate = "//*[@##][not(contains(@##,'://'))]/@##";
- $query = '';
- foreach ($attributes as $attrname) {
- if (!empty($query)) {
- $query .= " | ";
+ if (!empty($mod_alltext) && $doc->loadHTML($mod_alltext)) {
+ $xpath = new DOMXPath($doc);
+ $attributes = array('href', 'src', 'background', 'archive', 'code');
+ $qtemplate = "//*[@##][not(contains(@##,'://'))]/@##";
+ $query = '';
+ foreach ($attributes as $attrname) {
+ if (!empty($query)) {
+ $query .= " | ";
+ }
+ $query .= str_replace('##', $attrname, $qtemplate);
}
- $query .= str_replace('##', $attrname, $qtemplate);
- }
- $list = $xpath->query($query);
- $searches = array();
- $replaces = array();
- foreach ($list as $resrc) {
- $rpath = $resrc->nodeValue;
- $rtp = realpath($rpath);
- if (($rtp !== false) && is_file($rtp)) {
- //file is there - we are in business
- $strip = str_replace("\\", "/", str_ireplace($rootpath, '', $rtp));
- $encoded_file = '$@FILEPHP@$'.str_replace('/', '$@SLASH@$', $strip);
- $searches[] = $resrc->nodeValue;
- $replaces[] = $encoded_file;
+ $list = $xpath->query($query);
+ $searches = array();
+ $replaces = array();
+ foreach ($list as $resrc) {
+ $rpath = $resrc->nodeValue;
+ $rtp = realpath($rpath);
+ if (($rtp !== false) && is_file($rtp)) {
+ //file is there - we are in business
+ $strip = str_replace("\\", "/", str_ireplace($rootpath, '', $rtp));
+ $encoded_file = '$@FILEPHP@$'.str_replace('/', '$@SLASH@$', $strip);
+ $searches[] = $resrc->nodeValue;
+ $replaces[] = $encoded_file;
+ }
}
+ $mod_alltext = str_replace($searches, $replaces, $mod_alltext);
}
- $mod_alltext = str_replace($searches, $replaces, $mod_alltext);
} catch (Exception $e) {
//silence the complaints
}
diff --git a/backup/cc/sheets/course_sections_section_mods_mod.xml b/backup/cc/sheets/course_sections_section_mods_mod.xml
index 7a5f36c4862..c170ced220f 100644
--- a/backup/cc/sheets/course_sections_section_mods_mod.xml
+++ b/backup/cc/sheets/course_sections_section_mods_mod.xml
@@ -5,7 +5,7 @@
[#date_now#]
0
[#mod_indent#]
- 1
+ [#mod_visible#]
0
0
0