コード例 #1
0
ファイル: renderer.php プロジェクト: OctaveBabel/moodle-itop
 public function response_area_input($name, $qa, $step, $lines, $context)
 {
     global $USER;
     $usercontextid = context_user::instance($USER->id)->id;
     //prepare a draft file id for use
     list($draftitemid, $response) = $this->prepare_response_for_editing($name, $step, $context);
     //prepare the tags for our hidden( or shown ) input
     $inputname = $qa->get_qt_field_name($name);
     //$inputname="answer";
     $inputid = $inputname . '_id';
     //check of we already have a submitted answer. If so we need to set the filename
     //in our input field.
     $submittedfile = $this->get_submitted_file($name, $qa, $step, $context);
     if ($submittedfile) {
         $submittedfilename = strip_tags($submittedfile->get_filename());
     } else {
         $submittedfilename = "";
     }
     //our answerfield
     $ret = html_writer::empty_tag('input', array('type' => 'hidden', 'id' => $inputid, 'name' => $inputname, 'value' => $submittedfilename));
     //this is just for testing purposes so we can see the value the recorder is writing
     //$ret = $this->textarea($step->get_qt_var($name), $lines, array('name' => $inputname,'id'=>$inputid));
     //our answerfield draft id key
     $ret .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $inputname . ':itemid', 'value' => $draftitemid));
     //our answerformat
     $ret .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $inputname . 'format', 'value' => 1));
     //if we already have a response, lets display it so the student  can check/decide to rerecord
     if ($submittedfile) {
         $ret .= get_string('currentresponse', 'qtype_poodllrecording');
         $ret .= \filter_poodll\poodlltools::fetchSimpleAudioPlayer('auto', $qa->get_response_file_url($submittedfile), "http", 400, 25);
     }
     //get a handle on the question
     $q = $qa->get_question();
     //the context id is the user context for a student submission
     return $ret . \filter_poodll\poodlltools::fetchMP3RecorderForSubmission($inputid, $usercontextid, 'user', 'draft', $draftitemid, $q->timelimit);
 }
コード例 #2
0
ファイル: filter.php プロジェクト: OctaveBabel/moodle-itop
/**
 * Replace mp4 or flv links with player
 *
 * @param  $link
 * @return string
 */
function filter_poodll_mp4flv_callback($link)
{
    global $CFG;
    $lm = new \filter_poodll\licensemanager();
    if (!$lm->validate_registrationkey($CFG->filter_poodll_registrationkey)) {
        return $lm->fetch_unregistered_content();
    }
    //clean up url
    $url = $link[1];
    $url = str_replace('&', '&', $url);
    $url = clean_param($url, PARAM_URL);
    //use default widths or explicit width/heights if they were passed in ie http://url.to.video.mp4?d=640x480
    if (empty($link[3]) or empty($link[4])) {
        $width = $CFG->filter_poodll_videowidth;
        $height = $CFG->filter_poodll_videoheight;
    } else {
        $width = $link[3];
        $height = $link[4];
    }
    //get the url and massage it a little
    $url = $link[1];
    $rawurl = str_replace('&', '&', $url);
    //test for presence of player selectors and serve up the correct player
    //determine the file extension
    $ext = substr($link[5], -3);
    $len = strlen($link[5]);
    if (strrpos($link[5], '.mini.' . $ext) === $len - 9) {
        $returnHtml = \filter_poodll\poodlltools::fetch_miniplayer('auto', $rawurl, 'http', '', 0, 0, true);
    } else {
        if (strrpos($link[2], '.once.' . $ext) === $len - 9) {
            $returnHtml = \filter_poodll\poodlltools::fetch_onceplayer('auto', $rawurl, 'http');
        } elseif (strrpos($link[5], '.word.' . $ext) === $len - 9) {
            $word = substr($link[5], 0, $len - 9);
            $returnHtml = \filter_poodll\poodlltools::fetch_wordplayer('auto', $rawurl, $word, 0, 'http', 0, 0, true);
        } elseif (strrpos($link[5], '.audio.' . $ext) === $len - 10) {
            $returnHtml = \filter_poodll\poodlltools::fetchSimpleAudioPlayer('auto', $rawurl, 'http', $CFG->filter_poodll_audiowidth, $CFG->filter_poodll_audioheight, false, 'Play');
        } elseif (strrpos($link[5], '.inlineword.' . $ext) === $len - 15) {
            $word = substr($link[5], 0, $len - 15);
            $returnHtml = \filter_poodll\poodlltools::fetch_wordplayer('js', $rawurl, $word, 0, 'http', 0, 0, true);
        } else {
            $returnHtml = \filter_poodll\poodlltools::fetchSimpleVideoPlayer('auto', $url, $width, $height, 'http', false, true, 'Play');
        }
    }
    return $returnHtml;
}