public function response_area_input($name, $qa, $step, $lines, $context)
 {
     global $USER;
     $usercontextid = get_context_instance(CONTEXT_USER, $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';
     //our answerfield
     $ret = html_writer::empty_tag('input', array('type' => 'hidden', 'id' => $inputid, 'name' => $inputname));
     //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));
     //the context id $context->id here is wrong, so we just use "5" because it works, why is it wrong ..? J 20120214
     return $ret . fetchAudioRecorderForSubmission('swf', 'question', $inputid, $usercontextid, 'user', 'draft', $draftitemid);
     return $ret;
 }
Exemple #2
0
 public function fetch_recorder()
 {
     global $USER, $CFG;
     $ret = "";
     //we get necessary info
     $context = context_user::instance($USER->id);
     $filename = 'filename' . '_' . $this->options['recording_format'];
     //HTML5 Recording and Uploading audio/video
     if (isMobile($CFG->filter_poodll_html5rec) && ($this->options['recording_format'] == self::POODLLAUDIO || $this->options['recording_format'] == self::MP3AUDIO || $this->options['recording_format'] == self::POODLLVIDEO)) {
         switch ($this->options['recording_format']) {
             case self::POODLLVIDEO:
                 //we load up the file upload HTML5
                 $ret .= fetch_HTML5RecorderForSubmission($filename, $context->id, "user", "draft", "0", "video", true);
                 break;
             case self::POODLLAUDIO:
             case self::MP3AUDIO:
                 //we load up the file upload HTML5
                 $ret .= fetch_HTML5RecorderForSubmission($filename, $context->id, "user", "draft", "0", "audio", true);
                 break;
         }
         //end of switch
         //we need a dummy M object so we can reuse module js here
         $ret .= "<script type='text/javascript'>";
         $ret .= "var M = new Object();";
         $ret .= "</script>";
         //we load the poodll filter module JS for the HTML5 recording logic
         $ret .= "<script type=\"text/javascript\" src=\"{$CFG->wwwroot}/filter/poodll/module.js\"></script> ";
         //this calls the script we loaded just above, after we have a fileupload area to attach events to
         $ret .= "<script type='text/javascript'>";
         $ret .= "M.filter_poodll.loadmobileupload(0,0);";
         $ret .= "</script>";
         echo $ret;
         return;
     }
     //end of if is mobile
     //HTML5 WIdgets and Uploading Images
     if (isMobile($CFG->filter_poodll_html5widgets) && ($this->options['recording_format'] == self::POODLLWHITEBOARD || $this->options['recording_format'] == self::POODLLSNAPSHOT)) {
         //we load up the file upload HTML5
         $ret .= fetch_HTML5RecorderForSubmission($filename, $context->id, "user", "draft", "0", "image", true);
         //we need a dummy M object so we can reuse module js here
         $ret .= "<script type='text/javascript'>";
         $ret .= "var M = new Object();";
         $ret .= "</script>";
         //we load the poodll filter module JS for the HTML5 recording logic
         $ret .= "<script type=\"text/javascript\" src=\"{$CFG->wwwroot}/filter/poodll/module.js\"></script> ";
         //this calls the script we loaded just above, after we have a fileupload area to attach events to
         $ret .= "<script type='text/javascript'>";
         $ret .= "M.filter_poodll.loadmobileupload(0,0);";
         $ret .= "</script>";
         echo $ret;
         return;
     }
     //   $usercontextid = get_context_instance(CONTEXT_USER, $USER->id)->id;
     //	$draftitemid=0;
     //	$ret .= '<form name="poodll_repository" action="' . $CFG->wwwroot . '/repository/poodll/recorder.php">';
     //	$filename = 'filename' . '_' . $this->options['recording_format'] ;
     switch ($this->options['recording_format']) {
         case self::POODLLAUDIO:
             //$ret .= fetchSimpleAudioRecorder('swf','poodllrepository',$USER->id,$filename);
             $ret .= fetchAudioRecorderForSubmission('auto', 'poodllrepository', $filename, $context->id, 'user', 'draft', 0, 0);
             break;
         case self::POODLLVIDEO:
             //$ret .= fetchSimpleVideoRecorder('swf','poodllrepository',$USER->id,$filename,'','298', '340');
             $ret .= fetchVideoRecorderForSubmission('swf', 'poodllrepository', $filename, $context->id, 'user', 'draft', 0, 0);
             break;
         case self::MP3AUDIO:
             //this is the mp3 recorder, by Paul Nichols
             //$ret = $this->fetchMP3PostRecorder("filename","apic.jpg", '290','340');
             //$ret = fetchMP3RecorderForRepo("filename");
             $ret .= fetchMP3RecorderForSubmission($filename, $context->id, "user", "draft", "0");
             break;
         case self::POODLLWHITEBOARD:
             $ret .= fetchWhiteboardForSubmission($filename, $context->id, "user", "draft", "0", 305, 350, "", "poodll");
             break;
         case self::POODLLSNAPSHOT:
             $ret .= fetchSnapshotCameraForSubmission($filename, "apic.jpg", '290', '340', $context->id, "user", "draft", "0");
             break;
     }
     echo $ret;
 }
Exemple #3
0
 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';
     //our answerfield
     $ret = html_writer::empty_tag('input', array('type' => 'hidden', 'id' => $inputid, 'name' => $inputname));
     //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 so the student  can check/decide to rerecord
     $currentresponse = $this->response_area_read_only($name, $qa, $step, $lines, $context);
     if (!empty($currentresponse)) {
         $ret .= get_string('currentresponse', 'qtype_poodllrecording');
         $ret .= $currentresponse;
     }
     //get a handle on the question
     $q = $qa->get_question();
     //the context id is the user context for a student submission
     return $ret . fetchAudioRecorderForSubmission('swf', 'question', $inputid, $usercontextid, 'user', 'draft', $draftitemid, $q->timelimit);
 }
 function definition()
 {
     global $USER;
     $mform =& $this->_form;
     $draftitemid = file_get_submitted_draft_itemid(FILENAMECONTROL);
     $contextid = $this->_customdata['editoroptions']['context']->id;
     $submissionid = $this->_customdata['data']->sid;
     file_prepare_draft_area($draftitemid, $contextid, 'mod_assignment', 'submission', $submissionid, null, null);
     $usercontextid = context_user::instance($USER->id)->id;
     $mform->addElement('hidden', 'draftitemid', $draftitemid);
     $mform->addElement('hidden', 'usercontextid', $usercontextid);
     //timelimit
     //we have not enabled this for 2.3 assignment
     $timelimit = 0;
     //Do we need audio or text? or both?
     //the customdata is info we passed in up around line 175 in the view method.
     switch ($this->_customdata['assignment']->var3) {
         case OM_REPLYVOICEONLY:
             //$mediadata= fetchSimpleAudioRecorder('onlinemedia' . $this->_customdata['cm']->id , $USER->id);
             //$mediadata= fetchSimpleAudioRecorder('assignment/' . $this->_customdata['assignment']->id , $USER->id);
             $mediadata = fetchAudioRecorderForSubmission('swf', 'poodllonline', FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OM_REPLYMP3VOICE:
             //$mediadata= fetchSimpleAudioRecorder('onlinemedia' . $this->_customdata['cm']->id , $USER->id);
             //$mediadata= fetchSimpleAudioRecorder('assignment/' . $this->_customdata['assignment']->id , $USER->id);
             $mediadata = fetchMP3RecorderForSubmission(FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OM_REPLYWHITEBOARD:
             //$mediadata= fetchSimpleAudioRecorder('onlinemedia' . $this->_customdata['cm']->id , $USER->id);
             //$mediadata= fetchSimpleAudioRecorder('assignment/' . $this->_customdata['assignment']->id , $USER->id);
             $mediadata = fetchWhiteboardForSubmission(FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OM_REPLYVIDEOONLY:
             $mediadata = fetchVideoRecorderForSubmission('swf', 'poodllonline', FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OM_REPLYVOICETHENTEXT:
             //if we have no audio, we force user to make audio before text
             if (empty($this->_customdata['mediapath'])) {
                 $mediadata = fetchAudioRecorderForSubmission('swf', 'poodllonline', FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
                 $mform->addElement('static', 'description', '', $mediadata);
             }
             break;
         case OM_REPLYVIDEOTHENTEXT:
             //if we have no video, we force user to make video before text
             if (empty($this->_customdata['mediapath'])) {
                 $mediadata = fetchVideoRecorderForSubmission('swf', 'poodllonline', FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
                 $mform->addElement('static', 'description', '', $mediadata);
             }
             break;
     }
     //If we are recording text, and we do not need torecord media first
     //We display the text box
     switch ($this->_customdata['assignment']->var3) {
         case OM_REPLYVIDEOTHENTEXT:
         case OM_REPLYVOICETHENTEXT:
             if (empty($this->_customdata['mediapath'])) {
                 break;
             }
         case OM_REPLYVOICEONLY:
         case OM_REPLYVIDEOONLY:
         case OM_REPLYTALKBACK:
         case OM_REPLYWHITEBOARD:
         case OM_REPLYMP3VOICE:
             //We do not need a text box
             break;
         case OM_REPLYTEXTONLY:
         default:
             $mediadata = "";
             // visible elements
             //$mform->addElement('editor', 'text', get_string('submission', 'assignment'), array('cols'=>85, 'rows'=>30));
             $mform->addElement('editor', 'text_editor', get_string('submission', 'assignment'), null, $this->_customdata['editoroptions']);
             //$mform->addElement('editor', 'text', get_string('submission', 'assignment'));
             $mform->setType('text_editor', PARAM_RAW);
             // to be cleaned before display
             $mform->addRule('text_editor', get_string('required'), 'required', null, 'client');
     }
     // hidden params
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
     // buttons
     $this->add_action_buttons();
     $this->set_data($this->_customdata['data']);
 }
Exemple #5
0
 /**
  * Add form elements onlinepoodll submissions
  *
  * @param mixed $submission can be null
  * @param MoodleQuickForm $mform
  * @param stdClass $data
  * @return true if elements were added to the form
  */
 public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data)
 {
     global $CFG, $USER;
     $elements = array();
     $submissionid = $submission ? $submission->id : 0;
     if ($submission && get_config('assignsubmission_onlinepoodll', 'showcurrentsubmission')) {
         $onlinepoodllsubmission = $this->get_onlinepoodll_submission($submission->id);
         $size = get_config('assignsubmission_onlinepoodll', 'displaysize_single');
         //show the previous submission in a player or whatever
         $mform->addElement('static', 'currentsubmission', get_string('currentsubmission', 'assignsubmission_onlinepoodll'), $this->fetchResponses($submission->id, false, false));
     }
     //We prepare our form here and fetch/save data in SAVE method
     $usercontextid = context_user::instance($USER->id)->id;
     $draftitemid = file_get_submitted_draft_itemid(OP_FILENAMECONTROL);
     $contextid = $this->assignment->get_context()->id;
     file_prepare_draft_area($draftitemid, $contextid, ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT, ASSIGNSUBMISSION_ONLINEPOODLL_FILEAREA, $submissionid, null, null);
     $mform->addElement('hidden', 'draftitemid', $draftitemid);
     $mform->addElement('hidden', 'usercontextid', $usercontextid);
     $mform->addElement('hidden', OP_FILENAMECONTROL, '', array('id' => OP_FILENAMECONTROL));
     $mform->setType('draftitemid', PARAM_INT);
     $mform->setType('usercontextid', PARAM_INT);
     $mform->setType(OP_FILENAMECONTROL, PARAM_TEXT);
     //get timelimit for recorders if set
     $timelimit = $this->get_config('timelimit');
     //fetch the required "recorder
     switch ($this->get_config('recordertype')) {
         case OP_REPLYVOICE:
             $mediadata = fetchAudioRecorderForSubmission('swf', 'onlinepoodll', OP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OP_REPLYMP3VOICE:
             $mediadata = fetchMP3RecorderForSubmission(OP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OP_REPLYWHITEBOARD:
             //get board sizes
             switch ($this->get_config('boardsize')) {
                 case "320x320":
                     $width = 320;
                     $height = 320;
                     break;
                 case "400x600":
                     $width = 400;
                     $height = 600;
                     break;
                 case "500x500":
                     $width = 500;
                     $height = 500;
                     break;
                 case "600x400":
                     $width = 600;
                     $height = 400;
                     break;
                 case "600x800":
                     $width = 600;
                     $height = 800;
                     break;
                 case "800x600":
                     $width = 800;
                     $height = 600;
                     break;
             }
             //Get Backimage, if we have one
             // get file system handle for fetching url to submitted media prompt (if there is one)
             $fs = get_file_storage();
             $itemid = 0;
             $files = $fs->get_area_files($contextid, ASSIGNSUBMISSION_ONLINEPOODLL_CONFIG_COMPONENT, ASSIGNSUBMISSION_ONLINEPOODLL_WB_FILEAREA, $itemid);
             $imageurl = "";
             if ($files && count($files) > 0) {
                 $file = array_pop($files);
                 $imageurl = file_rewrite_pluginfile_urls('@@PLUGINFILE@@/' . $file->get_filename(), 'pluginfile.php', $file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid());
             }
             $mediadata = fetchWhiteboardForSubmission(OP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $width, $height, $imageurl);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OP_REPLYSNAPSHOT:
             $mediadata = fetchSnapshotCameraForSubmission(OP_FILENAMECONTROL, "snap.jpg", 350, 400, $usercontextid, 'user', 'draft', $draftitemid);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
         case OP_REPLYVIDEO:
             $mediadata = fetchVideoRecorderForSubmission('swf', 'onlinepoodll', OP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit);
             $mform->addElement('static', 'description', '', $mediadata);
             break;
     }
     // hidden params
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
     return true;
 }
 function display_add_field($recordid = 0)
 {
     global $CFG, $DB, $OUTPUT, $PAGE, $USER;
     $text = '';
     $format = 0;
     $str = '<div title="' . $this->field->description . '">';
     editors_head_setup();
     $options = $this->get_options();
     $itemid = $this->field->id;
     $field = 'field_' . $itemid;
     if ($recordid && ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid)))) {
         $format = $content->content1;
         $text = clean_text($content->content, $format);
         $text = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_data', 'content', $content->id, $options, $text);
     } else {
         $draftitemid = file_get_unused_draft_itemid();
     }
     $updatecontrol = $field;
     $idcontrol = $field . '_itemid';
     $str .= '<input type="hidden" id="' . $updatecontrol . '" name="' . $updatecontrol . '" value="empty" />';
     $str .= '<input type="hidden"  name="' . $idcontrol . '" value="' . $draftitemid . '" />';
     // $type = DBP_AUDIOMP3;
     $usercontextid = context_user::instance($USER->id)->id;
     switch ($this->field->param4) {
         case DBP_AUDIO:
             $str .= fetchAudioRecorderForSubmission('auto', 'ignore', $updatecontrol, $usercontextid, "user", "draft", $draftitemid);
             break;
         case DBP_VIDEO:
             $str .= fetchVideoRecorderForSubmission('auto', 'ignore', $updatecontrol, $usercontextid, "user", "draft", $draftitemid);
             break;
         case DBP_AUDIOMP3:
             $str .= fetchMP3RecorderForSubmission($updatecontrol, $usercontextid, "user", "draft", $draftitemid);
             break;
         case DBP_WHITEBOARDSIMPLE:
         case DBP_WHITEBOARDFULL:
             $str .= fetchWhiteboardForSubmission($updatecontrol, $usercontextid, "user", "draft", $draftitemid);
             break;
         case DBP_SNAPSHOT:
             $str .= fetchSnapshotCameraForSubmission($updatecontrol, 'apic.jpg', 350, 400, $usercontextid, "user", "draft", $draftitemid);
             break;
     }
     return $str;
 }