Esempio n. 1
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;
 }
Esempio n. 2
0
 public function fetch_recorder()
 {
     global $USER, $CFG;
     $ret = "";
     //we get necessary info
     $context = get_context_instance(CONTEXT_USER, $USER->id);
     $filename = 'filename' . '_' . $this->options['recording_format'];
     if (isMobile()) {
         //if(true){
         switch ($this->options['recording_format']) {
             case self::POODLLAUDIO:
             case self::POODLLVIDEO:
             case self::MP3AUDIO:
                 //we load up the file upload HTML5
                 $ret .= fetch_HTML5RecorderForSubmission($filename, $context->id, "user", "draft", "0", "video", true);
                 break;
             case self::POODLLWHITEBOARD:
             case self::POODLLSNAPSHOT:
                 //we load up the file upload HTML5
                 $ret .= fetch_HTML5RecorderForSubmission($filename, $context->id, "user", "draft", "0", "image", 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
     //   $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);
             break;
         case self::POODLLVIDEO:
             $ret .= fetchSimpleVideoRecorder('swf', 'poodllrepository', $USER->id, $filename, '', '298', '340');
             break;
         case self::MP3AUDIO:
             //this is the mp3 recorder, by Paul Nichols
             //$ret = $this->fetchMP3PostRecorder("filename","apic.jpg", '290','340');
             //$ret = fetchMP3RecorderForRepo("filename");
             //$context = get_context_instance(CONTEXT_USER, $USER->id);
             $ret .= fetchMP3RecorderForSubmission($filename, $context->id, "user", "draft", "0");
             break;
         case self::POODLLWHITEBOARD:
             //$context = get_context_instance(CONTEXT_USER, $USER->id);
             $ret .= fetchWhiteboardForSubmission($filename, $context->id, "user", "draft", "0", 510, 370);
             break;
         case self::POODLLSNAPSHOT:
             //$context = get_context_instance(CONTEXT_USER, $USER->id);
             $ret .= fetchSnapshotCameraForSubmission($filename, "apic.jpg", '290', '340', $context->id, "user", "draft", "0");
             break;
     }
     echo $ret;
 }
Esempio n. 3
0
 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;
 }