function fetchSWFWidgetCode($widget, $params, $width, $height, $bgcolor = "#FFFFFF") { global $CFG; $widgetid = html_writer::random_id('laszlobase'); $widgetjson = \filter_poodll\poodlltools::fetchSWFWidgetJSON($widget, $params, $width, $height, $bgcolor = "#FFFFFF", $widgetid); $retcode = html_writer::div('', '', array('id' => $widgetid . 'Container')); $retcode .= '<script type="text/javascript" src="' . $CFG->httpswwwroot . '/filter/poodll/flash/embed-compressed.js"></script> <script type="text/javascript"> lz.embed.swf(' . $widgetjson . ')</script>'; return $retcode; }
function fetch_course_users($courseid) { global $CFG, $DB; //get course and require requester is logged in if (!($course = $DB->get_record('course', array('id' => $courseid)))) { print_error('invalidcourseid'); } require_course_login($course); //fetch course context $coursecontext = \context_course::instance($courseid); //fetch user objects for all users in course //'u.id, u.username, u.firstname, u.lastname, u.picture' $users = get_users_by_capability($coursecontext, 'moodle/user:viewdetails'); //usersummary variable $usersummary = ""; //set up xml to return $xml_output = "<pairsets>\n"; $pairstreamname = rand(1000000, 9999999); $xml_output .= "\t<pair name='{$pairstreamname}' dirty='false'>\n"; //fill with user "pairelements" foreach ($users as $user) { $xml_output .= "\t\t<pairelement username='******' showname='" . fullname($user) . "' pictureurl='" . \filter_poodll\poodlltools::fetch_user_picture($user, 120) . "' />\n"; if ($usersummary == "") { $usersummary .= $user->username; } else { $usersummary .= ";" . $user->username; } } //close our list of users in the pairset $xml_output .= "\t</pair>\n"; //We also provide a summary of all the users in this course //so that the laszlo client doesn't need to xml divine it $xml_output .= "\t<usersummary>\n"; $xml_output .= $usersummary; $xml_output .= "\t</usersummary>\n"; $xml_output .= "</pairsets>"; //Return the data return $xml_output; }
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>
private function prepareWhiteboard($updatecontrol, $contextid, $component, $filearea, $itemid, $width = 0, $height = 0, $backimage = "") { $whiteboardString = \filter_poodll\poodlltools::fetchWhiteboardForSubmission($updatecontrol, $contextid, $component, $filearea, $itemid, $width, $height, $backimage); return $whiteboardString; }
/** * 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; }
/** * 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; }
/** * 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; }