Bumped the version up to 1.9.3
[moodle.git] / mod / hotpot / show.php
blobd1fdf02298a02cc5798ffb5cf04d3476312adf87
1 <?php // $Id$
3 require_once("../../config.php");
4 require_once("lib.php");
6 $params = new stdClass();
7 $params->action = required_param('action', PARAM_ALPHA);
8 $params->course = required_param('course', PARAM_INT);
9 $params->reference = required_param('reference', PARAM_PATH);
11 require_login($params->course);
13 if (!has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $params->course))) {
14 error("You are not allowed to view this page!");
16 if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM))) {
17 $params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES, PARAM_INT);
18 } else {
19 $params->location = HOTPOT_LOCATION_COURSEFILES;
21 $title = get_string($params->action, 'hotpot').': '.$params->reference;
22 print_header($title, $title);
23 hotpot_print_show_links($params->course, $params->location, $params->reference);
25 <script type="text/javascript">
26 //<![CDATA[
27 // http://www.krikkit.net/howto_javascript_copy_clipboard.html
28 function copy_contents(id) {
29 if (id==null) {
30 id = 'contents';
32 var obj = null;
33 if (document.getElementById) {
34 obj = document.getElementById(id);
36 if (obj && window.clipboardData) {
37 window.clipboardData.setData("Text", obj.innerText);
38 alert('<?php print_string('copiedtoclipboard', 'hotpot') ?>');
41 document.write('<span class="helplink"> &nbsp; <a href="javascript:copy_contents()"><?php print_string('copytoclipboard', 'hotpot') ?></A></span>');
42 //]]>
43 </script>
44 <?php
45 print_simple_box_start("center", "96%");
46 if($hp = new hotpot_xml_quiz($params)) {
47 print '<pre id="contents">';
48 switch ($params->action) {
49 case 'showxmlsource':
50 print htmlspecialchars($hp->source);
51 break;
52 case 'showxmltree':
53 if (isset($hp->xml)) {
54 print_r($hp->xml);
56 break;
57 case 'showhtmlsource':
58 print htmlspecialchars($hp->html);
59 break;
60 case 'showhtmlquiz':
61 print $hp->html;
62 break;
64 print '</pre>';
65 } else {
66 print_simple_box("Could not open Hot Potatoes XML file", "center", "", "#FFBBBB");
68 print_simple_box_end();
69 print '<br />';
70 close_window_button();