Esempio n. 1
0
function voiceshadow_player($ids, $table = "voiceshadow_files")
{
    global $DB, $CFG, $voiceshadow_vc, $cm;
    //require_once($CFG->dirroot.'/filter/mediaplugin/filter.php');
    $player = new moodle_url("/mod/voiceshadow/js/flowplayer-3.2.7.swf");
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (!isset($voiceshadow_vc)) {
        $voiceshadow_vc = 0;
    }
    $voiceshadow_vc++;
    if ($data = $DB->get_record($table, array("id" => $ids))) {
        if ($data->itemid == 0) {
            /*
            * Show nanogong if wav and mp3 not ready
            */
            $o = "";
            if (!empty($data->itemoldid) && $CFG->voiceshadow_preplayer == 1) {
                if ($item = $DB->get_record("files", array("id" => $data->itemoldid))) {
                    if ($item->mimetype == 'audio/wav') {
                        $link = new moodle_url("/pluginfile.php/" . $item->contextid . "/mod_voiceshadow/" . $ids . "/" . $data->itemoldid . "/" . $item->filename);
                        $o .= html_writer::start_tag("div");
                        $o .= html_writer::start_tag("applet", array("id" => "nanogong", "archive" => "nanogong.jar", "code" => "gong.NanoGong", "width" => "180", "height" => "40"));
                        $o .= html_writer::empty_tag("param", array("name" => "Color", "value" => "#ffffff"));
                        $o .= html_writer::empty_tag("param", array("name" => "AudioFormat", "value" => "ImaADPCM"));
                        $o .= html_writer::empty_tag("param", array("name" => "ShowRecordButton", "value" => "false"));
                        $o .= html_writer::empty_tag("param", array("name" => "ShowAudioLevel", "value" => "false"));
                        $o .= html_writer::empty_tag("param", array("name" => "SoundFileURL", "value" => $link));
                        $o .= html_writer::end_tag('applet');
                        $o .= html_writer::end_tag('div');
                    }
                }
            }
            if ($table != "voiceshadow_comments") {
                if (!$DB->get_record("voiceshadow_process", array("itemid" => $data->itemoldid))) {
                    return get_string('pleaseerrorinprocess', 'voiceshadow') . $o;
                } else {
                    return get_string('pleasewaitinprocess', 'voiceshadow') . $o;
                }
            } else {
                return "";
            }
        } else {
            if ($item = $DB->get_record("files", array("id" => $data->itemid))) {
                //$f = get_file_storage();
                //$file = $f->get_file_instance($item);
                $link = new moodle_url("/pluginfile.php/" . $item->contextid . "/mod_voiceshadow/" . $ids . "/" . $data->itemid . "/" . $item->filename);
                if (voiceshadow_is_ios() || voiceshadow_get_browser() == 'chrome' || voiceshadow_get_browser() == 'android') {
                    if (in_array($item->mimetype, json_decode(VOICESHADOW_AUDIOTYPES))) {
                        $o = "";
                        $o .= html_writer::start_tag('div', array("id" => "html5-player-" . $ids));
                        $o .= html_writer::start_tag('audio', array("id" => "html5-audioplayer-" . $ids, "controls" => "controls", "src" => $link, "oncanplay" => "this.volume=0.5"));
                        $o .= html_writer::link($link, get_string("audio", "voiceshadow"));
                        $o .= html_writer::end_tag('audio');
                        $o .= html_writer::end_tag('div');
                    } else {
                        if (in_array($item->mimetype, json_decode(VOICESHADOW_VIDEOTYPES))) {
                            $itemimg = $DB->get_record("files", array("id" => $data->itemimgid));
                            $linkimg = new moodle_url("/pluginfile.php/" . $itemimg->contextid . "/mod_voiceshadow/" . $ids . "/" . $data->itemimgid);
                            $o = "";
                            $o .= html_writer::start_tag('div', array("id" => "html5-player-" . $ids));
                            $o .= html_writer::start_tag('video', array("id" => "html5-videoplayer-" . $ids, "controls" => "controls", "src" => $link, "poster" => $linkimg));
                            $o .= html_writer::link($link, get_string("video", "voiceshadow"));
                            $o .= html_writer::end_tag('video');
                            $o .= html_writer::end_tag('div');
                        }
                    }
                } else {
                    if (in_array($item->mimetype, json_decode(VOICESHADOW_AUDIOTYPES))) {
                        $o = "";
                        $o .= html_writer::script('var fn = function() {var att = { data:"' . new moodle_url("/mod/voiceshadow/js/mp3player.swf") . '", width:"90", height:"15" };var par = { flashvars:"src=' . $link . '" };var id = "audio_' . $ids . '_' . $voiceshadow_vc . '";var myObject = swfobject.createSWF(att, par, id);};swfobject.addDomLoadEvent(fn);');
                        $o .= '<div id="audio_' . $ids . '_' . $voiceshadow_vc . '"><a href="' . $link . '">audio</a></div>';
                    } else {
                        if (in_array($item->mimetype, json_decode(VOICESHADOW_VIDEOTYPES))) {
                            $itemimg = $DB->get_record("files", array("id" => $data->itemimgid));
                            $linkimg = new moodle_url("/pluginfile.php/" . $itemimg->contextid . "/mod_voiceshadow/" . $ids . "/" . $data->itemimgid);
                            $o = "";
                            $o .= html_writer::start_tag('a', array("id" => "player_{$ids}_{$voiceshadow_vc}", "style" => "display:block;width:425px;height:240px;background: url('" . $linkimg . "') no-repeat 0 0;", "href" => $link));
                            $o .= html_writer::empty_tag('img', array("src" => new moodle_url("/mod/voiceshadow/img/playlayer.png"), "alt" => get_string("video", "voiceshadow"), "width" => 425, "height" => 240));
                            $o .= html_writer::end_tag('a');
                            $o .= html_writer::script('flowplayer("player_' . $ids . '_' . $voiceshadow_vc . '", "' . $player . '");');
                        }
                    }
                }
            }
        }
    }
    return $o;
}
Esempio n. 2
0
        function definition()
        {
            global $CFG, $USER, $DB, $course, $fileid, $id, $act, $commentid, $voiceshadow;
            $time = time();
            $filename = str_replace(" ", "_", $USER->username) . "_" . date("Ymd_Hi", $time);
            $mform =& $this->_form;
            $mform->disable_form_change_checker();
            //-----Speech to text plugin----------------//
            if ($voiceshadow->speechtotext == 1 && voiceshadow_get_browser() == 'chrome') {
                $mform->addElement('html', '<div id="foo"> <div class="p-header k" style="padding: 0px 0px 4px; margin: 0px;"> <table cellpadding="0" class="cf Ht"><tbody><tr id=":2jc"><td><div id=":2k1" class="Hp"><div class="aYF" style="width:152px">Use speech to text&lrm;</div></div></td><td class="Hm"><img class="Hl" id=":256" src="img/cleardot.gif"><img class="Hq" id=":257" src="img/cleardot.gif"></td></tr></tbody></table> </div><div class="p-content"> <div style="width: 100%;background-color: #fff;"> <div style="margin:0;width:280px;"> <div style="float:left;width: 120px;margin: 10px 20px 0 0;"><button type="button" style="width: 134px;" id="p-start-record">Start transcribing</button></div><div style="float:left;width: 120px;font-size: 60%;padding: 3px;" class="" id="p-rec-notice">Click "Start transcribing" button when you are ready.</div><div style="clear:both;"></div></div><textarea id="speechtext" style="width: 250px;height: 180px;margin: 0 0 0 8px;"></textarea> <div style="margin:10px 0 0 10px;width:260px;"> <div style="float:left;width: 120px;margin: 0 20px 0 0;"><button type="button" style="width: 120px;" id="p-speech-text">Speak it!</button></div><div style="float:left;width: 120px;"><button type="button" style="width: 120px;" id="p-clear-text">Clear text</button></div><div style="clear:both;"></div></div></div></div></div>');
            }
            //--------------Checking Embed code---------//
            if (!empty($voiceshadow->embedvideo)) {
                $mform->addElement('header', 'Embed', get_string('embedcode', 'voiceshadow'));
                $mform->addElement('static', 'description', '', $voiceshadow->embedvideo);
            }
            //------------------------------------------//
            //--------------Uploadd MP3 ----------------//
            //if (!voiceshadow_is_ios() && voiceshadow_get_browser() != 'android') {
            if (!voiceshadow_is_ios()) {
                $filepickeroptions = array();
                //$filepickeroptions['filetypes'] = array('.mp3','.mov','.mp4','.m4a');
                $filepickeroptions['maxbytes'] = get_max_upload_file_size($voiceshadow->maxbytes);
                $mform->addElement('header', 'mp3upload', get_string('mp3upload', 'voiceshadow'));
                $mform->addElement('filepicker', 'submitfile', get_string('uploadmp3', 'voiceshadow'), null, $filepickeroptions);
            }
            //-------------- Listen to recorded audio ----------------//
            $mform->addElement('header', 'listentorecordedaudio', get_string('listentorecordedaudio', 'voiceshadow'));
            for ($i = 1; $i <= 5; $i++) {
                $name = "var{$i}";
                $nametext = "var{$i}text";
                if (!empty($voiceshadow->{$name})) {
                    if ($item = $DB->get_record("files", array("id" => $voiceshadow->{$name}))) {
                        $link = new moodle_url("/mod/voiceshadow/file.php?file=" . $voiceshadow->{$name});
                        if (!isset($linkhtml5mp3)) {
                            $linkhtml5mp3 = $link;
                        }
                        if ($i == 1) {
                            $checked = 'checked="checked"';
                        } else {
                            $checked = '';
                        }
                        $o = '<div style="margin:10px 0">';
                        if (voiceshadow_is_ios() || voiceshadow_get_browser() == 'chrome' || voiceshadow_get_browser() == 'android') {
                            $o .= '<div><audio src="' . $link . '" controls="controls"><a href="' . $link . '">audio</a></audio></div>';
                        } else {
                            $o .= html_writer::script('var fn = function() {var att = { data:"' . new moodle_url("/mod/voiceshadow/js/mp3player.swf") . '", width:"90", height:"15" };var par = { flashvars:"src=' . $link . '" };var id = "audios_' . $voiceshadow->{$name} . '";var myObject = swfobject.createSWF(att, par, id);};swfobject.addDomLoadEvent(fn);');
                            $o .= '<div><div id="audios_' . $voiceshadow->{$name} . '"><a href="' . $link . '">audio</a></div></div>';
                        }
                        $o .= '</div>';
                        $mform->addElement('static', 'description', '', $o);
                    }
                }
            }
            //-------------- END -------------------------------------//
            //-------------- Record ----------------//
            $mediadata = "";
            if (voiceshadow_is_ios()) {
                // || voiceshadow_get_browser() == 'android'
                $mediadata .= html_writer::start_tag("h3", array("style" => "padding: 0 20px;"));
                $mediadata .= html_writer::start_tag("a", array("href" => 'voiceshadow://?link=' . $CFG->wwwroot . '&id=' . $id . '&uid=' . $USER->id . '&time=' . $time . '&var=1&type=voiceshadow', "id" => "id_recoring_link", "onclick" => 'formsubmit(this.href)'));
                //voiceshadow://?link='.$CFG->wwwroot.'&id='.$id.'&cid='.$course->id.'&filename='.$filename.'&type=audio
                $mediadata .= get_string('recordvoice', 'voiceshadow');
                $mediadata .= html_writer::end_tag('a');
                $mediadata .= html_writer::end_tag('h3');
                $mediadata .= html_writer::script('function formsubmit(link) {$(\'input[name=iphonelink]\').val(link);$(\'#mform1\').submit();}');
            } else {
                if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE && voiceshadow_get_browser() == 'android') {
                    $mediadata .= '

  <div style="font-size: 21px;line-height: 40px;color: #333;">Record</div>

  <button onclick="startRecording(this);" id="btn_rec" disabled>record</button>
  <button onclick="stopRecording(this);" id="btn_stop" disabled>stop</button>
  
  <div style="font-size: 21px;line-height: 40px;color: #333;">Recordings</div>
  <ul id="recordingslist" style="list-style-type: none;"></ul>
  
  <div style="font-size: 21px;line-height: 40px;color: #333;display:none;">Log</div>
  <pre id="log" style="display:none"></pre>

  <script>
  
  $(".selectaudiomodel").click(function(){
    $("#audioshadowmp3").attr("src", $(this).parent().find("audio").attr("src"));
    __log($(this).parent().find("audio").attr("src"));
  });
  
  function __log(e, data) {
    log.innerHTML += "\\n" + e + " " + (data || \'\');
  }

  var audio_context;
  var recorder;

  function startUserMedia(stream) {
    var input = audio_context.createMediaStreamSource(stream);
    __log(\'Media stream created.\' );
    __log("input sample rate " +input.context.sampleRate);
    
    //input.connect(audio_context.destination);
    //__log(\'Input connected to audio context destination.\');
    
    recorder = new Recorder(input);
    __log(\'Recorder initialised.\');
  }

  function startRecording(button) {
    recorder && recorder.record();
    button.disabled = true;
    button.nextElementSibling.disabled = false;
    __log(\'Recording...\');
  }

  function stopRecording(button) {
    recorder && recorder.stop();
    button.disabled = true;
    button.previousElementSibling.disabled = false;
    __log(\'Stopped recording.\');
    
    // create WAV download link using audio data blob
    createDownloadLink();
    
    recorder.clear();
  }

  function createDownloadLink() {
    recorder && recorder.exportWAV(function(blob) {
    });
  }

  window.onload = function init() {
    try {
      // webkit shim
      window.AudioContext = window.AudioContext || window.webkitAudioContext;
      navigator.getUserMedia = ( navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);
      window.URL = window.URL || window.webkitURL;
      
      audio_context = new AudioContext;
      __log(\'Audio context set up.\');
      __log(\'navigator.getUserMedia \' + (navigator.getUserMedia ? \'available.\' : \'not present!\'));
    } catch (e) {
      alert(\'No web audio support in this browser!\');
    }
    
    navigator.getUserMedia({audio: true}, startUserMedia, function(e) {
      __log(\'No live audio input: \' + e);
    });
  };

  function jInit(){
      audio = $("#audioshadowmp3");
      addEventHandlers();
  }

  function addEventHandlers(){
      $("#btn_rec").click(startAudio);
      $("#btn_stop").click(stopAudio);
  }

  function loadAudio(){
      audio.bind("load",function(){
        __log(\'MP3 Audio Loaded succesfully\');
        $(\'#btn_rec\').removeAttr( "disabled" );
      });
      audio.trigger(\'load\');
      //startAudio()
  }
  
  function startAudio(){
      __log(\'MP3 Audio Play\');
      audio.trigger(\'play\');
  }

  function pauseAudio(){
      __log(\'MP3 Audio Pause\');
      audio.trigger(\'pause\');
  }

  function stopAudio(){
      pauseAudio();
      audio.prop("currentTime",0);
  }

  function forwardAudio(){
      pauseAudio();
      audio.prop("currentTime",audio.prop("currentTime")+5);
      startAudio();
  }

  function backAudio(){
      pauseAudio();
      audio.prop("currentTime",audio.prop("currentTime")-5);
      startAudio();
  }

  function volumeUp(){
      var volume = audio.prop("volume")+0.2;
      if(volume >1){
        volume = 1;
      }
      audio.prop("volume",volume);
  }

  function volumeDown(){
      var volume = audio.prop("volume")-0.2;
      if(volume <0){
        volume = 0;
      }
      audio.prop("volume",volume);
  }

  function toggleMuteAudio(){
      audio.prop("muted",!audio.prop("muted"));
  }
  
  $( document ).ready(function() {
     jInit();
     loadAudio();
     
     $("#id_Recording").find(".fitemtitle").append(\'<img src="img/spiffygif_30x30.gif" style="display:none;" id="html5-mp3-loader"/>\');
  });
</script>
  
  <audio src="' . $linkhtml5mp3 . '" id="audioshadowmp3" autobuffer="autobuffer" data-url="' . urlencode(json_encode(array("id" => $id, "userid" => $USER->id))) . '"></audio>
                  ';
                } else {
                    $filename = str_replace(" ", "_", $USER->username) . "_" . date("Ymd_Hi", $time);
                    /*$mediadata  = html_writer::script('var fn = function() {var att = { data:"'.(new moodle_url("/mod/voiceshadow/js/recorder.swf")).'", width:"350", height:"200"};var par = { flashvars:"rate=44&gain=50&prefdevice=&loopback=no&echosupression=yes&silencelevel=0&updatecontrol=poodll_recorded_file&callbackjs=poodllcallback&posturl='.(new moodle_url("/mod/voiceshadow/uploadmp3.php")).'&p1='.$id.'&p2='.$USER->id.'&p3="+$(\'#id_submitfile\').attr(\'value\')+"&p4='.$filename.'&autosubmit=true&debug=false&lzproxied=false" };var id = "mp3_flash_recorder";var myObject = swfobject.createSWF(att, par, id);};swfobject.addDomLoadEvent(fn);');
                      $mediadata .= '<div id="mp3_flash_recorder"></div><input name="poodll_recorded_file" type="hidden" value="" id="poodll_recorded_file" />';*/
                    /*echo html_writer::script('
                    function poodllcallback(args){
                    	console.log ("poodllcallback:" + args[0] + ":" + args[1] + ":" + args[2] + ":" + args[3] + ":" + args[4]);
                    }
                    ');*/
                    /*
                    if ($voiceshadow->speechtotext == 1){
                      $speechcode = 'flashvars.speech = "'.urlencode("http://netcourse.org/pr/flashrecorder/speechtotext.php").'";';
                      $speechcallbackcode = '<div style="margin-bottom: 10px;width: 275px;padding: 10px;border: 1px dashed #666;background-color: #eeefff;">\'+e.text+\'</div>';
                    } else {
                    */
                    $speechcode = "";
                    $speechcallbackcode = '';
                    //}
                    $mediadata = html_writer::script('var flashvars={};flashvars.gain=35;flashvars.rate=44;flashvars.call="callbackjs";flashvars.name = "' . $filename . '";flashvars.p = "' . urlencode(json_encode(array("id" => $id, "userid" => $USER->id))) . '";flashvars.url = "' . urlencode(new moodle_url("/mod/voiceshadow/uploadmp3.php")) . '";' . $speechcode . 'swfobject.embedSWF("' . new moodle_url("/mod/voiceshadow/js/recorder.swf") . '", "mp3_flash_recorder", "220", "200", "9.0.0", "expressInstall.swf", flashvars);');
                    $mediadata .= '<div id="mp3_flash_recorder"></div><div id="mp3_flash_records" style="margin:20px 0;"></div>';
                    /*
                    * Safari fix
                    */
                    if (voiceshadow_get_browser() == 'safari') {
                        $preplayer = '<embed xmlns="http://www.w3.org/1999/xhtml" align="" allowFullScreen="false" flashvars="src=' . $CFG->wwwroot . '\'+obj.url+\'" height="15" width="90" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="' . new moodle_url("/mod/voiceshadow/js/mp3player.swf") . '" type="application/x-shockwave-flash" />';
                    } else {
                        $preplayer = '<audio controls id="peviewaudio" oncanplay="this.volume=1"><source src="' . $CFG->wwwroot . '\'+obj.url+\'" preload="auto" type="audio/mpeg"></audio>';
                    }
                    echo html_writer::script('
function chooserecord(e){
  $(".choosingrecord").html(\'<img src="' . new moodle_url("/mod/voiceshadow/img/right-arrow-gray.png") . '" style="margin-top: 6px;"/>\');
  $(e).html(\'<img src="' . new moodle_url("/mod/voiceshadow/img/right-arrow.png") . '" style="margin-top: 6px;"/>\');
  $("#id_submitfile").val($(e).attr("data-url"));
  $("#id_speechtext").val($(e).attr("data-text"));
}
function callbackjs(e){
  /*
  * Speech to text box stop
  */
  if ($(".p-content").length > 0) {
    recognition.stop();
    window.recordmark = 0;
    var stext = $("#speechtext").val();
    $("#speechtext").val("");
  } else 
    var stext = "";
  

  $("#id_speechtext").val(""+stext+"");
  $(".choosingrecord").html(\'<img src="' . new moodle_url("/mod/voiceshadow/img/right-arrow-gray.png") . '" style="margin-top: 6px;"/>\');
  obj = JSON.parse(e.data);
  
  $("#mp3_flash_records").prepend(\'<div class="recordings"><div class="choosingrecord" style="float:left;cursor: pointer;" data-url="\'+obj.id+\'" data-text="\'+stext+\'" onclick="chooserecord(this)"><img src="' . new moodle_url("/mod/voiceshadow/img/right-arrow.png") . '" style="margin-top: 6px;"/></div><div style="float:left;"><div>' . $preplayer . '</div><div style="margin-bottom: 10px;width: 275px;padding: 10px;border: 1px dashed #666;background-color: #eeefff;">\'+stext+\'</div></div><div style="clear:both;"></div></div>\');
  $("#id_submitfile").val(obj.id);

  if($("#mp3_flash_records > div").size() >= ' . ($voiceshadow->allowmultiple + 1) . ') {
    $("#mp3_flash_records > div").last().remove();
  }
  
}
');
                }
            }
            $mform->addElement('header', 'Recording', get_string('recordvoice', 'voiceshadow'));
            //Audio listen-record
            for ($i = 1; $i <= 5; $i++) {
                $name = "var{$i}";
                $nametext = "var{$i}text";
                if (!empty($voiceshadow->{$name})) {
                    if ($item = $DB->get_record("files", array("id" => $voiceshadow->{$name}))) {
                        $link = new moodle_url("/mod/voiceshadow/file.php?file=" . $voiceshadow->{$name});
                        if (!isset($linkhtml5mp3)) {
                            $linkhtml5mp3 = $link;
                        }
                        if ($i == 1) {
                            $checked = 'checked="checked"';
                        } else {
                            $checked = '';
                        }
                        $o = '<div style="margin:10px 0">
                      <input type="radio" name="selectaudiomodel" value="' . $i . '" class="selectaudiomodel" id="id_selectaudiomodel_' . $i . '" style="float: left;margin: 0 20px 0 0;" ' . $checked . ' data-url="voiceshadow://?link=' . $CFG->wwwroot . '&id=' . $id . '&uid=' . $USER->id . '&time=' . $time . '&var=' . $i . '&type=voiceshadow" />
                      ';
                        if (voiceshadow_is_ios() || voiceshadow_get_browser() == 'chrome' || voiceshadow_get_browser() == 'android') {
                            $o .= '<div style="float:left;"><audio src="' . $link . '" id="audio_' . $voiceshadow->{$name} . '" controls="controls" class="startSST"><a href="' . $link . '">audio</a></audio></div><label for="id_selectaudiomodel_' . $i . '" style="float: left;margin-left: 20px;font-size: 15px;">' . $voiceshadow->{$nametext} . '</label><div style="clear:both;"></div>';
                        } else {
                            $o .= html_writer::script('var fn = function() {var att = { data:"' . new moodle_url("/mod/voiceshadow/js/mp3player.swf") . '", width:"90", height:"15" };var par = { flashvars:"src=' . $link . '" };var id = "audio_' . $voiceshadow->{$name} . '";var myObject = swfobject.createSWF(att, par, id);};swfobject.addDomLoadEvent(fn);');
                            $o .= '<div style="float:left;"><div id="audio_' . $voiceshadow->{$name} . '"><a href="' . $link . '">audio</a></div></div><label for="id_selectaudiomodel_' . $i . '" style="float: left;margin-left: 20px;font-size: 15px;">' . $voiceshadow->{$nametext} . '</label><div style="clear:both;"></div>';
                        }
                        if (!empty($voiceshadow->{"var" . $i . "transcript"}) && $voiceshadow->showscore == 1) {
                            $o .= '<div id="transcript_' . $i . '">' . $voiceshadow->{"var" . $i . "transcript"} . '</div>';
                        }
                        $o .= '</div>';
                        $mform->addElement('static', 'description', '', $o);
                    }
                }
            }
            //----
            $mform->addelEment('hidden', 'filename', $filename);
            $mform->addelEment('hidden', 'iphonelink', '');
            $mform->addElement('static', 'description', '', $mediadata);
            if (!empty($fileid) && empty($act)) {
                $mform->setDefault("filename", $data->filename);
                $mform->addelEment('hidden', 'fileid', $fileid);
            }
            if (!empty($act)) {
                $mform->addelEment('hidden', 'act', $act);
                $mform->addelEment('hidden', 'fileid', $fileid);
            } else {
                $mform->addelEment('hidden', 'act', 'newinstance');
            }
            if ($voiceshadow->speechtotext == 1) {
                $mform->addelEment('hidden', 'speechtext', 'null', array('id' => 'id_speechtext'));
            }
            //-------------- Record -------END------//
            $mform->addElement('header', 'addcomment', get_string('addcomment', 'voiceshadow'));
            if (!empty($fileid) && empty($act)) {
                $data = $DB->get_record("voiceshadow_files", array("id" => $fileid, "userid" => $USER->id));
                $mform->addElement('editor', 'summary', '')->setValue(array('text' => $data->summary));
            } else {
                if (!empty($act) && !empty($commentid)) {
                    $data = $DB->get_record("voiceshadow_comments", array("id" => $commentid, "userid" => $USER->id));
                    $mform->addElement('editor', 'summary', '')->setValue(array('text' => $data->summary));
                    $mform->addelEment('hidden', 'commentid', $commentid);
                } else {
                    $mform->addElement('editor', 'summary', '');
                }
            }
            $mform->addElement('html', '<script language="JavaScript">
            $(document).ready(function() {
              $(".selectaudiomodel").click(function(){
                $("#id_recoring_link").attr("href", $(this).attr("data-url"));
              });
            });
            </script>');
            //$mform->addelEment('hidden', 'instanceid', $id);
            //$mform->addRule('summary', null, 'required', null, 'client');
            $this->add_action_buttons(false, $submitlabel = get_string("saverecording", "voiceshadow"));
        }