Example #1
0
 function display_add_field($recordid = 0)
 {
     global $CFG, $DB, $OUTPUT;
     $text = '';
     $format = 0;
     if ($recordid) {
         if ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) {
             $text = $content->content;
             $format = $content->content1;
         }
     }
     $str = '<div title="' . $this->field->description . '">';
     if (can_use_html_editor()) {
         // Show a rich text html editor.
         $str .= $this->gen_textarea(true, $text);
         $str .= $OUTPUT->help_icon(moodle_help_icon::make("richtext2", get_string("helprichtext"), 'moodle', true));
         $str .= '<input type="hidden" name="field_' . $this->field->id . '_content1' . '" value="' . FORMAT_HTML . '" />';
     } else {
         // Show a normal textarea. Also let the user specify the format to be used.
         $str .= $this->gen_textarea(false, $text);
         // Get the available text formats for this field.
         $formatsForField = format_text_menu();
         $str .= '<br />';
         $select = html_select($formatsForField, 'field_' . $this->field->id . '_content1', $format);
         $select->nothingvalue = '';
         $str .= $OUTPUT->select($select);
         $str .= $OUTPUT->help_icon(moodle_help_icon::make('textformat', get_string('helpformatting'), 'moodle'));
     }
     $str .= '</div>';
     return $str;
 }
 function display_add_field($recordid = 0)
 {
     global $CFG;
     $text = '';
     $format = 0;
     if ($recordid) {
         if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
             $text = $content->content;
             $format = $content->content1;
         }
     }
     $str = '<div title="' . $this->field->description . '">';
     if (can_use_richtext_editor()) {
         // Show a rich text html editor.
         $str .= $this->gen_textarea(true, $text);
         $str .= helpbutton("richtext", get_string("helprichtext"), 'moodle', true, true, '', true);
         $str .= '<input type="hidden" name="field_' . $this->field->id . '_content1' . '" value="' . FORMAT_HTML . '" />';
     } else {
         // Show a normal textarea. Also let the user specify the format to be used.
         $str .= $this->gen_textarea(false, $text);
         // Get the available text formats for this field.
         $formatsForField = format_text_menu();
         $str .= '<br />';
         $str .= choose_from_menu($formatsForField, 'field_' . $this->field->id . '_content1', $format, 'choose', '', '', true);
         $str .= helpbutton('textformat', get_string('helpformatting'), 'moodle', true, false, '', true);
     }
     $str .= '</div>';
     return $str;
 }
Example #3
0
 /**
  * Called by HTML_QuickForm whenever form event is made on this element
  *
  * @param     string    $event  Name of event
  * @param     mixed     $arg    event arguments
  * @param     object    $caller calling object
  * @since     1.0
  * @access    public
  * @return    mixed
  */
 function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'createElement':
             $menu = format_text_menu();
             $this->load($menu);
             $this->setHelpButton(array('textformat', get_string('helpformatting')));
             break;
         case 'updateValue':
             $value = $this->_findValue($caller->_constantValues);
             if (null === $value) {
                 $value = $this->_findValue($caller->_submitValues);
                 // Fix for bug #4465 & #5269
                 // XXX: should we push this to element::onQuickFormEvent()?
                 if (null === $value && (!$caller->isSubmitted() || !$this->getMultiple())) {
                     $value = $this->_findValue($caller->_defaultValues);
                 }
             }
             if (null !== $value) {
                 $format = $value;
             } else {
                 $format = FORMAT_MOODLE;
             }
             if ($this->_useHtmlEditor) {
                 $this->setValue(array(FORMAT_HTML));
             } else {
                 $this->setValue(array($format));
             }
             return true;
             break;
     }
     return parent::onQuickFormEvent($event, $arg, $caller);
 }
Example #4
0
 public function manual_comment_fields(question_attempt $qa, question_display_options $options)
 {
     $inputname = $qa->get_behaviour_field_name('comment');
     $id = $inputname . '_id';
     list($commenttext, $commentformat) = $qa->get_current_manual_comment();
     $editor = editors_get_preferred_editor($commentformat);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     $commenttext = format_text($commenttext, $commentformat, array('para' => false));
     $editor->set_text($commenttext);
     $editor->use_editor($id, array('context' => $options->context));
     $commenteditor = html_writer::tag('div', html_writer::tag('textarea', s($commenttext), array('id' => $id, 'name' => $inputname, 'rows' => 10, 'cols' => 60)));
     $editorformat = '';
     if (count($formats) == 1) {
         reset($formats);
         $editorformat .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $inputname . 'format', 'value' => key($formats)));
     } else {
         $editorformat = html_writer::start_tag('div', array('class' => 'fitem'));
         $editorformat .= html_writer::start_tag('div', array('class' => 'fitemtitle'));
         $editorformat .= html_writer::tag('label', get_string('format'), array('for' => 'menu' . $inputname . 'format'));
         $editorformat .= html_writer::end_tag('div');
         $editorformat .= html_writer::start_tag('div', array('class' => 'felement fhtmleditor'));
         $editorformat .= html_writer::select($formats, $inputname . 'format', $commentformat, '');
         $editorformat .= html_writer::end_tag('div');
         $editorformat .= html_writer::end_tag('div');
     }
     $comment = html_writer::tag('div', html_writer::tag('div', html_writer::tag('label', get_string('comment', 'question'), array('for' => $id)), array('class' => 'fitemtitle')) . html_writer::tag('div', $commenteditor, array('class' => 'felement fhtmleditor')), array('class' => 'fitem'));
     $comment .= $editorformat;
     $mark = '';
     if ($qa->get_max_mark()) {
         $currentmark = $qa->get_current_manual_mark();
         $maxmark = $qa->get_max_mark();
         $fieldsize = strlen($qa->format_max_mark($options->markdp)) - 1;
         $markfield = $qa->get_behaviour_field_name('mark');
         $attributes = array('type' => 'text', 'size' => $fieldsize, 'name' => $markfield, 'id' => $markfield);
         if (!is_null($currentmark)) {
             $attributes['value'] = $currentmark;
         }
         $a = new stdClass();
         $a->max = $qa->format_max_mark($options->markdp);
         $a->mark = html_writer::empty_tag('input', $attributes);
         $markrange = html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_behaviour_field_name('maxmark'), 'value' => $maxmark)) . html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_control_field_name('minfraction'), 'value' => $qa->get_min_fraction())) . html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_control_field_name('maxfraction'), 'value' => $qa->get_max_fraction()));
         $error = $qa->validate_manual_mark($currentmark);
         $errorclass = '';
         if ($error !== '') {
             $erroclass = ' error';
             $error = html_writer::tag('span', $error, array('class' => 'error')) . html_writer::empty_tag('br');
         }
         $mark = html_writer::tag('div', html_writer::tag('div', html_writer::tag('label', get_string('mark', 'question'), array('for' => $markfield)), array('class' => 'fitemtitle')) . html_writer::tag('div', $error . get_string('xoutofmax', 'question', $a) . $markrange, array('class' => 'felement ftext' . $errorclass)), array('class' => 'fitem'));
     }
     return html_writer::tag('fieldset', html_writer::tag('div', $comment . $mark, array('class' => 'fcontainer clearfix')), array('class' => 'hidden'));
 }
Example #5
0
 function display_add_field($recordid = 0)
 {
     global $CFG, $DB, $OUTPUT, $PAGE;
     $text = '';
     $format = 0;
     $str = '<div title="' . $this->field->description . '">';
     editors_head_setup();
     $options = array();
     $options['trusttext'] = false;
     $options['forcehttps'] = false;
     $options['subdirs'] = false;
     $options['maxfiles'] = 0;
     $options['maxbytes'] = 0;
     $options['changeformat'] = 0;
     $options['noclean'] = false;
     $itemid = $this->field->id;
     $field = 'field_' . $itemid;
     if ($recordid && ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid)))) {
         $text = $content->content;
         $format = $content->content1;
         $text = clean_text($text, $format);
     } else {
         if (can_use_html_editor()) {
             $format = FORMAT_HTML;
         } else {
             $format = FORMAT_PLAIN;
         }
     }
     $editor = editors_get_preferred_editor($format);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     $editor->use_editor($field, $options);
     $str .= '<div><textarea id="' . $field . '" name="' . $field . '" rows="' . $this->field->param3 . '" cols="' . $this->field->param2 . '">' . s($text) . '</textarea></div>';
     $str .= '<div><select name="' . $field . '_content1">';
     foreach ($formats as $key => $desc) {
         $selected = $format == $key ? 'selected="selected"' : '';
         $str .= '<option value="' . s($key) . '" ' . $selected . '>' . $desc . '</option>';
     }
     $str .= '</select>';
     $str .= '</div>';
     $str .= '</div>';
     return $str;
 }
Example #6
0
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package    filter
 * @subpackage emoticon
 * @copyright  2010 David Mudrak <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    $settings->add(new admin_setting_configmulticheckbox('filter_emoticon/formats', get_string('settingformats', 'filter_emoticon'), get_string('settingformats_desc', 'filter_emoticon'), array(FORMAT_HTML => 1, FORMAT_MARKDOWN => 1, FORMAT_MOODLE => 1), format_text_menu()));
}
Example #7
0
    data_generate_default_template($data, 'listtemplate');
    data_generate_default_template($data, 'addtemplate');
    data_generate_default_template($data, 'asearchtemplate');
    //Template for advanced searches.
    data_generate_default_template($data, 'rsstemplate');
}
editors_head_setup();
$format = FORMAT_HTML;
if ($mode === 'csstemplate' or $mode === 'jstemplate') {
    $disableeditor = true;
}
if ($disableeditor) {
    $format = FORMAT_PLAIN;
}
$editor = editors_get_preferred_editor($format);
$strformats = format_text_menu();
$formats = $editor->get_supported_formats();
foreach ($formats as $fid) {
    $formats[$fid] = $strformats[$fid];
}
$options = array();
$options['trusttext'] = false;
$options['forcehttps'] = false;
$options['subdirs'] = false;
$options['maxfiles'] = 0;
$options['maxbytes'] = 0;
$options['changeformat'] = 0;
$options['noclean'] = false;
echo '<form id="tempform" action="templates.php?d=' . $data->id . '&amp;mode=' . $mode . '" method="post">';
echo '<div>';
echo '<input name="sesskey" value="' . sesskey() . '" type="hidden" />';
Example #8
0
    /**
     * Returns HTML for editor form element.
     *
     * @return string
     */
    function toHtml() {
        global $CFG, $PAGE, $OUTPUT;
        require_once($CFG->dirroot.'/repository/lib.php');

        if ($this->_flagFrozen) {
            return $this->getFrozenHtml();
        }

        $ctx = $this->_options['context'];

        $id           = $this->_attributes['id'];
        $elname       = $this->_attributes['name'];

        $subdirs      = $this->_options['subdirs'];
        $maxbytes     = $this->_options['maxbytes'];
        $areamaxbytes = $this->_options['areamaxbytes'];
        $maxfiles     = $this->_options['maxfiles'];
        $changeformat = $this->_options['changeformat']; // TO DO: implement as ajax calls

        $text         = $this->_values['text'];
        $format       = $this->_values['format'];
        $draftitemid  = $this->_values['itemid'];

        // security - never ever allow guest/not logged in user to upload anything
        if (isguestuser() or !isloggedin()) {
            $maxfiles = 0;
        }

        $str = $this->_getTabs();
        $str .= '<div>';

        $editor = editors_get_preferred_editor($format);
        $strformats = format_text_menu();
        $formats =  $editor->get_supported_formats();
        foreach ($formats as $fid) {
            $formats[$fid] = $strformats[$fid];
        }

        // get filepicker info
        //
        $fpoptions = array();
        if ($maxfiles != 0 ) {
            if (empty($draftitemid)) {
                // no existing area info provided - let's use fresh new draft area
                require_once("$CFG->libdir/filelib.php");
                $this->setValue(array('itemid'=>file_get_unused_draft_itemid()));
                $draftitemid = $this->_values['itemid'];
            }

            $args = new stdClass();
            // need these three to filter repositories list
            $args->accepted_types = array('web_image');
            $args->return_types = $this->_options['return_types'];
            $args->context = $ctx;
            $args->env = 'filepicker';
            // advimage plugin
            $image_options = initialise_filepicker($args);
            $image_options->context = $ctx;
            $image_options->client_id = uniqid();
            $image_options->maxbytes = $this->_options['maxbytes'];
            $image_options->areamaxbytes = $this->_options['areamaxbytes'];
            $image_options->env = 'editor';
            $image_options->itemid = $draftitemid;

            // moodlemedia plugin
            $args->accepted_types = array('video', 'audio');
            $media_options = initialise_filepicker($args);
            $media_options->context = $ctx;
            $media_options->client_id = uniqid();
            $media_options->maxbytes  = $this->_options['maxbytes'];
            $media_options->areamaxbytes  = $this->_options['areamaxbytes'];
            $media_options->env = 'editor';
            $media_options->itemid = $draftitemid;

            // advlink plugin
            $args->accepted_types = '*';
            $link_options = initialise_filepicker($args);
            $link_options->context = $ctx;
            $link_options->client_id = uniqid();
            $link_options->maxbytes  = $this->_options['maxbytes'];
            $link_options->areamaxbytes  = $this->_options['areamaxbytes'];
            $link_options->env = 'editor';
            $link_options->itemid = $draftitemid;

            $args->accepted_types = array('.vtt');
            $subtitle_options = initialise_filepicker($args);
            $subtitle_options->context = $ctx;
            $subtitle_options->client_id = uniqid();
            $subtitle_options->maxbytes  = $this->_options['maxbytes'];
            $subtitle_options->areamaxbytes  = $this->_options['areamaxbytes'];
            $subtitle_options->env = 'editor';
            $subtitle_options->itemid = $draftitemid;

            $fpoptions['image'] = $image_options;
            $fpoptions['media'] = $media_options;
            $fpoptions['link'] = $link_options;
            $fpoptions['subtitle'] = $subtitle_options;
        }

        //If editor is required and tinymce, then set required_tinymce option to initalize tinymce validation.
        if (($editor instanceof tinymce_texteditor)  && !is_null($this->getAttribute('onchange'))) {
            $this->_options['required'] = true;
        }

        // print text area - TODO: add on-the-fly switching, size configuration, etc.
        $editor->set_text($text);
        $editor->use_editor($id, $this->_options, $fpoptions);

        $rows = empty($this->_attributes['rows']) ? 15 : $this->_attributes['rows'];
        $cols = empty($this->_attributes['cols']) ? 80 : $this->_attributes['cols'];

        //Apply editor validation if required field
        $context = [];
        $context['rows'] = $rows;
        $context['cols'] = $cols;
        $context['frozen'] = $this->_flagFrozen;
        foreach ($this->getAttributes() as $name => $value) {
            $context[$name] = $value;
        }
        $context['hasformats'] = count($formats) > 1;
        $context['formats'] = [];
        if (($format === '' || $format === null) && count($formats)) {
            $format = key($formats);
        }
        foreach ($formats as $formatvalue => $formattext) {
            $context['formats'][] = ['value' => $formatvalue, 'text' => $formattext, 'selected' => ($formatvalue == $format)];
        }
        $context['id'] = $id;
        $context['value'] = $text;
        $context['format'] = $format;

        if (!is_null($this->getAttribute('onblur')) && !is_null($this->getAttribute('onchange'))) {
            $context['changelistener'] = true;
        }

        $str .= $OUTPUT->render_from_template('core_form/editor_textarea', $context);

        // during moodle installation, user area doesn't exist
        // so we need to disable filepicker here.
        if (!during_initial_install() && empty($CFG->adminsetuppending)) {
            // 0 means no files, -1 unlimited
            if ($maxfiles != 0 ) {
                $str .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $elname.'[itemid]',
                        'value' => $draftitemid));

                // used by non js editor only
                $editorurl = new moodle_url("$CFG->wwwroot/repository/draftfiles_manager.php", array(
                    'action'=>'browse',
                    'env'=>'editor',
                    'itemid'=>$draftitemid,
                    'subdirs'=>$subdirs,
                    'maxbytes'=>$maxbytes,
                    'areamaxbytes' => $areamaxbytes,
                    'maxfiles'=>$maxfiles,
                    'ctx_id'=>$ctx->id,
                    'course'=>$PAGE->course->id,
                    'sesskey'=>sesskey(),
                    ));
                $str .= '<noscript>';
                $str .= "<div><object type='text/html' data='$editorurl' height='160' width='600' style='border:1px solid #000'></object></div>";
                $str .= '</noscript>';
            }
        }


        $str .= '</div>';

        return $str;
    }
Example #9
0
 function toHtml()
 {
     global $CFG, $PAGE;
     require_once $CFG->dirroot . '/repository/lib.php';
     if ($this->_flagFrozen) {
         return $this->getFrozenHtml();
     }
     $ctx = $this->_options['context'];
     $id = $this->_attributes['id'];
     $elname = $this->_attributes['name'];
     $subdirs = $this->_options['subdirs'];
     $maxbytes = $this->_options['maxbytes'];
     $maxfiles = $this->_options['maxfiles'];
     $changeformat = $this->_options['changeformat'];
     // TO DO: implement as ajax calls
     $text = $this->_values['text'];
     $format = $this->_values['format'];
     $draftitemid = $this->_values['itemid'];
     // security - never ever allow guest/not logged in user to upload anything
     if (isguestuser() or !isloggedin()) {
         $maxfiles = 0;
     }
     $str = $this->_getTabs();
     $str .= '<div>';
     $editor = editors_get_preferred_editor($format);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     // get filepicker info
     //
     $fpoptions = array();
     if ($maxfiles != 0) {
         if (empty($draftitemid)) {
             // no existing area info provided - let's use fresh new draft area
             require_once "{$CFG->libdir}/filelib.php";
             $this->setValue(array('itemid' => file_get_unused_draft_itemid()));
             $draftitemid = $this->_values['itemid'];
         }
         $args = new stdClass();
         // need these three to filter repositories list
         $args->accepted_types = array('image');
         $args->return_types = FILE_INTERNAL | FILE_EXTERNAL;
         $args->context = $ctx;
         $args->env = 'filepicker';
         // advimage plugin
         $image_options = initialise_filepicker($args);
         $image_options->context = $ctx;
         $image_options->client_id = uniqid();
         $image_options->maxbytes = $this->_options['maxbytes'];
         $image_options->env = 'editor';
         $image_options->itemid = $draftitemid;
         // moodlemedia plugin
         $args->accepted_types = array('video', 'audio');
         $media_options = initialise_filepicker($args);
         $media_options->context = $ctx;
         $media_options->client_id = uniqid();
         $media_options->maxbytes = $this->_options['maxbytes'];
         $media_options->env = 'editor';
         $media_options->itemid = $draftitemid;
         // advlink plugin
         $args->accepted_types = '*';
         $link_options = initialise_filepicker($args);
         $link_options->context = $ctx;
         $link_options->client_id = uniqid();
         $link_options->maxbytes = $this->_options['maxbytes'];
         $link_options->env = 'editor';
         $link_options->itemid = $draftitemid;
         $fpoptions['image'] = $image_options;
         $fpoptions['media'] = $media_options;
         $fpoptions['link'] = $link_options;
     }
     //If editor is required and tinymce, then set required_tinymce option to initalize tinymce validation.
     if ($editor instanceof tinymce_texteditor && !is_null($this->getAttribute('onchange'))) {
         $this->_options['required'] = true;
     }
     /// print text area - TODO: add on-the-fly switching, size configuration, etc.
     $editor->use_editor($id, $this->_options, $fpoptions);
     $rows = empty($this->_attributes['rows']) ? 15 : $this->_attributes['rows'];
     $cols = empty($this->_attributes['cols']) ? 80 : $this->_attributes['cols'];
     //Apply editor validation if required field
     $editorrules = '';
     if (!is_null($this->getAttribute('onblur')) && !is_null($this->getAttribute('onchange'))) {
         $editorrules = 'onblur="' . htmlspecialchars($this->getAttribute('onblur')) . '" onchange="' . htmlspecialchars($this->getAttribute('onchange')) . '"';
     }
     $str .= '<div><textarea id="' . $id . '" name="' . $elname . '[text]" rows="' . $rows . '" cols="' . $cols . '"' . $editorrules . '>';
     $str .= s($text);
     $str .= '</textarea></div>';
     $str .= '<div>';
     if (count($formats) > 1) {
         $str .= html_writer::select($formats, $elname . '[format]', $format, false);
     } else {
         $str .= html_writer::empty_tag('input', array('name' => $elname . '[format]', 'type' => 'hidden', 'value' => array_pop(array_keys($formats))));
     }
     $str .= '</div>';
     // during moodle installation, user area doesn't exist
     // so we need to disable filepicker here.
     if (!during_initial_install() && empty($CFG->adminsetuppending)) {
         // 0 means no files, -1 unlimited
         if ($maxfiles != 0) {
             $str .= '<input type="hidden" name="' . $elname . '[itemid]" value="' . $draftitemid . '" />';
             // used by non js editor only
             $editorurl = new moodle_url("{$CFG->wwwroot}/repository/draftfiles_manager.php", array('action' => 'browse', 'env' => 'editor', 'itemid' => $draftitemid, 'subdirs' => $subdirs, 'maxbytes' => $maxbytes, 'maxfiles' => $maxfiles, 'ctx_id' => $ctx->id, 'course' => $PAGE->course->id, 'sesskey' => sesskey()));
             $str .= '<noscript>';
             $str .= "<div><object type='text/html' data='{$editorurl}' height='160' width='600' style='border:1px solid #000'></object></div>";
             $str .= '</noscript>';
         }
     }
     $str .= '</div>';
     return $str;
 }
 /**
  *  Display a single submission, ready for grading on a popup window
  *
  * This default method prints the teacher info and submissioncomment box at the top and
  * the student info and submission at the bottom.
  * This method also fetches the necessary data in order to be able to
  * provide a "Next submission" button.
  * Calls preprocess_submission() to give assignment type plug-ins a chance
  * to process submissions before they are graded
  * This method gets its arguments from the page parameters userid and offset
  */
 function display_submission($extra_javascript = '')
 {
     global $CFG;
     $userid = optional_param('userid', PARAM_INT);
     $offset = required_param('offset', PARAM_INT);
     //offset for where to start looking for student.
     //echo '<p>userid: '.$userid;
     if (!($user = get_record('user', 'id', $userid))) {
         error('No such user!');
     }
     if (!($submission = $this->get_submission($user->id))) {
         $submission = $this->prepare_new_submission($userid);
     }
     if ($submission->timemodified > $submission->timemarked) {
         $subtype = 'webquestscormnew';
     } else {
         $subtype = 'webquestscormold';
     }
     /// Get all teachers and students
     $currentgroup = get_current_group($this->course->id);
     if ($currentgroup) {
         $users = get_group_users($currentgroup);
     } else {
         $users = get_users_by_capability($this->context, 'mod/webquestscorm:submit');
         //$users = get_course_users($this->course->id);
     }
     $select = 'SELECT u.id, u.firstname, u.lastname, u.picture,
                       s.id AS submissionid, s.grade, s.submissioncomment, 
                       s.timemodified, s.timemarked ';
     $sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'webquestscorm_submissions s ON u.id = s.userid 
                                                               AND s.webquestscorm = ' . $this->wqid . ' ' . 'WHERE u.id IN (' . implode(',', array_keys($users)) . ') ';
     require_once $CFG->libdir . '/tablelib.php';
     if ($sort = flexible_table::get_sql_sort('mod-webquestscorm-submissions')) {
         $sort = 'ORDER BY ' . $sort . ' ';
     }
     $nextid = 0;
     if (($auser = get_records_sql($select . $sql . $sort, $offset + 1, 1)) !== false) {
         $nextuser = array_shift($auser);
         /// Calculate user status
         $nextuser->status = $nextuser->timemarked > 0 && $nextuser->timemarked >= $nextuser->timemodified;
         $nextid = $nextuser->id;
     }
     print_header(get_string('feedback', 'webquestscorm') . ':' . fullname($user, true) . ':' . format_string($this->wqname));
     /// Print any extra javascript needed for saveandnext
     echo $extra_javascript;
     ///SOme javascript to help with setting up >.>
     echo '<script type="text/javascript">' . "\n";
     echo 'function setNext(){' . "\n";
     echo 'document.submitform.mode.value=\'next\';' . "\n";
     echo 'document.submitform.userid.value="' . $nextid . '";' . "\n";
     echo '}' . "\n";
     echo 'function saveNext(){' . "\n";
     echo 'document.submitform.mode.value=\'saveandnext\';' . "\n";
     echo 'document.submitform.userid.value="' . $nextid . '";' . "\n";
     echo 'document.submitform.saveuserid.value="' . $userid . '";' . "\n";
     echo 'document.submitform.menuindex.value = document.submitform.grade.selectedIndex;' . "\n";
     echo '}' . "\n";
     echo '</script>' . "\n";
     echo '<table cellspacing="0" class="feedback ' . $subtype . '" >';
     ///Start of teacher info row
     echo '<tr>';
     echo '<td width="35" valign="top" class="picture teacher">';
     if ($submission->teacher) {
         $teacher = get_record('user', 'id', $submission->teacher);
     } else {
         global $USER;
         $teacher = $USER;
     }
     print_user_picture($teacher->id, $this->course->id, $teacher->picture);
     echo '</td>';
     echo '<td class="content">';
     echo '<form name="submitform" action="submissions.php?cmid=' . $this->cm->id . '" method="post">';
     echo '<input type="hidden" name="offset" value="' . ++$offset . '">';
     echo '<input type="hidden" name="userid" value="' . $userid . '" />';
     echo '<input type="hidden" name="id" value="' . $this->cm->id . '" />';
     echo '<input type="hidden" name="mode" value="grade" />';
     //echo '<input type="hidden" name="tabs" value="required" />';
     echo '<input type="hidden" name="menuindex" value="0" />';
     //selected menu index
     //new hidden field, initialized to -1.
     echo '<input type="hidden" name="saveuserid" value="-1" />';
     if ($submission->timemarked) {
         echo '<div class="from">';
         echo '<div class="fullname">' . fullname($teacher, true) . '</div>';
         echo '<div class="time">' . userdate($submission->timemarked) . '</div>';
         echo '</div>';
     }
     echo '<div class="grade">' . get_string('grade') . ':';
     choose_from_menu(make_grades_menu($this->wqgrade), 'grade', $submission->grade, get_string('nograde'), '', -1);
     echo '</div>';
     echo '<div class="clearer"></div>';
     echo '<br />';
     if ($usehtmleditor = can_use_html_editor()) {
         $defaultformat = FORMAT_HTML;
         $editorfields = '';
     } else {
         $defaultformat = FORMAT_MOODLE;
     }
     print_textarea($usehtmleditor, 14, 58, 0, 0, 'submissioncomment', $submission->submissioncomment, $this->course->id);
     if ($usehtmleditor) {
         echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
     } else {
         echo '<div align="right" class="format">';
         choose_from_menu(format_text_menu(), "format", $submission->format, "");
         helpbutton("textformat", get_string("helpformatting"));
         echo '</div>';
     }
     ///Print Buttons in Single View
     echo '<div class="buttons" align="center">';
     echo '<input type="submit" name="submit" value="' . get_string('savechanges') . '" onclick = "document.submitform.menuindex.value = document.submitform.grade.selectedIndex" />';
     echo '<input type="submit" name="cancel" value="' . get_string('cancel') . '" />';
     //if there are more to be graded.
     if ($nextid) {
         echo '<input type="submit" name="saveandnext" value="' . get_string('saveandnext') . '" onclick="saveNext()" />';
         echo '<input type="submit" name="next" value="' . get_string('next') . '" onclick="setNext();" />';
     }
     echo '</div>';
     echo '</form>';
     /*
             $customfeedback = $this->custom_feedbackform($submission, true);
             if (!empty($customfeedback)) {
                 echo $customfeedback; 
             }
     */
     echo '</td></tr>';
     ///End of teacher info row, Start of student info row
     echo '<tr>';
     echo '<td width="35" valign="top" class="picture user">';
     print_user_picture($user->id, $this->course->id, $user->picture);
     echo '</td>';
     echo '<td class="topic">';
     echo '<div class="from">';
     echo '<div class="fullname">' . fullname($user, true) . '</div>';
     if ($submission->timemodified) {
         echo '<div class="time">' . userdate($submission->timemodified) . $this->display_lateness($submission->timemodified, $this->wqtimedue) . '</div>';
     }
     echo '</div>';
     $this->print_user_files($user->id);
     echo '</td>';
     echo '</tr>';
     ///End of student info row
     echo '</table>';
     if ($usehtmleditor) {
         use_html_editor();
     }
 }
    }
    if (has_capability('moodle/course:bulkmessaging', $coursecontext)) {
        $usehtmleditor = can_use_html_editor();
        echo '<div class="buttons"><br />';
        echo '<input type="button" id="checkall" value="' . get_string('selectall') . '" /> ';
        echo '<input type="button" id="checknone" value="' . get_string('deselectall') . '" /> ';
        echo '</div>';
        echo '<fieldset class="clearfix">';
        echo '<legend class="ftoggler">' . get_string('send_message', 'feedback') . '</legend>';
        echo '<div><label for="feedback_subject">' . get_string('subject', 'feedback') . '&nbsp;</label><input type="text" id="feedback_subject" size="50" maxlength="255" name="subject" value="' . $subject . '" /></div>';
        print_textarea($usehtmleditor, 15, 25, 30, 10, "message", $message);
        if ($usehtmleditor) {
            print_string('formathtml');
            echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
        } else {
            choose_from_menu(format_text_menu(), "format", $format, "");
        }
        echo '<br /><div class="buttons">';
        echo '<input type="submit" name="send_message" value="' . get_string('send', 'feedback') . '" />';
        echo '</div>';
        echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
        echo '<input type="hidden" name="action" value="sendmessage" />';
        echo '<input type="hidden" name="id" value="' . $id . '" />';
        echo '</fieldset>';
        echo '</form>';
        //include the needed js
        $module = array('name' => 'mod_feedback', 'fullpath' => '/mod/feedback/feedback.js');
        $PAGE->requires->js_init_call('M.mod_feedback.init_sendmessage', null, false, $module);
    }
}
echo $OUTPUT->box_end();
 public static function format_editor_formats($editor, $name, $format)
 {
     // get the valid formats
     $strformats = format_text_menu();
     $formatids = $editor->get_supported_formats();
     foreach ($formatids as $formatid) {
         $formats[$formatid] = $strformats[$formatid];
     }
     // get label and select element for the formats
     $output = '';
     $params = array('for' => 'id_' . $name . '_format', 'class' => 'accesshide');
     $output .= html_writer::tag('label', get_string('format'), $params);
     $output .= html_writer::select($formats, $name . '_format', $format);
     // wrap it all in a DIV ... not sure why :-)
     return html_writer::tag('div', $output);
 }
 function view_dates()
 {
     global $CFG, $USER;
     $showcombo = optional_param('showcombo', NULL, PARAM_INT);
     $komboroom = optional_param('komboroom', NULL, PARAM_ALPHAEXT);
     $jday = optional_param('jday', NULL, PARAM_INT);
     $subitemid = optional_param('subitemid', NULL, PARAM_INT);
     $tidx = optional_param('tidx', NULL, PARAM_INT);
     $delete = optional_param('delete', NULL, PARAM_INT);
     $edit = optional_param('edit', NULL, PARAM_INT);
     $save = optional_param('save', NULL, PARAM_INT);
     $restore = optional_param('restore', NULL, PARAM_INT);
     $resid = optional_param('resid', NULL, PARAM_INT);
     $uid = optional_param('uid', NULL, PARAM_INT);
     $value = optional_param('value');
     $cmid = $this->cm->id;
     $itemid = $this->bookings->itemid;
     $username = $USER->username;
     // $bookings = get_record('bookings', 'id', $this->bookings->id);
     /// get start and end julian day number
     list($ey, $em, $ed) = explode("/", strftime("%Y/%m/%d", $this->bookings->enddate));
     $ejday = 7 * (int) (gregoriantojd($em, $ed, $ey) / 7);
     list($ey, $em, $ed) = explode("/", strftime("%Y/%m/%d", $this->bookings->startdate));
     $sjday = 7 * (int) (gregoriantojd($em, $ed, $ey) / 7);
     $UID = $USER->id;
     $firstname = $USER->firstname;
     $lastname = $USER->lastname;
     if ($firstname == '' or $lastname == '') {
         return "";
     }
     print '<form name=myform id=myform method=post action="view.php?id=' . $cmid . '">';
     // fetch out data for this item
     $sql = 'SELECT id,name,type,parent
             FROM ' . $CFG->prefix . 'bookings_item i
             WHERE i.parent = ' . $itemid . '
             ORDER BY i.name';
     $idx = 0;
     $main_reservation = array();
     $iteminfo = array();
     $itemid_list = array();
     if (!($childlist = get_records_sql($sql))) {
         $sql = 'SELECT r.id,r.name,r.type,r.parent FROM ' . $CFG->prefix . 'bookings_item r WHERE r.id=' . $itemid;
         $childlist = get_records_sql($sql);
     }
     foreach ($childlist as $child) {
         // build array of props for this item (room)
         $itemid_list[] = $child->id;
         $proplist = bookings_item_properties($child->id);
         if (isset($proplist['image'])) {
             $childlist[$child->id]->image = '<br>' . '<img src="' . $proplist['image'] . '">';
         }
         /// here we fetch out all reservations
         $reservation = array();
         $sql = 'SELECT * FROM ' . $CFG->prefix . 'bookings_calendar 
                 WHERE eventtype="reservation" 
                 AND itemid=' . $child->id . '
                 AND julday >= ' . $sjday . '
                 AND julday <= ' . $ejday;
         if ($res = get_records_sql($sql)) {
             foreach ($res as $re) {
                 $reservation[7 * (int) ($re->julday / 7)] = $re;
             }
         }
         $childlist[$child->id]->proplist = $proplist;
         $main_reservation[$idx] = $reservation;
         $iteminfo[$idx] = $child;
         /// $childlist[$child->id]->reservation = $reservation;
         $idx++;
     }
     /// if there are children, then we must fetch out properties for parent
     /// these props decide if teachers or students can make bookings
     if ($idx > 1) {
         $proplist = bookings_item_properties($itemid);
     }
     // decide if user can edit timetable
     // 0 = view only, 1 = add items, delete/edit own, 2 add/delete/edit any
     $can_edit = isteacherinanycourse($USER->id) ? 1 : 0;
     // default is that teachers can edit
     $link2room = '';
     if (isset($proplist['edit_group'])) {
         $can_edit = 0;
         // default is no edit (that is: edit_group != teacher|student )
         if ($proplist['edit_group'] == 'teachers' and isteacherinanycourse($USER->id)) {
             $can_edit = 1;
             $link2room = ' <a href="itemeditor.php?id=' . $cmid . '&newid=' . $itemid . '">Edit Item</a>';
         } else {
             if ($proplist['edit_group'] == 'students') {
                 $can_edit = 1;
             }
         }
     }
     // intended to give edit-rights to named users
     // these users have admin rights, can delete/edit any booking
     if (isset($proplist['edit_list'])) {
         if (strstr($proplist['edit_list'], $username)) {
             $can_edit = 2;
         }
     }
     if (isadmin()) {
         /// no matter what, admin can edit - even past dates
         $can_edit = 2;
         $link2room = ' <a href="itemeditor.php?id=' . $cmid . '&newid=' . $itemid . '">Edit Item</a>';
     }
     /// this is where we make the reservation or delete reservations
     if (isset($subitemid) and $can_edit) {
         $orig_res = $main_reservation[$tidx][$jday];
         // print_r($orig_res);
         // print "UID = $UID<p>";
         $value = isset($value) ? $value : $username;
         if (isset($edit) and ($can_edit == 2 or $UID == $orig_res->userid)) {
             print "<table><tr><td>";
             print '<script type="text/javascript" src="http://localhost/moodle/lib/editor/htmlarea.php?id=3"></script>
             <script type="text/javascript" src="http://localhost/moodle/lib/editor/lang/en.php"></script>';
             helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
             echo "<br />";
             helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
             echo "<br />";
             if ($usehtmleditor) {
                 helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
             } else {
                 emoticonhelpbutton("form", "description");
             }
             echo "</td><td>";
             print_textarea($usehtmleditor, 20, 60, 680, 400, "value", $orig_res->value);
             if ($usehtmleditor) {
                 echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
             } else {
                 echo '<div align="right">';
                 helpbutton("textformat", get_string("formattexttype"));
                 print_string("formattexttype");
                 echo ':&nbsp;';
                 if (!$form->format) {
                     $form->format = $defaultformat;
                 }
                 choose_from_menu(format_text_menu(), "format", $form->format, "");
                 echo '</div>';
             }
             print "<script language=\"javascript\" type=\"text/javascript\" defer=\"defer\">\n                var config = new HTMLArea.Config();\n                config.pageStyle = \"body { background-color: #ffffff; font-family: Trebuchet MS,Verdana,Arial,Helvetica,sans-serif; }\";\n                config.killWordOnPaste = true;\n                config.fontname = {\n                \"Trebuchet\":    'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif',\n                \"Arial\":    'arial,helvetica,sans-serif',\n                \"Courier New\":  'courier new,courier,monospace',\n                \"Georgia\":  'georgia,times new roman,times,serif',\n                \"Tahoma\":   'tahoma,arial,helvetica,sans-serif',\n                \"Times New Roman\":  'times new roman,times,serif',\n                \"Verdana\":  'verdana,arial,helvetica,sans-serif',\n                \"Impact\":   'impact',\n                \"Wingdings\":    'wingdings'};\n                HTMLArea.replaceAll(config);\n                </script>";
             print '<input type="submit" name="save" value="save" />';
             print "</td></tr></table>";
             print '<input type="hidden" name="subitemid" value="' . $subitemid . '" />';
             print '<input type="hidden" name="tidx" value="' . $tidx . '" />';
             print '<input type="hidden" name="jday" value="' . $jday . '" />';
             print '<input type="hidden" name="resid" value="' . $resid . '" />';
             print "</form>";
             return;
         }
         if (isset($resid) and ($orig_res->userid == $UID or $can_edit == 2)) {
             $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar 
                     WHERE id=' . $resid;
             execute_sql($sql, 0);
             unset($main_reservation[$tidx][$jday]);
         }
         unset($res);
         if (isset($restore)) {
             $res->start = 0;
             $value = $orig_res->value;
         }
         if (isset($delete) and ($orig_res->userid == $UID or $can_edit == 2)) {
             if ($orig_res->start != -1) {
                 $res->start = -1;
                 $value = $orig_res->value;
                 unset($delete);
             }
         }
         if (!isset($delete)) {
             $res->name = $username;
             $res->value = $value;
             $res->bookingid = $this->bookings->id;
             $res->userid = $UID;
             $res->eventtype = 'reservation';
             $res->itemid = $iteminfo[$tidx]->id;
             $res->julday = $jday;
             if ($returnid = insert_record("bookings_calendar", $res)) {
                 $res->id = $returnid;
                 $main_reservation[$tidx][$jday] = $res;
             }
         }
     }
     $html = $link2room;
     // now we draw up the table
     // print_r($childlist);
     $html .= '<table border=2><tr><th>' . get_string('week') . '</th>';
     foreach ($childlist as $child) {
         $html .= '<th>' . $child->name . ' ' . $child->image . '</th>';
     }
     $html .= '</tr>';
     $count = count($childlist);
     /// $widthprcent = (int)(95 / $count ) ;    // default width
     $julday = $sjday;
     $date = jdtogregorian($julday);
     list($m1, $d1, $y) = explode('/', $date);
     $time = mktime(12, 0, 0, $m1, $d1, $y);
     while ($julday < $ejday) {
         $baselink = '<a href="view.php?id=' . $cmid . '&jday=' . $julday;
         $date = jdtogregorian($julday);
         list($m, $d, $y) = explode('/', $date);
         $date = jdtogregorian($julday + 6);
         list($m1, $d1, $y) = explode('/', $date);
         $monthname = userdate($time, '%b');
         $date = sprintf("%02d.%02d-%02d.%02d", $d, $m, $d1, $m1);
         $html .= "<tr><th><a name=\"jd{$julday}\">" . bookings_week($julday) . "</a><div class='mod-bookings tiny'>{$monthname} {$date}<div></th>";
         for ($idx = 0; $idx < $count; $idx++) {
             if (isset($main_reservation[$idx][$julday])) {
                 $res = $main_reservation[$idx][$julday];
                 $class = 'reserved';
                 if ($can_edit and ($res->userid == $UID or $can_edit == 2)) {
                     // $linktext = $main_reservation[$idx][$julday]->value;
                     $resid = $res->id;
                     $link = $res->value . '<br>';
                     if ($res->start == -1) {
                         $class = 'deleted';
                         $link .= $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '&restore=1&resid=' . $resid . '#jd' . $julday . '" title="Restore" ><img src="' . $CFG->pixpath . '/i/restore.gif" ' . ' height="14" width="14" border="0" alt="Restore" /></a> ';
                     } else {
                         $link .= $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '&edit=1&resid=' . $resid . '#jd' . $julday . '" title="Edit" ><img src="' . $CFG->pixpath . '/t/edit.gif" ' . ' height="12" width="12" border="0" alt="Edit" /></a> ';
                     }
                     $link .= $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '&delete=1&resid=' . $resid . '#jd' . $julday . '" title="Delete" ><img src="' . $CFG->pixpath . '/t/delete.gif" ' . ' height="12" width="12" border="0" alt="Delete" /></a>';
                 } else {
                     $link = get_string('reserved', 'bookings');
                     if ($can_edit) {
                         $link = $res->value;
                     }
                 }
             } else {
                 $linktext = 'free';
                 $class = 'free';
                 $link = $can_edit ? $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '#jd' . $julday . '">' . get_string('free', 'bookings') . '</a>' : get_string('free', 'bookings');
             }
             $html .= "<td class='{$class}'>{$link}</td>\n";
         }
         $julday += 7;
         $time += WEEKSECS;
         $html .= "</tr>";
     }
     $html .= "</table>";
     $html .= '<input type="hidden" name="itemid" value="' . $itemid . '">';
     print $html;
     if ($can_edit > 0) {
         unset($table);
         $table->head = array('&nbsp;', get_string('bookedby', 'bookings'));
         $table->align = array('center', 'left');
         $table->wrap = array('nowrap', 'nowrap');
         $table->width = '100%';
         $table->size = array(10, '*');
         $table->head[] = get_string('week');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         $table->head[] = get_string('date');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         $table->head[] = get_string('reservation', 'bookings');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         $table->head[] = get_string('item', 'bookings');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         // $books = get_records('calendar', 'bookingid', $this->bookings->id);
         $itemid_list = implode(',', $itemid_list);
         /// WHERE r.bookingid = '{$this->bookings->id}'
         if ($books = get_records_sql("SELECT r.*, u.firstname, u.lastname, u.picture, u.email\n                                FROM {$CFG->prefix}bookings_calendar r,\n                                    {$CFG->prefix}user u\n                                WHERE r.itemid in ( {$itemid_list} )\n                                AND r.julday >= {$sjday}\n                                AND r.julday <= {$ejday}\n                                AND r.userid = u.id ORDER BY r.itemid,r.julday")) {
             foreach ($books as $request) {
                 $row = array();
                 $row[] = print_user_picture($request->userid, $course->id, $request->picture, 0, true);
                 $row[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $request->userid . '&course=' . $course->id . '">' . $request->lastname . ' ' . $request->firstname . '</a>';
                 $date = jdtogregorian($request->julday);
                 list($m1, $d1, $y) = explode('/', $date);
                 $time = mktime(12, 0, 0, $m1, $d1, $y);
                 $monthname = userdate($time, '%b');
                 $date = jdtogregorian($request->julday + 6);
                 list($m1, $d1, $y) = explode('/', $date);
                 $date = sprintf("%02d.%02d-%02d.%02d", $d, $m, $d1, $m1);
                 $row[] = get_string('week') . bookings_week($request->julday);
                 $row[] = " {$monthname} " . $date;
                 $row[] = $request->value;
                 $row[] = $childlist[$request->itemid]->name;
                 $table->data[] = $row;
             }
             print "<p>";
             print_table($table);
         }
     }
     print "</form>";
     return;
 }
     echo ' : ';
     make_grading_menu($brainstorm, 'feedback', @$gradeset->feedback, false);
 }
 // print a final feedback form
 echo '<br/><br/><table width="80%"><tr valign="top"><td><b>' . get_string('feedback') . ':</b></td><td>';
 $usehtmleditor = can_use_html_editor();
 print_textarea($usehtmleditor, 20, 50, 680, 400, 'teacherfeedback', @$report->feedback);
 if (!$usehtmleditor) {
     echo '<p align="right">';
     helpbutton('textformat', get_string('formattexttype'));
     print_string('formattexttype');
     echo ":&nbsp;";
     if (empty($report->feedbackformat)) {
         $report->feedbackformat = FORMAT_MOODLE;
     }
     choose_from_menu(format_text_menu(), 'feedbackformat', $report->feedbackformat, '');
 } else {
     $htmleditorneeded = 1;
 }
 echo '</td></tr></table>';
 // if single grading, print a single grade scale
 if ($brainstorm->singlegrade) {
     echo '<br/>';
     print_string('grade');
     echo ' : ';
     make_grading_menu($brainstorm, 'grade', @$gradeset->single, false);
 }
 /// print the submit button
 echo '<br/><center>';
 echo "<br/><input type=\"submit\" name=\"go_btn\" value=\"" . get_string('update') . '" />';
 /// end form
Example #15
0
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package    plugintype
 * @subpackage pluginname
 * @copyright  2010 David Mudrak <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    $settings->add(new admin_setting_configmulticheckbox('filter_urltolink/formats', get_string('settingformats', 'filter_urltolink'), get_string('settingformats_desc', 'filter_urltolink'), array(FORMAT_MOODLE => 1), format_text_menu()));
    $settings->add(new admin_setting_configcheckbox('filter_urltolink/embedimages', get_string('embedimages', 'filter_urltolink'), get_string('embedimages_desc', 'filter_urltolink'), 1));
}
Example #16
0
 /**
  * Returns the list of supported comment text formats.
  *
  * @return array
  */
 protected function get_comment_formats()
 {
     return format_text_menu();
 }
Example #17
0
 function toHtml()
 {
     global $CFG, $COURSE, $PAGE;
     if ($this->_flagFrozen) {
         return $this->getFrozenHtml();
     }
     $id = $this->_attributes['id'];
     $elname = $this->_attributes['name'];
     $subdirs = $this->_options['subdirs'];
     $maxbytes = $this->_options['maxbytes'];
     $maxfiles = $this->_options['maxfiles'];
     $changeformat = $this->_options['changeformat'];
     // TO DO: implement as ajax calls
     $text = $this->_values['text'];
     $format = $this->_values['format'];
     $draftitemid = $this->_values['itemid'];
     // security - never ever allow guest/not logged in user to upload anything
     if (isguestuser() or !isloggedin()) {
         $maxfiles = 0;
     }
     $str = $this->_getTabs();
     $str .= '<div>';
     $editor = get_preferred_texteditor($format);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     /// print text area - TODO: add on-the-fly switching, size configuration, etc.
     $editor->use_editor($id, $this->_options);
     $ctx = $this->_options['context'];
     $str .= '<div><textarea id="' . $id . '" name="' . $elname . '[text]" rows="15" cols="80">';
     $str .= s($text);
     $str .= '</textarea></div>';
     $str .= '<div>';
     $str .= '<select name="' . $elname . '[format]">';
     foreach ($formats as $key => $desc) {
         $selected = $format == $key ? 'selected="selected"' : '';
         $str .= '<option value="' . s($key) . '" ' . $selected . '>' . $desc . '</option>';
     }
     $str .= '</select>';
     $str .= '</div>';
     if ($maxfiles != 0) {
         // 0 means no files, -1 unlimited
         if (empty($draftitemid)) {
             // no existing area info provided - let's use fresh new draft area
             require_once "{$CFG->libdir}/filelib.php";
             $this->setValue(array('itemid' => file_get_unused_draft_itemid()));
             $draftitemid = $this->_values['itemid'];
         }
         $str .= '<div><input type="hidden" name="' . $elname . '[itemid]" value="' . $draftitemid . '" /></div>';
         /// embedded image files - TODO: hide on the fly when switching editors
         $str .= '<div id="' . $id . '_filemanager">';
         $editorurl = "{$CFG->wwwroot}/repository/filepicker.php?action=embedded&amp;itemid={$draftitemid}&amp;subdirs={$subdirs}&amp;maxbytes={$maxbytes}&amp;ctx_id=" . $ctx->id;
         $str .= '<object type="text/html" data="' . $editorurl . '" height="160" width="600" style="border:1px solid #000">Error</object>';
         // TODO: localise, fix styles, etc.
         $str .= '</div>';
         require_once $CFG->dirroot . '/repository/lib.php';
         $client_id = uniqid();
         $repojs = repository_get_client($ctx, $client_id, array('image', 'video', 'media'), '*');
         $str .= $repojs;
         $str .= $PAGE->requires->js_function_call('id2_add_clientid', array($id, $client_id))->asap();
         $str .= $PAGE->requires->js_function_call('id2_add_itemid', array($id, $draftitemid))->asap();
         if ($editor->supports_repositories()) {
             $str .= $PAGE->requires->js_function_call('hide_item', array("{$id}_filemanager"))->asap();
         }
     }
     $str .= '</div>';
     return $str;
 }
    emoticonhelpbutton("form", "description");
}
?>
    </td>
    <td>
    <?php 
print_textarea($this->usehtmleditor, 20, 60, 680, 400, "data", $data);
if ($this->usehtmleditor) {
    use_html_editor('');
    echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
} else {
    echo '<div align="right">';
    helpbutton("textformat", get_string("formattexttype"));
    print_string("formattexttype");
    echo ':&nbsp;';
    choose_from_menu(format_text_menu(), "format", $this->defaultformat, "");
    echo '</div>';
}
?>
    </td>
</tr>
<tr valign="top">
    <td colspan="2" align="center" ><input type="submit" value="<?php 
print_string("savechanges");
?>
" /></td>
</tr>


</table>
Example #19
0
 /**
  *  Display a single submission, ready for grading on a popup window
  * Justin: I just lifted this from assignments/lib.php because  I needed to show the conversation entries properly.beneath the feedback form.
  * This default method prints the teacher info and submissioncomment box at the top and
  * the student info and submission at the bottom.
  * This method also fetches the necessary data in order to be able to
  * provide a "Next submission" button.
  * Calls preprocess_submission() to give assignment type plug-ins a chance
  * to process submissions before they are graded
  * This method gets its arguments from the page parameters userid and offset
  */
 function display_submission($extra_javascript = '')
 {
     global $CFG;
     require_once $CFG->libdir . '/gradelib.php';
     require_once $CFG->libdir . '/tablelib.php';
     $userid = required_param('userid', PARAM_INT);
     $offset = required_param('offset', PARAM_INT);
     //offset for where to start looking for student.
     if (!($user = get_record('user', 'id', $userid))) {
         error('No such user!');
     }
     if (!($submission = $this->get_submission($user->id))) {
         $submission = $this->prepare_new_submission($userid);
     }
     if ($submission->timemodified > $submission->timemarked) {
         $subtype = 'assignmentnew';
     } else {
         $subtype = 'assignmentold';
     }
     $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($user->id));
     $disabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
     /// construct SQL, using current offset to find the data of the next student
     $course = $this->course;
     $assignment = $this->assignment;
     $cm = $this->cm;
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// Get all ppl that can submit assignments
     $currentgroup = groups_get_activity_group($cm);
     if ($users = get_users_by_capability($context, 'mod/assignment:submit', 'u.id', '', '', '', $currentgroup, '', false)) {
         $users = array_keys($users);
     }
     // if groupmembersonly used, remove users who are not in any group
     if ($users and !empty($CFG->enablegroupings) and $cm->groupmembersonly) {
         if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
             $users = array_intersect($users, array_keys($groupingusers));
         }
     }
     $nextid = 0;
     if ($users) {
         $select = 'SELECT u.id, u.firstname, u.lastname, u.picture, u.imagealt,
                           s.id AS submissionid, s.grade, s.submissioncomment,
                           s.timemodified, s.timemarked,
                           COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ';
         $sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'assignment_submissions s ON u.id = s.userid
                                                                   AND s.assignment = ' . $this->assignment->id . ' ' . 'WHERE u.id IN (' . implode(',', $users) . ') ';
         if ($sort = flexible_table::get_sql_sort('mod-assignment-submissions')) {
             $sort = 'ORDER BY ' . $sort . ' ';
         }
         if (($auser = get_records_sql($select . $sql . $sort, $offset + 1, 1)) !== false) {
             $nextuser = array_shift($auser);
             /// Calculate user status
             $nextuser->status = $nextuser->timemarked > 0 && $nextuser->timemarked >= $nextuser->timemodified;
             $nextid = $nextuser->id;
         }
     }
     print_header(get_string('feedback', 'assignment') . ':' . fullname($user, true) . ':' . format_string($this->assignment->name));
     /// Print any extra javascript needed for saveandnext
     echo $extra_javascript;
     ///SOme javascript to help with setting up >.>
     echo '<script type="text/javascript">' . "\n";
     echo 'function setNext(){' . "\n";
     echo 'document.getElementById(\'submitform\').mode.value=\'next\';' . "\n";
     echo 'document.getElementById(\'submitform\').userid.value="' . $nextid . '";' . "\n";
     echo '}' . "\n";
     echo 'function saveNext(){' . "\n";
     echo 'document.getElementById(\'submitform\').mode.value=\'saveandnext\';' . "\n";
     echo 'document.getElementById(\'submitform\').userid.value="' . $nextid . '";' . "\n";
     echo 'document.getElementById(\'submitform\').saveuserid.value="' . $userid . '";' . "\n";
     echo 'document.getElementById(\'submitform\').menuindex.value = document.getElementById(\'submitform\').grade.selectedIndex;' . "\n";
     echo '}' . "\n";
     echo '</script>' . "\n";
     echo '<table cellspacing="0" class="feedback ' . $subtype . '" >';
     ///Start of teacher info row
     echo '<tr>';
     echo '<td class="picture teacher">';
     //Edited by justin 20081003: otherwise regardlss of which teacher is logged in ,
     //first teacher to write in journal would be shown,
     //if ($submission->teacher) {
     if (false) {
         $teacher = get_record('user', 'id', $submission->teacher);
     } else {
         global $USER;
         $teacher = $USER;
     }
     print_user_picture($teacher, $this->course->id, $teacher->picture);
     echo '</td>';
     echo '<td class="content">';
     echo '<form id="submitform" action="submissions.php" method="post">';
     echo '<div>';
     // xhtml compatibility - invisiblefieldset was breaking layout here
     echo '<input type="hidden" name="offset" value="' . ($offset + 1) . '" />';
     echo '<input type="hidden" name="userid" value="' . $userid . '" />';
     echo '<input type="hidden" name="id" value="' . $this->cm->id . '" />';
     echo '<input type="hidden" name="mode" value="grade" />';
     echo '<input type="hidden" name="menuindex" value="0" />';
     //selected menu index
     //new hidden field, initialized to -1.
     echo '<input type="hidden" name="saveuserid" value="-1" />';
     if ($submission->timemarked) {
         echo '<div class="from">';
         echo '<div class="fullname">' . fullname($teacher, true) . '</div>';
         echo '<div class="time">' . userdate($submission->timemarked) . '</div>';
         echo '</div>';
     }
     //if we are grading journals
     if ($this->assignment->grade > 0) {
         echo '<div class="grade"><label for="menugrade">' . get_string('grade') . '</label> ';
         choose_from_menu(make_grades_menu($this->assignment->grade), 'grade', $submission->grade, get_string('nograde'), '', -1, false, $disabled);
         echo '</div>';
         echo '<div class="clearer"></div>';
         echo '<div class="finalgrade">' . get_string('finalgrade', 'grades') . ': ' . $grading_info->items[0]->grades[$userid]->str_grade . '</div>';
         echo '<div class="clearer"></div>';
         if (!empty($CFG->enableoutcomes)) {
             foreach ($grading_info->outcomes as $n => $outcome) {
                 echo '<div class="outcome"><label for="menuoutcome_' . $n . '">' . $outcome->name . '</label> ';
                 $options = make_grades_menu(-$outcome->scaleid);
                 if ($outcome->grades[$submission->userid]->locked) {
                     $options[0] = get_string('nooutcome', 'grades');
                     echo $options[$outcome->grades[$submission->userid]->grade];
                 } else {
                     choose_from_menu($options, 'outcome_' . $n . '[' . $userid . ']', $outcome->grades[$submission->userid]->grade, get_string('nooutcome', 'grades'), '', 0, false, false, 0, 'menuoutcome_' . $n);
                 }
                 echo '</div>';
                 echo '<div class="clearer"></div>';
             }
         }
         //if we are not grading journals
     } else {
         echo '<input type="hidden" name="grade" value="-1" />';
     }
     $this->preprocess_submission($submission);
     if ($disabled) {
         echo '<div class="disabledfeedback">' . $grading_info->items[0]->grades[$userid]->str_feedback . '</div>';
     } else {
         //---------------Justin Video Message start 20090105-------------------
         if ($CFG->filter_poodll_journal_video || $CFG->filter_poodll_journal_audio) {
             echo '<a href="#" onclick="document.getElementById(\'teacherrecorder\').style.display=\'block\';">Record Audio/Video</a>';
             echo "<div id='teacherrecorder' style='display: none'>";
             //$rtmplink = "rtmp://{$CFG->rtmp}";
             $rtmplink = $CFG->poodll_media_server;
             //$filename='poodlljournal/' . $this->assignment->id . $submission->userid . time(). rand() . '.flv';
             $filename = 'moddata/assignment/' . $this->assignment->id . '/' . $submission->userid . '/teacher_' . time() . rand() . '.flv';
             $mediadata = fetch_teachersrecorder($filename, "mediafilename");
             echo $mediadata;
             echo '<input type="hidden" value="" id="mediafilename" name="mediafilename" />';
             echo "</div>";
         }
         //---------------Video Message end 20090105---------------------
         //Justin: We never edit old submissions so we show a blank area in the feedback box
         //print_textarea($this->usehtmleditor, 14, 58, 0, 0, 'submissioncomment', $submission->submissioncomment, $this->course->id);
         print_textarea($this->usehtmleditor, 14, 58, 0, 0, 'submissioncomment', "", $this->course->id);
         if ($this->usehtmleditor) {
             echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
         } else {
             echo '<div class="format">';
             choose_from_menu(format_text_menu(), "format", $submission->format, "");
             helpbutton("textformat", get_string("helpformatting"));
             echo '</div>';
         }
     }
     $lastmailinfo = get_user_preferences('assignment_mailinfo', 1) ? 'checked="checked"' : '';
     ///Print Buttons in Single View
     echo '<input type="hidden" name="mailinfo" value="0" />';
     echo '<input type="checkbox" id="mailinfo" name="mailinfo" value="1" ' . $lastmailinfo . ' /><label for="mailinfo">' . get_string('enableemailnotification', 'assignment') . '</label>';
     echo '<div class="buttons">';
     echo '<input type="submit" name="submit" value="' . get_string('savechanges') . '" onclick = "document.getElementById(\'submitform\').menuindex.value = document.getElementById(\'submitform\').grade.selectedIndex" />';
     echo '<input type="submit" name="cancel" value="' . get_string('cancel') . '" />';
     //if there are more to be graded.
     if ($nextid) {
         echo '<input type="submit" name="saveandnext" value="' . get_string('saveandnext') . '" onclick="saveNext()" />';
         echo '<input type="submit" name="next" value="' . get_string('next') . '" onclick="setNext();" />';
     }
     echo '</div>';
     echo '</div></form>';
     $customfeedback = $this->custom_feedbackform($submission, true);
     if (!empty($customfeedback)) {
         echo $customfeedback;
     }
     echo '</td></tr>';
     ///End of teacher info row, Start of student info row
     if (!empty($submission)) {
         $comments = explode(COMMENTSDELIM, $submission->data1);
         foreach ($comments as $comment) {
             $commentParts = explode(PARTSDELIM, $comment);
             if (sizeof($commentParts) > 2) {
                 $feedback = $commentParts[0];
                 $personId = $commentParts[1];
                 $comment_date = $commentParts[2];
                 $person = get_record('user', 'id', $personId);
                 /// Print the feedback
                 //print_heading(get_string('feedbackfromteacher', 'assignment', $this->course->teacher));
                 //echo '<table cellspacing="0" class="feedback">';
                 echo '<tr>';
                 echo '<td class="left picture">';
                 if ($person) {
                     print_user_picture($person, $this->course->id, $person->picture);
                 }
                 echo '</td>';
                 echo '<td class="topic">';
                 echo '<div class="from">';
                 if ($person) {
                     echo '<div class="fullname">' . fullname($person) . '</div>';
                 }
                 echo '<div class="time">' . userdate($comment_date) . '</div>';
                 echo '</div>';
                 echo '</td>';
                 echo '</tr>';
                 echo '<tr>';
                 echo '<td class="content" colspan="2">';
                 echo '<div class="comment">';
                 echo format_text($feedback);
                 echo '</div>';
                 echo '</td>';
                 echo '</tr>';
             }
             //end of if sizeof > 2
         }
         //end of for each
     }
     //end of if submission not empty
     ///End of student info row
     echo '</table>';
     if (!$disabled and $this->usehtmleditor) {
         use_html_editor();
     }
     print_footer('none');
 }
Example #20
0
 public function response_area_input($name, $qa, $step, $lines, $context)
 {
     global $CFG;
     require_once $CFG->dirroot . '/repository/lib.php';
     $inputname = $qa->get_qt_field_name($name);
     $responseformat = $step->get_qt_var($name . 'format');
     $id = $inputname . '_id';
     $editor = editors_get_preferred_editor($responseformat);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     list($draftitemid, $reponse) = $this->prepare_response_for_editing($name, $step, $context);
     $editor->use_editor($id, $this->get_editor_options($context), $this->get_filepicker_options($context, $draftitemid));
     $output = '';
     $output .= html_writer::start_tag('div', array('class' => $this->class_name() . ' qtype_essay_response'));
     $output .= html_writer::tag('div', html_writer::tag('textarea', s($reponse), array('id' => $id, 'name' => $inputname, 'rows' => $lines, 'cols' => 60)));
     $output .= html_writer::start_tag('div');
     if (count($formats == 1)) {
         reset($formats);
         $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $inputname . 'format', 'value' => key($formats)));
     } else {
         $output .= html_writer::select($formats, $inputname . 'format', $responseformat, '');
     }
     $output .= html_writer::end_tag('div');
     $output .= $this->filepicker_html($inputname, $draftitemid);
     $output .= html_writer::end_tag('div');
     return $output;
 }
         $commenteditor .= "<input type=\"hidden\" name=\"page\" value=\"appointments\" />\n";
         $commenteditor .= "<input type=\"hidden\" name=\"id\" value=\"{$cm->id}\" />\n";
         $commenteditor .= "<input type=\"hidden\" name=\"studentid\" value=\"{$studentid}\" />\n";
         $commenteditor .= "<input type=\"hidden\" name=\"appid\" value=\"{$slot->appid}\" />\n";
         $commenteditor .= print_textarea($usehtmleditor, 20, 60, 400, 200, 'appointmentnote', $slot->appointmentnote, $COURSE->id, true);
         if ($usehtmleditor) {
             $commenteditor .= "<input type=\"hidden\" name=\"format\" value=\"FORMAT_HTML\" />\n";
         } else {
             $commenteditor .= '<p align="right">';
             $commenteditor .= helpbutton('textformat', get_string('formattexttype'), 'moodle', true, false, '', true);
             $commenteditor .= get_string('formattexttype');
             $commenteditor .= ':&nbsp;';
             if (!$form->format) {
                 $form->format = 'MOODLE';
             }
             $commenteditor .= choose_from_menu(format_text_menu(), 'format', $form->format, '', 'choose', '', 0, true);
             $commenteditor .= '</p>';
         }
         $commenteditor .= $distributecheck;
         $commenteditor .= "</form>";
         $table->data[] = array($slot->notes . '<br/><font size=-2>' . $startdate . ' ' . $starttime . ' to ' . $endtime . '</font>', $commenteditor, $actions);
     }
 }
 // print slots table
 if ($page == 'appointments') {
     echo '<form name="studentform" action="view.php" method="post">';
     echo "<input type=\"hidden\" name=\"id\" value=\"{$cm->id}\" />\n";
     echo "<input type=\"hidden\" name=\"subaction\" value=\"updategrades\" />\n";
     echo "<input type=\"hidden\" name=\"what\" value=\"viewstudent\" />\n";
     echo "<input type=\"hidden\" name=\"page\" value=\"appointments\" />\n";
     echo "<input type=\"hidden\" name=\"studentid\" value=\"{$studentid}\" />\n";
Example #22
0
    function display_add_field($recordid=0) {
        global $CFG, $DB, $OUTPUT, $PAGE;

        $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();
            if (can_use_html_editor()) {
                $format = FORMAT_HTML;
            } else {
                $format = FORMAT_PLAIN;
            }
        }

        // get filepicker info
        //
        $fpoptions = array();
        if ($options['maxfiles'] != 0 ) {
            $args = new stdClass();
            // need these three to filter repositories list
            $args->accepted_types = array('web_image');
            $args->return_types = (FILE_INTERNAL | FILE_EXTERNAL);
            $args->context = $this->context;
            $args->env = 'filepicker';
            // advimage plugin
            $image_options = initialise_filepicker($args);
            $image_options->context = $this->context;
            $image_options->client_id = uniqid();
            $image_options->maxbytes = $options['maxbytes'];
            $image_options->env = 'editor';
            $image_options->itemid = $draftitemid;

            // moodlemedia plugin
            $args->accepted_types = array('video', 'audio');
            $media_options = initialise_filepicker($args);
            $media_options->context = $this->context;
            $media_options->client_id = uniqid();
            $media_options->maxbytes  = $options['maxbytes'];
            $media_options->env = 'editor';
            $media_options->itemid = $draftitemid;

            // advlink plugin
            $args->accepted_types = '*';
            $link_options = initialise_filepicker($args);
            $link_options->context = $this->context;
            $link_options->client_id = uniqid();
            $link_options->maxbytes  = $options['maxbytes'];
            $link_options->env = 'editor';
            $link_options->itemid = $draftitemid;

            $fpoptions['image'] = $image_options;
            $fpoptions['media'] = $media_options;
            $fpoptions['link'] = $link_options;
        }

        $editor = editors_get_preferred_editor($format);
        $strformats = format_text_menu();
        $formats =  $editor->get_supported_formats();
        foreach ($formats as $fid) {
            $formats[$fid] = $strformats[$fid];
        }
        $editor->use_editor($field, $options, $fpoptions);
        $str .= '<input type="hidden" name="'.$field.'_itemid" value="'.$draftitemid.'" />';
        $str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="'.$this->field->param3.'" cols="'.$this->field->param2.'">'.s($text).'</textarea></div>';
        $str .= '<div><select name="'.$field.'_content1">';
        foreach ($formats as $key=>$desc) {
            $selected = ($format == $key) ? 'selected="selected"' : '';
            $str .= '<option value="'.s($key).'" '.$selected.'>'.$desc.'</option>';
        }
        $str .= '</select>';
        $str .= '</div>';

        $str .= '</div>';
        return $str;
    }
Example #23
0
 /**
  *  Display a single submission, ready for grading on a popup window
  *
  * This default method prints the teacher info and submissioncomment box at the top and
  * the student info and submission at the bottom.
  * This method also fetches the necessary data in order to be able to
  * provide a "Next submission" button.
  * Calls preprocess_submission() to give assignment type plug-ins a chance
  * to process submissions before they are graded
  * This method gets its arguments from the page parameters userid and offset
  */
 function display_submission($extra_javascript = '')
 {
     global $CFG;
     require_once $CFG->libdir . '/gradelib.php';
     $userid = required_param('userid', PARAM_INT);
     $offset = required_param('offset', PARAM_INT);
     //offset for where to start looking for student.
     if (!($user = get_record('user', 'id', $userid))) {
         error('No such user!');
     }
     if (!($submission = $this->get_submission($user->id))) {
         $submission = $this->prepare_new_submission($userid);
     }
     if ($submission->timemodified > $submission->timemarked) {
         $subtype = 'assignmentnew';
     } else {
         $subtype = 'assignmentold';
     }
     $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($user->id));
     $disabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
     /// construct SQL, using current offset to find the data of the next student
     $course = $this->course;
     $assignment = $this->assignment;
     $cm = $this->cm;
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// Get all ppl that can submit assignments
     $currentgroup = groups_get_activity_group($cm);
     $users = get_users_by_capability($context, 'mod/assignment:submit', 'u.id, u.id', '', '', '', $currentgroup, '', false);
     $select = 'SELECT u.id, u.firstname, u.lastname, u.picture,
                       s.id AS submissionid, s.grade, s.submissioncomment,
                       s.timemodified, s.timemarked,
                       COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ';
     $sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'assignment_submissions s ON u.id = s.userid
                                                               AND s.assignment = ' . $this->assignment->id . ' ' . 'WHERE u.id IN (' . implode(',', array_keys($users)) . ') ';
     require_once $CFG->libdir . '/tablelib.php';
     if ($sort = flexible_table::get_sql_sort('mod-assignment-submissions')) {
         $sort = 'ORDER BY ' . $sort . ' ';
     }
     $nextid = 0;
     if (($auser = get_records_sql($select . $sql . $sort, $offset + 1, 1)) !== false) {
         $nextuser = array_shift($auser);
         /// Calculate user status
         $nextuser->status = $nextuser->timemarked > 0 && $nextuser->timemarked >= $nextuser->timemodified;
         $nextid = $nextuser->id;
     }
     print_header(get_string('feedback', 'assignment') . ':' . fullname($user, true) . ':' . format_string($this->assignment->name));
     /// Print any extra javascript needed for saveandnext
     echo $extra_javascript;
     ///SOme javascript to help with setting up >.>
     echo '<script type="text/javascript">' . "\n";
     echo 'function setNext(){' . "\n";
     echo 'document.getElementById(\'submitform\').mode.value=\'next\';' . "\n";
     echo 'document.getElementById(\'submitform\').userid.value="' . $nextid . '";' . "\n";
     echo '}' . "\n";
     echo 'function saveNext(){' . "\n";
     echo 'document.getElementById(\'submitform\').mode.value=\'saveandnext\';' . "\n";
     echo 'document.getElementById(\'submitform\').userid.value="' . $nextid . '";' . "\n";
     echo 'document.getElementById(\'submitform\').saveuserid.value="' . $userid . '";' . "\n";
     echo 'document.getElementById(\'submitform\').menuindex.value = document.getElementById(\'submitform\').grade.selectedIndex;' . "\n";
     echo '}' . "\n";
     echo '</script>' . "\n";
     echo '<table cellspacing="0" class="feedback ' . $subtype . '" >';
     ///Start of teacher info row
     echo '<tr>';
     echo '<td class="picture teacher">';
     if ($submission->teacher) {
         $teacher = get_record('user', 'id', $submission->teacher);
     } else {
         global $USER;
         $teacher = $USER;
     }
     print_user_picture($teacher->id, $this->course->id, $teacher->picture);
     echo '</td>';
     echo '<td class="content">';
     echo '<form id="submitform" action="submissions.php" method="post">';
     echo '<div>';
     // xhtml compatibility - invisiblefieldset was breaking layout here
     echo '<input type="hidden" name="offset" value="' . ($offset + 1) . '" />';
     echo '<input type="hidden" name="userid" value="' . $userid . '" />';
     echo '<input type="hidden" name="id" value="' . $this->cm->id . '" />';
     echo '<input type="hidden" name="mode" value="grade" />';
     echo '<input type="hidden" name="menuindex" value="0" />';
     //selected menu index
     //new hidden field, initialized to -1.
     echo '<input type="hidden" name="saveuserid" value="-1" />';
     if ($submission->timemarked) {
         echo '<div class="from">';
         echo '<div class="fullname">' . fullname($teacher, true) . '</div>';
         echo '<div class="time">' . userdate($submission->timemarked) . '</div>';
         echo '</div>';
     }
     echo '<div class="grade"><label for="menugrade">' . get_string('grade') . '</label> ';
     choose_from_menu(make_grades_menu($this->assignment->grade), 'grade', $submission->grade, get_string('nograde'), '', -1, false, $disabled);
     echo '</div>';
     echo '<div class="clearer"></div>';
     echo '<div class="finalgrade">' . get_string('finalgrade', 'grades') . ': ' . $grading_info->items[0]->grades[$userid]->str_grade . '</div>';
     echo '<div class="clearer"></div>';
     if (!empty($CFG->enableoutcomes)) {
         foreach ($grading_info->outcomes as $n => $outcome) {
             echo '<div class="outcome"><label for="menuoutcome_' . $n . '">' . $outcome->name . '</label> ';
             $options = make_grades_menu(-$outcome->scaleid);
             if ($outcome->grades[$submission->userid]->locked) {
                 $options[0] = get_string('nooutcome', 'grades');
                 echo $options[$outcome->grades[$submission->userid]->grade];
             } else {
                 choose_from_menu($options, 'outcome_' . $n . '[' . $userid . ']', $outcome->grades[$submission->userid]->grade, get_string('nooutcome', 'grades'), '', 0, false, false, 0, 'menuoutcome_' . $n);
             }
             echo '</div>';
             echo '<div class="clearer"></div>';
         }
     }
     $this->preprocess_submission($submission);
     if ($disabled) {
         echo '<div class="disabledfeedback">' . $grading_info->items[0]->grades[$userid]->str_feedback . '</div>';
     } else {
         print_textarea($this->usehtmleditor, 14, 58, 0, 0, 'submissioncomment', $submission->submissioncomment, $this->course->id);
         if ($this->usehtmleditor) {
             echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
         } else {
             echo '<div class="format">';
             choose_from_menu(format_text_menu(), "format", $submission->format, "");
             helpbutton("textformat", get_string("helpformatting"));
             echo '</div>';
         }
     }
     ///Print Buttons in Single View
     echo '<div class="buttons">';
     echo '<input type="submit" name="submit" value="' . get_string('savechanges') . '" onclick = "document.getElementById(\'submitform\').menuindex.value = document.getElementById(\'submitform\').grade.selectedIndex" />';
     echo '<input type="submit" name="cancel" value="' . get_string('cancel') . '" />';
     //if there are more to be graded.
     if ($nextid) {
         echo '<input type="submit" name="saveandnext" value="' . get_string('saveandnext') . '" onclick="saveNext()" />';
         echo '<input type="submit" name="next" value="' . get_string('next') . '" onclick="setNext();" />';
     }
     echo '</div>';
     echo '</div></form>';
     $customfeedback = $this->custom_feedbackform($submission, true);
     if (!empty($customfeedback)) {
         echo $customfeedback;
     }
     echo '</td></tr>';
     ///End of teacher info row, Start of student info row
     echo '<tr>';
     echo '<td class="picture user">';
     print_user_picture($user->id, $this->course->id, $user->picture);
     echo '</td>';
     echo '<td class="topic">';
     echo '<div class="from">';
     echo '<div class="fullname">' . fullname($user, true) . '</div>';
     if ($submission->timemodified) {
         echo '<div class="time">' . userdate($submission->timemodified) . $this->display_lateness($submission->timemodified) . '</div>';
     }
     echo '</div>';
     $this->print_user_files($user->id);
     echo '</td>';
     echo '</tr>';
     ///End of student info row
     echo '</table>';
     if (!$disabled and $this->usehtmleditor) {
         use_html_editor();
     }
     print_footer('none');
 }
Example #24
0
 $usehtmleditor = can_use_html_editor();
 echo '<fieldset class="clearfix">';
 echo '<legend class="ftoggler">' . get_string('send_message', 'questionnaire') . '</legend>';
 $id = 'message' . '_id';
 $subjecteditor = '&nbsp;&nbsp;&nbsp;<input type="text" id="questionnaire_subject" size="65"
     maxlength="255" name="subject" value="' . $subject . '" />';
 $format = '';
 if ($usehtmleditor) {
     $editor = editors_get_preferred_editor();
     $editor->use_editor($id, questionnaire_get_editor_options($context));
     $texteditor = html_writer::tag('div', html_writer::tag('textarea', '', array('id' => $id, 'name' => "message", '', '')));
     echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
 } else {
     $texteditor = html_writer::tag('div', html_writer::tag('textarea', '', array('id' => $id, 'name' => "message", 'rows' => 10, 'cols' => 65)));
     $formatlabel = '<label for="menuformat" class="accesshide">' . get_string('format') . '</label>';
     $format = '&nbsp;&nbsp;&nbsp;' . html_writer::select(format_text_menu(), "format", $format, "");
 }
 // Print editor.
 $table = new html_table();
 $table->align = array('left', 'left');
 $table->data[] = array('<strong>' . get_string('subject', 'questionnaire') . '</strong>', $subjecteditor);
 $table->data[] = array('<strong>' . get_string('messagebody') . '</strong>', $texteditor);
 if (!$usehtmleditor) {
     $table->data[] = array($formatlabel, $format);
 }
 echo html_writer::table($table);
 // Send button.
 echo $OUTPUT->box_start('mdl-left');
 echo '<div class="buttons">';
 echo '<input type="submit" name="send_message" value="' . get_string('send', 'questionnaire') . '" />';
 echo '</div>';
Example #25
-1
    function display_add_field($recordid = 0, $formdata = null) {
        global $CFG, $DB, $OUTPUT, $PAGE;

        $text   = '';
        $format = 0;
        $str = '<div title="' . s($this->field->description) . '">';
        $str .= '<label for="field_' . $this->field->id . '" class="accesshide">';
        $str .= html_writer::span($this->field->name);
        if ($this->field->required) {
            $image = html_writer::img($OUTPUT->pix_url('req'), get_string('requiredelement', 'form'),
                                     array('class' => 'req', 'title' => get_string('requiredelement', 'form')));
            $str .= html_writer::div($image, 'inline-req');
        }
        $str .= '</label>';

        editors_head_setup();
        $options = $this->get_options();

        $itemid = $this->field->id;
        $field = 'field_'.$itemid;

        if ($formdata) {
            $fieldname = 'field_' . $this->field->id . '_content1';
            if (isset($formdata->$fieldname)) {
                $format = $formdata->$fieldname;
            } else {
                $format = file_get_unused_draft_itemid();
            }
            $fieldname = 'field_' . $this->field->id . '_itemid';
            if (isset($formdata->$fieldname)) {
                $draftitemid = clean_param($formdata->$fieldname, PARAM_INT);
            } else {
                $draftitemid = file_get_unused_draft_itemid();
            }
            $fieldname = 'field_' . $this->field->id;
            if (isset($formdata->$fieldname)) {
                $text = $formdata->$fieldname;
            }
        } else 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();
            $format = FORMAT_HTML;
        }

        // get filepicker info
        //
        $fpoptions = array();
        if ($options['maxfiles'] != 0 ) {
            $args = new stdClass();
            // need these three to filter repositories list
            $args->accepted_types = array('web_image');
            $args->return_types = (FILE_INTERNAL | FILE_EXTERNAL);
            $args->context = $this->context;
            $args->env = 'filepicker';
            // advimage plugin
            $image_options = initialise_filepicker($args);
            $image_options->context = $this->context;
            $image_options->client_id = uniqid();
            $image_options->maxbytes = $options['maxbytes'];
            $image_options->env = 'editor';
            $image_options->itemid = $draftitemid;

            // moodlemedia plugin
            $args->accepted_types = array('video', 'audio');
            $media_options = initialise_filepicker($args);
            $media_options->context = $this->context;
            $media_options->client_id = uniqid();
            $media_options->maxbytes  = $options['maxbytes'];
            $media_options->env = 'editor';
            $media_options->itemid = $draftitemid;

            // advlink plugin
            $args->accepted_types = '*';
            $link_options = initialise_filepicker($args);
            $link_options->context = $this->context;
            $link_options->client_id = uniqid();
            $link_options->maxbytes  = $options['maxbytes'];
            $link_options->env = 'editor';
            $link_options->itemid = $draftitemid;

            $fpoptions['image'] = $image_options;
            $fpoptions['media'] = $media_options;
            $fpoptions['link'] = $link_options;
        }

        $editor = editors_get_preferred_editor($format);
        $strformats = format_text_menu();
        $formats =  $editor->get_supported_formats();
        foreach ($formats as $fid) {
            $formats[$fid] = $strformats[$fid];
        }
        $editor->set_text($text);
        $editor->use_editor($field, $options, $fpoptions);
        $str .= '<input type="hidden" name="'.$field.'_itemid" value="'.s($draftitemid).'" />';
        $str .= '<div class="mod-data-input">';
        $str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="'.$this->field->param3.'" cols="'.$this->field->param2.'" spellcheck="true">'.s($text).'</textarea></div>';
        $str .= '<div><label class="accesshide" for="' . $field . '_content1">' . get_string('format') . '</label>';
        $str .= '<select id="' . $field . '_content1" name="'.$field.'_content1">';
        foreach ($formats as $key=>$desc) {
            $selected = ($format == $key) ? 'selected="selected"' : '';
            $str .= '<option value="'.s($key).'" '.$selected.'>'.$desc.'</option>';
        }
        $str .= '</select>';

        $str .= '</div>';
        $str .= '</div>';
        $str .= '</div>';
        return $str;
    }