moodle-expcontent/view.php
2022-09-07 14:04:43 +00:00

61 lines
1.8 KiB
PHP

<?php
require('../../config.php');
require_once($CFG->dirroot.'/mod/expcontent/lib.php');
require_once($CFG->libdir.'/completionlib.php');
$id = required_param('id', PARAM_INT);
list ($course, $cm) = get_course_and_cm_from_cmid($id, 'expcontent');
$expcontent = $DB->get_record('expcontent', array('id'=> $cm->instance), '*', MUST_EXIST);
$expconfig = get_config('mod_expcontent');
$baseurl = $expconfig->baseurl;
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
if ($baseurl[-1] != "/") $baseurl += "/";
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/mod/expcontent/css/expcontent.css">
<link rel="stylesheet" type="text/css" href="/mod/expcontent/vendor/font-awesome/css/all.css">
<title><?php echo($expcontent->name); ?></title>
</head>
<body>
<ul>
<li class="logo"><img src="pix/icon.png"></li>
<li class="title"><div class="container"><div class="text"><?php echo($expcontent->name); ?></div></div></li>
<li class="right"><a class="hover" href="#" onclick="goToCourse();"><i class="fas fa-times"></i></a></li>
</ul>
<iframe src='<?php echo($baseurl . "view-content/" . $expcontent->contentid . "?autoplay=true"); ?>' allow="autoplay; fullscreen"></iframe>
<script>
<?php
$modinfo = get_fast_modinfo($course);
$quizzes = array();
foreach ($modinfo->get_instances_of("quiz") as $quiz) {
$quizzes[] = $quiz->id;
}
echo("var thiscourse = $course->id;\n");
echo("var quizzes = " . json_encode($quizzes) . ";\n\n");
?>
function goToCourse(courseid=thiscourse) {
window.location.href = "/course/view.php?id=" + courseid;
}
function goToQuiz(quizindex=1) {
quizid = quizzes[quizindex-1];
window.location.href = "/mod/quiz/view.php?id=" + quizid;
}
</script>
</body>
</html>