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 (\filter_poodll\poodlltools::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 .= \filter_poodll\poodlltools::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 .= \filter_poodll\poodlltools::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>"; */ return $ret; } //end of if is mobile //HTML5 WIdgets and Uploading Images if (\filter_poodll\poodlltools::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 .= \filter_poodll\poodlltools::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>"; */ return $ret; } // $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 .= \filter_poodll\poodlltools::fetchSimpleAudioRecorder('swf','poodllrepository',$USER->id,$filename); $ret .= \filter_poodll\poodlltools::fetchAudioRecorderForSubmission('auto', 'poodllrepository', $filename, $context->id, 'user', 'draft', 0, 0); break; case self::POODLLVIDEO: //$ret .= \filter_poodll\poodlltools::fetchSimpleVideoRecorder('swf','poodllrepository',$USER->id,$filename,'','298', '340'); $ret .= \filter_poodll\poodlltools::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 .= \filter_poodll\poodlltools::fetchMP3RecorderForSubmission($filename, $context->id, "user", "draft", "0"); break; case self::POODLLWHITEBOARD: $ret .= \filter_poodll\poodlltools::fetchWhiteboardForSubmission($filename, $context->id, "user", "draft", "0", 400, 300, "", 'drawingboard'); break; case self::POODLLSNAPSHOT: $ret .= \filter_poodll\poodlltools::fetchSnapshotCameraforSubmission($filename, "apic.jpg", '290', '340', $context->id, "user", "draft", "0"); break; } return $ret; }
case 'snapshot': $recorderhtml = \filter_poodll\poodlltools::fetchSnapshotCameraforSubmission($updatecontrol, "apic.jpg", 350, 400, $usercontextid, 'user', 'draft', $itemid, $callbackjs); $instruction = get_string('snaptheninsert', 'atto_poodll'); break; case 'whiteboard': $recorderhtml = \filter_poodll\poodlltools::fetchWhiteboardForSubmission($updatecontrol, $usercontextid, 'user', 'draft', $itemid, 400, 350, "", $usewhiteboard, $callbackjs); $recorderhtml = "<div class='jswhiteboard'>" . $recorderhtml . "</div>"; $instruction = get_string('drawtheninsert', 'atto_poodll'); break; case 'audiored5': $recorderhtml = \filter_poodll\poodlltools::fetchAudioRecorderForSubmission('auto', 'none', $updatecontrol, $usercontextid, 'user', 'draft', $itemid, 0, $callbackjs); $instruction = get_string('recordtheninsert', 'atto_poodll'); break; case 'audiomp3': default: $recorderhtml = \filter_poodll\poodlltools::fetchMP3RecorderForSubmission($updatecontrol, $usercontextid, 'user', 'draft', $itemid, 0, $callbackjs); $instruction = get_string('recordtheninsert', 'atto_poodll'); } $PAGE->set_pagelayout('embedded'); $PAGE->set_title(get_string('dialogtitle', 'atto_poodll')); $PAGE->requires->css(new moodle_url($CFG->wwwroot . '/lib/editor/atto/plugins/poodll/dialog/poodll.css')); $PAGE->requires->js(new moodle_url($CFG->wwwroot . '/filter/poodll/module.js'), true); $PAGE->requires->jquery(); echo $OUTPUT->header(); ?> <div id="atto_poodll_container"> <div style="text-align: center;"> <p id="messageAlert"><?php echo $instruction; ?> </p>
/** * Get form elements for grading form * * @param stdClass $grade * @param MoodleQuickForm $mform * @param stdClass $data * @param int $userid The userid we are currently grading * @return bool true if elements were added to the form */ public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid) { global $USER, $PAGE, $CFG; $PAGE->requires->js(new moodle_url($CFG->httpswwwroot . '/mod/assign/feedback/poodll/module.js')); $displayname = $this->get_name(); $gradeid = $grade ? $grade->id : 0; if ($gradeid > 0 && get_config('assignfeedback_poodll', 'showcurrentfeedback')) { $currentfeedback = $this->fetch_responses($gradeid); if ($currentfeedback != '') { $deletefeedback = "<a href='javascript:void(0);' onclick='M.assignfeedback_poodll.deletefeedback();'>" . "<img src='" . $CFG->httpswwwroot . '/mod/assign/feedback/poodll/pix/deletebutton.png' . "' alt='" . get_string('deletefeedback', 'assignfeedback_poodll') . "'/>" . "</a>"; $currentfeedback .= $deletefeedback; } $currentcontainer = 'currentfeedbackwrapper'; $currentfeedback = "<div id='" . $currentcontainer . "'>" . $currentfeedback . "</div>"; $mform->addElement('static', 'currentfeedback', $displayname, $currentfeedback); //reset the display name so it doesn't show with the recorder $displayname = ""; $opts = array("filecontrolid" => FP_FILENAMECONTROL, "reallydeletefeedback" => get_string('reallydeletefeedback', 'assignfeedback_poodll'), "currentcontainer" => $currentcontainer); //$PAGE->requires->js(new moodle_url($CFG->httpswwwroot . '/mod/assign/feedback/poodll/module.js')); $PAGE->requires->js_init_call('M.assignfeedback_poodll.init', array($opts), 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(FP_FILENAMECONTROL); $contextid = $this->assignment->get_context()->id; file_prepare_draft_area($draftitemid, $contextid, ASSIGNFEEDBACK_POODLL_COMPONENT, ASSIGNFEEDBACK_POODLL_FILEAREA, $gradeid, null, null); $mform->addElement('hidden', 'draftitemid', $draftitemid); $mform->addElement('hidden', 'usercontextid', $usercontextid); $mform->addElement('hidden', FP_FILENAMECONTROL, '', array('id' => FP_FILENAMECONTROL)); $mform->setType('draftitemid', PARAM_INT); $mform->setType('usercontextid', PARAM_INT); $mform->setType(FP_FILENAMECONTROL, PARAM_TEXT); //no timelimit on recordings $timelimit = 0; //fetch the required "recorder switch ($this->get_config('recordertype')) { case FP_REPLYVOICE: $mediadata = \filter_poodll\poodlltools::fetchAudioRecorderForSubmission('swf', 'poodllfeedback', FP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit); $mform->addElement('static', 'description', $displayname, $mediadata); break; case FP_REPLYMP3VOICE: $mediadata = \filter_poodll\poodlltools::fetchMP3RecorderForSubmission(FP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit); $mform->addElement('static', 'description', $displayname, $mediadata); break; case FP_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; } $imageurl = ""; $mediadata = \filter_poodll\poodlltools::fetchWhiteboardForSubmission(FP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $width, $height, $imageurl); $mform->addElement('static', 'description', $displayname, $mediadata); break; case FP_REPLYSNAPSHOT: $mediadata = \filter_poodll\poodlltools::fetchSnapshotCameraforSubmission(FP_FILENAMECONTROL, "snap.jpg", 350, 400, $usercontextid, 'user', 'draft', $draftitemid); $mform->addElement('static', 'description', $displayname, $mediadata); break; case FP_REPLYVIDEO: $mediadata = \filter_poodll\poodlltools::fetchVideoRecorderForSubmission('swf', 'poodllfeedback', FP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit); $mform->addElement('static', 'description', $displayname, $mediadata); break; } // hidden params $mform->addElement('hidden', 'id', 0); $mform->setType('id', PARAM_INT); return true; }
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); }
/** * 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)); } if (!isset($data->vectordata)) { $data->vectordata = ''; } if ($submission) { $onlinepoodllsubmission = $this->get_onlinepoodll_submission($submission->id); if ($onlinepoodllsubmission) { $data->vectordata = $onlinepoodllsubmission->vectordata; } } //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->addElement('hidden', OP_VECTORCONTROL, $data->vectordata, array('id' => OP_VECTORCONTROL)); $mform->setType('draftitemid', PARAM_INT); $mform->setType('usercontextid', PARAM_INT); $mform->setType(OP_FILENAMECONTROL, PARAM_TEXT); $mform->setType(OP_VECTORCONTROL, 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 = \filter_poodll\poodlltools::fetchAudioRecorderForSubmission('swf', 'onlinepoodll', OP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $timelimit); $mform->addElement('static', 'description', '', $mediadata); break; case OP_REPLYMP3VOICE: $mediadata = \filter_poodll\poodlltools::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()); } $vectorcontrol = OP_VECTORCONTROL; $vectordata = $data->vectordata; $mediadata = \filter_poodll\poodlltools::fetchWhiteboardForSubmission(OP_FILENAMECONTROL, $usercontextid, 'user', 'draft', $draftitemid, $width, $height, $imageurl, '', '', $vectorcontrol, $vectordata); $mform->addElement('static', 'description', '', $mediadata); break; case OP_REPLYSNAPSHOT: $mediadata = \filter_poodll\poodlltools::fetchSnapshotCameraforSubmission(OP_FILENAMECONTROL, "snap.jpg", 350, 400, $usercontextid, 'user', 'draft', $draftitemid); $mform->addElement('static', 'description', '', $mediadata); break; case OP_REPLYVIDEO: $mediadata = \filter_poodll\poodlltools::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; }