2009-09-24 07:47:50 +00:00
< ? PHP
2006-08-09 13:45:49 +00:00
/// This page prints a hotpot quiz
if ( defined ( 'HOTPOT_FIRST_ATTEMPT' ) && HOTPOT_FIRST_ATTEMPT == false ) {
// this script is being included (by attempt.php)
} else {
// this script is being called directly from the browser
define ( 'HOTPOT_FIRST_ATTEMPT' , true );
require_once ( " ../../config.php " );
require_once ( " lib.php " );
2006-05-02 06:00:35 +00:00
2006-10-07 08:59:59 +00:00
$id = optional_param ( 'id' , 0 , PARAM_INT ); // Course Module ID, or
$hp = optional_param ( 'hp' , 0 , PARAM_INT ); // hotpot ID
2006-05-02 06:00:35 +00:00
2006-08-09 13:45:49 +00:00
if ( $id ) {
2010-01-16 15:39:56 +00:00
$PAGE -> set_url ( '/mod/hotpot/report.php' , array ( 'id' => $id ));
2006-08-09 13:45:49 +00:00
if ( ! $cm = get_coursemodule_from_id ( 'hotpot' , $id )) {
2008-05-29 02:49:39 +00:00
print_error ( 'invalidcoursemodule' );
2006-08-09 13:45:49 +00:00
}
2008-06-08 19:37:17 +00:00
if ( ! $course = $DB -> get_record ( " course " , array ( " id " => $cm -> course ))) {
2008-05-29 02:49:39 +00:00
print_error ( 'coursemisconf' );
2006-08-09 13:45:49 +00:00
}
2008-06-08 19:37:17 +00:00
if ( ! $hotpot = $DB -> get_record ( " hotpot " , array ( " id " => $cm -> instance ))) {
2008-05-29 02:49:39 +00:00
print_error ( 'invalidcoursemodule' );
2006-08-09 13:45:49 +00:00
}
2006-05-02 06:00:35 +00:00
2006-08-09 13:45:49 +00:00
} else {
2010-01-16 15:39:56 +00:00
$PAGE -> set_url ( '/mod/hotpot/report.php' , array ( 'hp' => $hp ));
2008-06-08 19:37:17 +00:00
if ( ! $hotpot = $DB -> get_record ( " hotpot " , array ( " id " => $hp ))) {
2008-05-29 02:49:39 +00:00
print_error ( 'invalidhotpotid' , 'hotpot' );
2006-08-09 13:45:49 +00:00
}
2008-06-08 19:37:17 +00:00
if ( ! $course = $DB -> get_record ( " course " , array ( " id " => $hotpot -> course ))) {
2008-05-29 02:49:39 +00:00
print_error ( 'coursemisconf' );
2006-08-09 13:45:49 +00:00
}
if ( ! $cm = get_coursemodule_from_instance ( " hotpot " , $hotpot -> id , $course -> id )) {
2008-05-29 02:49:39 +00:00
print_error ( 'invalidcoursemodule' );
2006-08-09 13:45:49 +00:00
}
2007-08-17 19:09:11 +00:00
2006-08-09 13:45:49 +00:00
}
2007-08-17 12:49:28 +00:00
require_login ( $course , true , $cm );
2006-08-30 08:43:17 +00:00
$context = get_context_instance ( CONTEXT_MODULE , $cm -> id );
2010-02-11 02:55:40 +00:00
require_capability ( 'mod/hotpot:attempt' , $context , $USER -> id );
2006-08-09 13:45:49 +00:00
}
// set nextpage (for error messages)
$nextpage = " $CFG->wwwroot /course/view.php?id= $course->id " ;
// header strings
2007-02-28 06:25:22 +00:00
$title = format_string ( $course -> shortname . ': ' . $hotpot -> name , true );
$heading = $course -> fullname ;
2007-08-17 19:09:11 +00:00
2007-01-28 00:25:57 +00:00
$button = '<div style="font-size:0.75em;">' . $button . '</div>' ;
2009-09-07 03:55:32 +00:00
$PAGE -> set_title ( $title );
$PAGE -> set_heading ( $heading );
$PAGE -> set_button ( $button );
2006-08-09 13:45:49 +00:00
$time = time ();
2009-08-27 18:37:53 +00:00
$hppassword = optional_param ( 'hppassword' , '' , PARAM_RAW );
2006-08-30 08:43:17 +00:00
if ( HOTPOT_FIRST_ATTEMPT && ! has_capability ( 'mod/hotpot:grade' , $context )) {
2006-08-09 13:45:49 +00:00
// check this quiz is available to this student
// error message, if quiz is unavailable
$error = '' ;
// check quiz is visible
if ( ! hotpot_is_visible ( $cm )) {
$error = get_string ( " activityiscurrentlyhidden " );
// check network address
2009-05-01 03:04:10 +00:00
} else if ( $hotpot -> subnet && ! address_in_subnet ( getremoteaddr (), $hotpot -> subnet )) {
2006-08-09 13:45:49 +00:00
$error = get_string ( " subneterror " , " quiz " );
// check number of attempts
2009-11-01 15:03:10 +00:00
} else if ( $hotpot -> attempts && $hotpot -> attempts <= $DB -> count_records_select ( 'hotpot_attempts' , 'hotpot=? AND userid=?' , array ( $hotpot -> id , $USER -> id ), 'COUNT(DISTINCT clickreportid)' )) {
2006-08-09 13:45:49 +00:00
$error = get_string ( " nomoreattempts " , " quiz " );
// get password
} else if ( $hotpot -> password && empty ( $hppassword )) {
2009-09-07 03:55:32 +00:00
echo $OUTPUT -> header ();
2009-08-06 08:22:00 +00:00
echo $OUTPUT -> heading ( $hotpot -> name );
2006-08-09 13:45:49 +00:00
$boxalign = 'center' ;
$boxwidth = 500 ;
if ( trim ( strip_tags ( $hotpot -> summary ))) {
2009-08-18 05:15:09 +00:00
echo $OUTPUT -> box_start ( " generalbox boxalign $boxalign " );
2008-12-10 06:48:54 +00:00
print '<div class="mdl-align">' . format_text ( $hotpot -> summary ) . " </div> \n " ;
2009-08-18 05:15:09 +00:00
echo $OUTPUT -> box_end ();
2006-08-09 13:45:49 +00:00
print " <br /> \n " ;
}
2007-01-04 21:32:36 +00:00
print '<form id="passwordform" method="post" action="view.php?id=' . $cm -> id . '">' . " \n " ;
2009-08-18 05:15:09 +00:00
echo $OUTPUT -> box_start ( " generalbox boxalign $boxalign " );
2008-12-10 06:48:54 +00:00
print '<div class="mdl-align">' ;
2006-08-09 13:45:49 +00:00
print get_string ( 'requirepasswordmessage' , 'quiz' ) . '<br /><br />' ;
print '<b>' . get_string ( 'password' ) . ':</b> ' ;
2007-01-08 19:34:16 +00:00
print '<input name="hppassword" type="password" value="" /> ' ;
print '<input type="submit" value="' . get_string ( " ok " ) . '" /> ' ;
2006-08-09 13:45:49 +00:00
print " </div> \n " ;
2009-08-18 05:15:09 +00:00
echo $OUTPUT -> box_end ();
2006-08-09 13:45:49 +00:00
print " </form> \n " ;
2009-08-06 14:20:19 +00:00
echo $OUTPUT -> footer ();
2006-08-09 13:45:49 +00:00
exit ;
// check password
} else if ( $hotpot -> password && strcmp ( $hotpot -> password , $hppassword )) {
$error = get_string ( " passworderror " , " quiz " );
$nextpage = " view.php?id= $cm->id " ;
// check quiz is open
} else if ( $hotpot -> timeopen && $hotpot -> timeopen > $time ) {
$error = get_string ( " quiznotavailable " , " quiz " , userdate ( $hotpot -> timeopen )) . " <br /> \n " ;
// check quiz is not closed
} else if ( $hotpot -> timeclose && $hotpot -> timeclose < $time ) {
$error = get_string ( " quizclosed " , " quiz " , userdate ( $hotpot -> timeclose )) . " <br /> \n " ;
}
if ( $error ) {
2009-09-07 03:55:32 +00:00
echo $OUTPUT -> header ();
2006-08-09 13:45:49 +00:00
notice ( $error , $nextpage );
//
// script stops here, if quiz is unavailable to student
//
}
}
$available_msg = '' ;
if ( ! empty ( $hotpot -> timeclose ) && $hotpot -> timeclose > $time ) {
// quiz is available until 'timeclose'
$available_msg = get_string ( " quizavailable " , " quiz " , userdate ( $hotpot -> timeclose )) . " <br /> \n " ;
}
// open and parse the source file
if ( ! $hp = new hotpot_xml_quiz ( $hotpot )) {
2008-05-29 02:49:39 +00:00
print_error ( 'quizunavailable' , 'hotpot' );
2006-08-09 13:45:49 +00:00
}
2006-10-07 08:59:59 +00:00
$get_js = optional_param ( 'js' , '' , PARAM_ALPHA );
$get_css = optional_param ( 'css' , '' , PARAM_ALPHA );
$framename = optional_param ( 'framename' , '' , PARAM_ALPHA );
2006-08-09 13:45:49 +00:00
// look for <frameset> (HP5 v5)
$frameset = '' ;
$frameset_tags = '' ;
if ( preg_match_all ( '|<frameset([^>]*)>(.*?)</frameset>|is' , $hp -> html , $matches )) {
$last = count ( $matches [ 0 ]) - 1 ;
$frameset = $matches [ 2 ][ $last ];
$frameset_tags = $matches [ 1 ][ $last ];
}
// if HTML is being requested ...
if ( empty ( $get_js ) && empty ( $get_css )) {
2007-08-17 19:09:11 +00:00
if ( empty ( $frameset )) {
2006-08-09 13:45:49 +00:00
// HP v6
if ( $hotpot -> navigation == HOTPOT_NAVIGATION_FRAME || $hotpot -> navigation == HOTPOT_NAVIGATION_IFRAME ) {
$get_html = ( $framename == 'main' ) ? true : false ;
} else {
$get_html = true ;
}
2007-08-17 19:09:11 +00:00
} else {
2006-08-09 13:45:49 +00:00
// HP5 v5
$get_html = empty ( $framename ) ? true : false ;
}
if ( $get_html ) {
2007-08-17 19:09:11 +00:00
2006-08-09 13:45:49 +00:00
if ( HOTPOT_FIRST_ATTEMPT ) {
add_to_log ( $course -> id , " hotpot " , " view " , " view.php?id= $cm->id " , " $hotpot->id " , " $cm->id " );
2006-05-02 06:00:35 +00:00
2006-08-09 13:45:49 +00:00
$attemptid = hotpot_add_attempt ( $hotpot -> id );
}
$hp -> adjust_media_urls ();
if ( empty ( $frameset )) {
// HP6 v6
2007-10-04 05:32:27 +00:00
$targetframe = '' ;
2006-08-09 13:45:49 +00:00
switch ( $hotpot -> navigation ) {
case HOTPOT_NAVIGATION_BUTTONS :
// do nothing (i.e. leave buttons as they are)
break ;
case HOTPOT_NAVIGATION_GIVEUP :
$hp -> insert_giveup_form ( $attemptid , '<!-- BeginTopNavButtons -->' , '<!-- EndTopNavButtons -->' );
break ;
2007-10-04 05:32:27 +00:00
case HOTPOT_NAVIGATION_FRAME :
$targetframe = $CFG -> framename ;
// drop through to remove nav buttons too
2006-08-09 13:45:49 +00:00
default :
$hp -> remove_nav_buttons ();
}
if ( isset ( $hp -> real_outputformat ) && $hp -> real_outputformat == HOTPOT_OUTPUTFORMAT_MOBILE ) {
$hp -> insert_submission_form ( $attemptid , '<!-- BeginSubmissionForm -->' , '<!-- EndSubmissionForm -->' , true );
} else {
2007-10-04 05:32:27 +00:00
$hp -> insert_submission_form ( $attemptid , '<!-- BeginSubmissionForm -->' , '<!-- EndSubmissionForm -->' , false , $targetframe );
2006-08-09 13:45:49 +00:00
}
} else {
// HP5 v5
switch ( $hotpot -> navigation ) {
case HOTPOT_NAVIGATION_BUTTONS :
// convert URLs in nav buttons
break ;
case HOTPOT_NAVIGATION_GIVEUP :
// $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
break ;
default :
// remove navigation buttons
$hp -> html = preg_replace ( '#NavBar\+=(.*);#' , '' , $hp -> html );
}
$hp -> insert_submission_form ( $attemptid , " var NavBar=' " , " '; " );
}
}
}
//FEEDBACK = new Array();
//FEEDBACK[0] = ''; // url of feedback page/script
//FEEDBACK[1] = ''; // array of array('teachername', 'value');
//FEEDBACK[2] = ''; // 'student name' [formmail only]
//FEEDBACK[3] = ''; // 'student email' [formmail only]
//FEEDBACK[4] = ''; // window width
//FEEDBACK[5] = ''; // window height
//FEEDBACK[6] = ''; // 'Send a message to teacher' [prompt/button text]
//FEEDBACK[7] = ''; // 'Title'
//FEEDBACK[8] = ''; // 'Teacher'
//FEEDBACK[9] = ''; // 'Message'
//FEEDBACK[10] = ''; // 'Close this window'
$feedback = array ();
switch ( $hotpot -> studentfeedback ) {
case HOTPOT_FEEDBACK_NONE :
// do nothing
break ;
case HOTPOT_FEEDBACK_WEBPAGE :
if ( empty ( $hotpot -> studentfeedbackurl )) {
$hotpot -> studentfeedback = HOTPOT_FEEDBACK_NONE ;
} else {
$feedback [ 0 ] = " ' $hotpot->studentfeedbackurl ' " ;
}
break ;
case HOTPOT_FEEDBACK_FORMMAIL :
$teachers = hotpot_feedback_teachers ( $course , $hotpot );
if ( empty ( $teachers ) || empty ( $hotpot -> studentfeedbackurl )) {
$hotpot -> studentfeedback = HOTPOT_FEEDBACK_NONE ;
} else {
$feedback [ 0 ] = " ' $hotpot->studentfeedbackurl ' " ;
$feedback [ 1 ] = $teachers ;
$feedback [ 2 ] = " ' " . fullname ( $USER ) . " ' " ;
$feedback [ 3 ] = " ' " . $USER -> email . " ' " ;
$feedback [ 4 ] = 500 ; // width
$feedback [ 5 ] = 300 ; // height
}
break ;
case HOTPOT_FEEDBACK_MOODLEFORUM :
2008-06-08 19:37:17 +00:00
$module = $DB -> get_record ( 'modules' , array ( 'name' => 'forum' ));
$forums = $DB -> get_records ( 'forum' , array ( 'course' => $course -> id ));
2006-08-09 13:45:49 +00:00
if ( empty ( $module ) || empty ( $module -> visible ) || empty ( $forums )) {
$hotpot -> studentfeedback = HOTPOT_FEEDBACK_NONE ;
} else {
$feedback [ 0 ] = " ' $CFG->wwwroot /mod/forum/index.php?id= $course->id ' " ;
}
break ;
case HOTPOT_FEEDBACK_MOODLEMESSAGING :
$teachers = hotpot_feedback_teachers ( $course , $hotpot );
if ( empty ( $CFG -> messaging ) || empty ( $teachers )) {
$hotpot -> studentfeedback = HOTPOT_FEEDBACK_NONE ;
} else {
$feedback [ 0 ] = " ' $CFG->wwwroot /message/discussion.php?id=' " ;
$feedback [ 1 ] = $teachers ;
$feedback [ 4 ] = 400 ; // width
$feedback [ 5 ] = 500 ; // height
}
break ;
default :
// do nothing
}
if ( $hotpot -> studentfeedback != HOTPOT_FEEDBACK_NONE ) {
$feedback [ 6 ] = " 'Send a message to teacher' " ;
$feedback [ 7 ] = " 'Title' " ;
$feedback [ 8 ] = " 'Teacher' " ;
$feedback [ 9 ] = " 'Message' " ;
$feedback [ 10 ] = " 'Close this window' " ;
$js = '' ;
foreach ( $feedback as $i => $str ) {
$js .= 'FEEDBACK[' . $i . " ] = $str ; \n " ;
}
2007-01-03 14:44:17 +00:00
$js = '<script type="text/javascript">' . " \n //<![CDATA[ \n " . " FEEDBACK = new Array(); \n " . $js . " //]]> \n </script> \n " ;
2006-08-09 13:45:49 +00:00
$hp -> html = preg_replace ( '|</head>|i' , " $js </head> " , $hp -> html , 1 );
}
// insert hot-potatoes.js
$hp -> insert_script ( HOTPOT_JS );
2007-05-04 02:53:52 +00:00
// get Moodle pageid and pageclass
2009-05-06 08:38:55 +00:00
$pageid = $PAGE -> pagetype ;
2006-08-09 13:45:49 +00:00
// extract first <head> tag
$head = '' ;
$pattern = '|<head([^>]*)>(.*?)</head>|is' ;
if ( preg_match ( $pattern , $hp -> html , $matches )) {
$head = $matches [ 2 ];
// remove <title>
$head = preg_replace ( '|<title[^>]*>(.*?)</title>|is' , '' , $head );
}
// extract <style> tags (and remove from $head)
$styles = '' ;
$pattern = '|<style([^>]*)>(.*?)</style>|is' ;
if ( preg_match_all ( $pattern , $head , $matches )) {
$count = count ( $matches [ 0 ]);
for ( $i = 0 ; $i < $count ; $i ++ ) {
2007-05-04 02:53:52 +00:00
if ( $pageid ) {
$styles .= str_replace ( 'TheBody' , $pageid , $matches [ 0 ][ $i ]) . " \n " ;
2007-05-08 15:44:37 +00:00
}
2006-08-09 13:45:49 +00:00
$head = str_replace ( $matches [ 0 ][ $i ], '' , $head );
}
}
// extract <script> tags (and remove from $head)
$scripts = '' ;
$pattern = '|<script([^>]*)>(.*?)</script>|is' ;
if ( preg_match_all ( $pattern , $head , $matches )) {
$count = count ( $matches [ 0 ]);
for ( $i = 0 ; $i < $count ; $i ++ ) {
2007-05-04 02:53:52 +00:00
if ( $pageid ) {
$scripts .= str_replace ( 'TheBody' , $pageid , $matches [ 0 ][ $i ]) . " \n " ;
2007-05-08 15:44:37 +00:00
}
2006-08-09 13:45:49 +00:00
$head = str_replace ( $matches [ 0 ][ $i ], '' , $head );
}
}
// extract <body> tags
$body = '' ;
$body_tags = '' ;
$footer = '</html>' ;
2007-08-17 19:09:11 +00:00
// HP6 and some HP5 (v6 and v4)
2006-08-09 13:45:49 +00:00
if ( preg_match ( '|<body' . '([^>]*' . 'onLoad=(["\'])(.*?)(\\2)' . '[^>]*)' . '>(.*)</body>|is' , $hp -> html , $matches )) {
$body = $matches [ 5 ]; // contents of first <body onload="StartUp()">...</body> block
2007-05-04 02:53:52 +00:00
if ( $pageid ) {
$body_tags = str_replace ( ' id="TheBody"' , '' , $matches [ 1 ]);
2007-05-08 15:44:37 +00:00
}
2006-08-09 13:45:49 +00:00
// workaround to ensure javascript onload routine for quiz is always executed
// $body_tags will only be inserted into the <body ...> tag
// if it is included in the theme/$CFG->theme/header.html,
// so some old or modified themes may not insert $body_tags
$body .= " "
. '<script type="text/javascript">' . " \n "
2006-12-22 04:52:13 +00:00
. " //<![CDATA[ \n "
2006-08-09 13:45:49 +00:00
. " var s = (typeof(window.onload)=='function') ? onload.toString() : ''; \n "
. " if (s.indexOf(' " . $matches [ 3 ] . " ')<0) { \n "
. " if (s=='') { \n " // no previous onload
. " window.onload = new Function(' " . $matches [ 3 ] . " '); \n "
. " } else { \n "
. " window.onload_hotpot = onload; \n "
. " window.onload = new Function('window.onload_hotpot();'+' " . $matches [ 3 ] . " '); \n "
. " } \n "
. " } \n "
2006-12-22 04:52:13 +00:00
. " //]]> \n "
2006-08-09 13:45:49 +00:00
. " </script> \n "
;
$footer = '</body>' . $footer ;
} else if ( $frameset ) { // HP5 v5
switch ( $framename ) {
case 'top' :
2009-09-07 03:55:32 +00:00
echo $OUTPUT -> header ();
2006-08-09 13:45:49 +00:00
print $footer ;
break ;
default :
// add a HotPot navigation frame at the top of the page
//$rows = empty($CFG->resource_framesize) ? 85 : $CFG->resource_framesize;
2007-10-21 03:02:55 +00:00
//$frameset = "\n\t".'<frame src="view.php?id='.$cm->id.'&framename=top" frameborder="0" name="top"></frame>'.$frameset;
2006-08-09 13:45:49 +00:00
//$frameset_tags = preg_replace('|rows="(.*?)"|', 'rows="'.$rows.',\\1"', $frameset_tags);
// put navigation into var NavBar='';
// add form to TopFrame in "WriteFeedback" function
// OR add form to BottomFrame in "DisplayExercise" function
// submission form: '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->'
// give up form: '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->'
print " <html> \n " ;
print " <head> \n <title> $title </title> \n $styles\n $scripts </head> \n " ;
print " <frameset $frameset_tags > $frameset </frameset> \n " ;
print " </html> \n " ;
break ;
} // end switch $framename
exit ;
// other files (maybe not even a HotPots)
} else if ( preg_match ( '|<body' . '([^>]*)' . '>(.*)</body>|is' , $hp -> html , $matches )) {
$body = $matches [ 2 ];
$body_tags = $matches [ 1 ];
}
// print the quiz to the browser
if ( $get_js ) {
print ( $scripts );
exit ;
}
if ( $get_css ) {
print ( $styles );
exit ;
}
2007-10-21 03:02:55 +00:00
// closing tags for "page" and "content" divs
$footer = '</div></div>' . $footer ;
2006-08-09 13:45:49 +00:00
switch ( $hotpot -> navigation ) {
case HOTPOT_NAVIGATION_BAR :
2009-09-24 07:47:50 +00:00
$PAGE -> set_title ( $title );
$PAGE -> set_heading ( $heading );
$PAGE -> set_button ( $button );
$PAGE -> set_headingmenu ( $loggedinas );
echo $OUTPUT -> header ();
2006-08-09 13:45:49 +00:00
if ( ! empty ( $available_msg )) {
2009-08-18 05:15:09 +00:00
echo $OUTPUT -> notification ( $available_msg );
2006-08-09 13:45:49 +00:00
}
print $body . $footer ;
break ;
case HOTPOT_NAVIGATION_FRAME :
switch ( $framename ) {
case 'top' :
2009-09-07 03:55:32 +00:00
echo $OUTPUT -> header ();
2006-08-09 13:45:49 +00:00
print $footer ;
break ;
case 'main' :
if ( ! empty ( $available_msg )) {
$hp -> insert_message ( '<!-- BeginTopNavButtons -->' , $available_msg );
}
print $hp -> html ;
break ;
default :
2006-11-28 10:43:27 +00:00
$txtframesetinfo = get_string ( 'framesetinfo' );
$txttoptitle = get_string ( 'navigation' , 'hotpot' );
$txtmaintitle = get_string ( 'modulename' , 'hotpot' );
2006-08-09 13:45:49 +00:00
$rows = empty ( $CFG -> resource_framesize ) ? 85 : $CFG -> resource_framesize ;
2006-11-28 10:43:27 +00:00
@ header ( 'Content-Type: text/html; charset=utf-8' );
print " <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.01 Frameset//EN \" \" http://www.w3.org/TR/html4/frameset.dtd \" > \n " ;
2006-08-09 13:45:49 +00:00
print " <html> \n " ;
2006-11-28 10:43:27 +00:00
print " <meta http-equiv= \" content-type \" content= \" text/html; charset=utf-8 \" /> \n " ;
2006-08-09 13:45:49 +00:00
print " <head><title> $title </title></head> \n " ;
print " <frameset rows= $rows ,*> \n " ;
2007-10-21 03:02:55 +00:00
print " <frame title= \" $txttoptitle\ " src = \ " view.php?id= $cm->id &framename=top \" > \n " ;
print " <frame title= \" $txtmaintitle\ " src = \ " view.php?id= $cm->id &framename=main \" > \n " ;
2006-11-28 10:43:27 +00:00
print " <noframes> \n " ;
print " <p> $txtframesetinfo </p> \n " ;
2007-10-21 03:02:55 +00:00
print " <ul><li><a href= \" view.php?id= $cm->id &framename=top \" > $txttoptitle </a></li> \n " ;
print " <li><a href= \" view.php?id= $cm->id &framename=main \" > $txtmaintitle </a></li></ul> \n " ;
2006-11-28 10:43:27 +00:00
print " </noframes> \n " ;
2006-08-09 13:45:49 +00:00
print " </frameset> \n " ;
print " </html> \n " ;
break ;
} // end switch $framename
break ;
case HOTPOT_NAVIGATION_IFRAME :
switch ( $framename ) {
case 'main' :
print $hp -> html ;
break ;
default :
$iframe_id = 'hotpot_iframe' ;
2010-01-18 20:57:32 +00:00
$PAGE -> requires -> js ( '/mod/hotpot/iframe.js' );
2010-02-06 14:45:17 +00:00
$PAGE -> requires -> js_function_call ( 'set_iframe_height' , array ( $iframe_id ), true );
2009-09-07 03:55:32 +00:00
echo $OUTPUT -> header ();
2006-08-09 13:45:49 +00:00
if ( ! empty ( $available_msg )) {
2009-08-18 05:15:09 +00:00
echo $OUTPUT -> notification ( $available_msg );
2006-08-09 13:45:49 +00:00
}
2007-10-21 03:02:55 +00:00
print " <iframe id= \" $iframe_id\ " src = \ " view.php?id= $cm->id &framename=main \" height= \" 100% \" width= \" 100% \" > " ;
print " <ilayer name= \" $iframe_id\ " src = \ " view.php?id= $cm->id &framename=main \" height= \" 100% \" width= \" 100% \" > " ;
2006-08-09 13:45:49 +00:00
print " </ilayer> \n " ;
print " </iframe> \n " ;
print $footer ;
break ;
} // end switch $framename
break ;
2007-05-11 05:28:28 +00:00
case HOTPOT_NAVIGATION_GIVEUP :
// replace charset , if necessary
// HotPots are plain ascii (iso-8859-1) with unicode chars encoded as HTML entities
2010-04-10 18:20:54 +00:00
$hp -> html = preg_replace (
'|<meta[^>]*charset=iso-8859-1[^>]*>|is' ,
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' ,
$hp -> html
);
2007-05-11 05:28:28 +00:00
// no break (continue to print html to browser)
2006-08-09 13:45:49 +00:00
default :
// HOTPOT_NAVIGATION_BUTTONS
// HOTPOT_NAVIGATION_NONE
if ( ! empty ( $available_msg )) {
$hp -> insert_message ( '<!-- BeginTopNavButtons -->' , $available_msg );
}
print ( $hp -> html );
}
2006-05-02 06:00:35 +00:00
///////////////////////////////////
2006-08-09 13:45:49 +00:00
/// functions
2006-05-02 06:00:35 +00:00
///////////////////////////////////
function hotpot_feedback_teachers ( & $course , & $hotpot ) {
2006-08-09 13:45:49 +00:00
global $CFG ;
2006-09-20 09:00:04 +00:00
$teachers = get_users_by_capability ( get_context_instance ( CONTEXT_COURSE , $course -> id ), 'mod/hotpot:grade' );
2006-08-09 13:45:49 +00:00
$teacherdetails = '' ;
if ( ! empty ( $teachers )) {
$details = array ();
foreach ( $teachers as $teacher ) {
if ( $hotpot -> studentfeedback == HOTPOT_FEEDBACK_MOODLEMESSAGING ) {
$detail = $teacher -> id ;
} else {
$detail = $teacher -> email ;
}
$details [] = " new Array(' " . fullname ( $teacher ) . " ', ' $detail ') " ;
}
$teacherdetails = 'new Array(' . implode ( ',' , $details ) . " ); \n " ;
}
return $teacherdetails ;
2006-05-02 06:00:35 +00:00
}
2009-11-01 15:03:10 +00:00