Example #1
0
 function toHtml()
 {
     if ($this->_canUseHtmlEditor && !$this->_flagFrozen) {
         ob_start();
         use_html_editor($this->getName(), '', $this->getAttribute('id'));
         $script = ob_get_clean();
     } else {
         $script = '';
     }
     if ($this->_flagFrozen) {
         return $this->getFrozenHtml();
     } else {
         return $this->_getTabs() . print_textarea($this->_canUseHtmlEditor, $this->_options['rows'], $this->_options['cols'], $this->_options['width'], $this->_options['height'], $this->getName(), preg_replace("/(\r\n|\n|\r)/", '
', $this->getValue()), $this->_options['course'], true, $this->getAttribute('id')) . $script;
     }
 }
Example #2
0
function show_edit_label($item, $usehtmleditor = false)
{
    $item->presentation = isset($item->presentation) ? $item->presentation : '';
    ?>
   <table style="display:inline">
      <tr><th><?php 
    print_string('label', 'feedback');
    ?>
</th></tr>
      <tr>
         <td>
            <?php 
    print_textarea($usehtmleditor, 20, 60, 680, 400, "presentation", $item->presentation);
    ?>
            <input type="hidden" id="itemname" name="itemname" value="label" />
         </td>
      </tr>
   </table>
   <div style="clear:both"></div>
<?php 
    if ($usehtmleditor) {
        use_html_editor();
    }
}
Example #3
0
}
if (empty($question->image)) {
    $question->image = "";
}
if (!isset($question->penalty)) {
    $question->penalty = 0.1;
}
if (!isset($question->defaultgrade)) {
    $question->defaultgrade = 1;
}
if (empty($question->generalfeedback)) {
    $question->generalfeedback = "";
}
// Set up some richtext editing if necessary
if ($usehtmleditor = can_use_richtext_editor()) {
    $defaultformat = FORMAT_HTML;
} else {
    $defaultformat = FORMAT_MOODLE;
}
if (isset($question->errors)) {
    $err = $question->errors;
}
// Print the question editing form
echo '<br />';
print_simple_box_start('center');
require_once 'type/' . $qtype . '/editquestion.php';
print_simple_box_end();
if ($usehtmleditor) {
    use_html_editor('questiontext');
}
print_footer($course);
/// Print the appropriate form
if (file_exists($filename)) {
    // We are in maintenance mode
    echo '<div style="margin-left:auto;margin-right:auto">';
    echo '<form action="maintenance.php" method="post">';
    echo '<input type="hidden" name="action" value="disable" />';
    echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
    echo '<p><input type="submit" value="' . get_string('disable') . '" /></p>';
    echo '</form>';
    echo '</div>';
} else {
    // We are not in maintenance mode
    $usehtmleditor = can_use_html_editor();
    echo '<div style="text-align:center;margin-left:auto;margin-right:auto">';
    echo '<form action="maintenance.php" method="post">';
    echo '<div>';
    echo '<input type="hidden" name="action" value="enable" />';
    echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
    echo '<p><input type="submit" value="' . get_string('enable') . '" /></p>';
    echo '<p>' . get_string('optionalmaintenancemessage', 'admin') . ':</p>';
    echo '<table><tr><td>';
    print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
    echo '</td></tr></table>';
    echo '</div>';
    echo '</form>';
    echo '</div>';
    if ($usehtmleditor) {
        use_html_editor();
    }
}
admin_externalpage_print_footer();
Example #5
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 #6
0
// print the email form START
print_heading($strquickmail);
// error printing
if (isset($form->error)) {
    notify($form->error);
    if (isset($form->usersfail)) {
        $errorstring = '';
        if (isset($form->usersfail['emailfail'])) {
            $errorstring .= get_string('emailfail', 'block_quickmail') . '<br />';
            foreach ($form->usersfail['emailfail'] as $user) {
                $errorstring .= $user . '<br />';
            }
        }
        if (isset($form->usersfail['emailstop'])) {
            $errorstring .= get_string('emailstop', 'block_quickmail') . '<br />';
            foreach ($form->usersfail['emailstop'] as $user) {
                $errorstring .= $user . '<br />';
            }
        }
        notice($errorstring, "{$CFG->wwwroot}/course/view.php?id={$course->id}", $course);
    }
}
$currenttab = 'compose';
include $CFG->dirroot . '/blocks/quickmail/tabs.php';
print_simple_box_start('center');
require $CFG->dirroot . '/blocks/quickmail/email.html';
print_simple_box_end();
if ($usehtmleditor) {
    use_html_editor('message');
}
print_footer($course);
Example #7
0
/**
 * Legacy function, provided for backward compatability.
 * This method now simply calls {@link use_html_editor()}
 *
 * @deprecated Use {@link use_html_editor()} instead.
 * @param string $name Form element to replace with HTMl editor by name
 * @todo Finish documenting this function
 */
function print_richedit_javascript($form, $name, $source = 'no')
{
    use_html_editor($name);
}
Example #8
0
}
echo '<li>';
message_history_link($user->id, 0, false, '', '', 'both');
echo '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
// class="userinfo"
echo '<div id="send">';
echo '<form id="editing" method="post" action="discussion.php">';
$usehtmleditor = can_use_html_editor() && get_user_preferences('message_usehtmleditor', 0);
echo '<h1><label for="edit-message">' . get_string('sendmessage', 'message') . '</label></h1>';
echo '<div>';
if ($usehtmleditor) {
    print_textarea(true, 8, 34, 100, 100, 'message', $refreshedmessage);
    use_html_editor('message', 'formatblock subscript superscript copy cut paste clean undo redo justifyleft justifycenter justifyright justifyfull lefttoright righttoleft insertorderedlist insertunorderedlist outdent indent inserthorizontalrule createanchor nolink inserttable');
    echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
} else {
    print_textarea(false, 8, 50, 0, 0, 'message', $refreshedmessage);
    echo '<input type="hidden" name="format" value="' . FORMAT_MOODLE . '" />';
}
echo '</div><div>';
echo '<input type="hidden" name="id" value="' . $user->id . '" />';
echo '<input type="hidden" name="start" value="' . $start . '" />';
echo '<input type="hidden" name="noframesjs" value="' . $noframesjs . '" />';
echo '<input type="hidden" name="last" value="' . time() . '" />';
echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
echo '<input type="submit" value="' . get_string('sendmessage', 'message') . '" />&nbsp;';
echo '<input type="submit" name="refresh" value="' . get_string('refresh') . '" />';
echo '<input type="checkbox" name="newonly" id="newonly" ' . ($newonly ? 'checked="checked" ' : '') . '/><label for="newonly">' . get_string('newonlymsg', 'message') . '</label>';
echo '</div>';
/**
 * Print the edit message form using the given
 * NanoGong message object.
 **/
function nanogong_print_edit_message_form($id, $nanogong, $nanogong_message)
{
    global $CFG, $USER;
    if (isstudent($nanogong->course) && $nanogong_message->locked) {
        error(get_string("lockerror", "nanogong"), "view.php?id={$id}");
        return;
    }
    $usehtmleditor = can_use_html_editor();
    ?>
    <form method="post">
    <center>
    <h3><?php 
    print_string("editmessage", "nanogong");
    ?>
</h3>
    </center>
    <?php 
    print_simple_box_start("center");
    ?>
    <center>
    <table cellpadding="5">
    <tr valign="top">
        <td align="right"><strong><?php 
    print_string("submitdate", "nanogong");
    ?>
:</strong></td>
        <td align="left"><?php 
    p(userdate($nanogong_message->timestamp));
    ?>
</td>
    </tr>
    <tr valign="top">
        <td align="right"><strong><?php 
    print_string("title", "nanogong");
    ?>
:</strong></td>
        <td align="left"><input id="title" name="title" type="text" maxlength="255" size="80" value="<?php 
    p($nanogong_message->title);
    ?>
" /></td>
    </tr>
    <tr valign="top">
        <td align="right"><strong><?php 
    print_string("audiomessage", "nanogong");
    ?>
:</strong></td>
        <td align="left">
            <applet archive="<?php 
    p("{$CFG->wwwroot}/mod/nanogong/nanogong.jar");
    ?>
"
                id="recorder" name="recorder" code="gong.NanoGong" width="180px" height="40px">
<?php 
    if ($CFG->slasharguments) {
        $url = "{$CFG->wwwroot}/file.php{$nanogong_message->path}";
    } else {
        $url = "{$CFG->wwwroot}/file.php?file={$nanogong_message->path}";
    }
    ?>
                <param name="SoundFileURL" value="<?php 
    p($url);
    ?>
" />
<?php 
    if (!empty($nanogong->color)) {
        ?>
                <param name="Color" value="<?php 
        p($nanogong->color);
        ?>
" />
<?php 
    }
    if (!empty($nanogong->maxduration)) {
        ?>
                <param name="MaxDuration" value="<?php 
        p($nanogong->maxduration);
        ?>
" />
<?php 
    }
    ?>
								<param name="ShowTime" value="true" />
            </applet></td>
    </tr>
    <tr valign="top">
        <td align="right"><strong><?php 
    print_string("textmessage", "nanogong");
    ?>
:</strong></td>
        <td align="left" valign="top">
        <?php 
    print_textarea($usehtmleditor, 20, 60, 680, 400, "message", $nanogong_message->message);
    ?>
        </td>
    </tr>
<?php 
    if (isteacheredit($nanogong->course)) {
        ?>
    <tr valign="top">
        <td align="right"><strong><?php 
        print_string("comments", "nanogong");
        ?>
:</strong></td>
        <td align="left">
        <?php 
        print_textarea($usehtmleditor, 20, 60, 680, 400, "comments", $nanogong_message->comments);
        ?>
        </td>
    </tr>
    <tr valign="top">
        <td align="right"><strong><?php 
        print_string("score", "nanogong");
        ?>
:</strong></td>
        <td align="left"><input type="text" id="score" name="score" size="7" maxsize="7" value="<?php 
        p($nanogong_message->score);
        ?>
" /></td>
    </tr>
    <tr valign="top">
        <td align="right"><strong><?php 
        print_string("locked", "nanogong");
        ?>
:</strong></td>
        <td align="left">
<?php 
        $options = array();
        $options[0] = get_string('no');
        $options[1] = get_string('yes');
        choose_from_menu($options, 'locked', $nanogong_message->locked, '');
        ?>
</td>
    </tr>
<?php 
    }
    ?>
    </table>
    <?php 
    nanogong_print_submit_form_script($nanogong);
    ?>
    <input id="path" name="path" type="hidden" value="<?php 
    p($nanogong_message->path);
    ?>
" />
    <input id="action" name="action" type="hidden" value="editsubmit" />
    <input id="messageid" name="messageid" type="hidden" value="<?php 
    p($nanogong_message->id);
    ?>
" />
    <input type="submit" value="<?php 
    print_string("updatemessage", "nanogong");
    ?>
" onclick="return submitMessage()" />
    <input type="button" value="<?php 
    print_string("cancel");
    ?>
" onclick="location.replace('view.php?id=<?php 
    p($id);
    ?>
')" />
    <br />&nbsp;
    </center>
    <?php 
    print_simple_box_end();
    ?>
    </form>
<?php 
    if ($usehtmleditor) {
        use_html_editor("message");
        if (isteacheredit($nanogong->course)) {
            use_html_editor("comments");
        }
    }
}
Example #10
0
    echo '</p>';
}
?>
    <table cellpadding="5" class="generalbox boxaligncenter" border="1">
    <tr valign="top">
    <td><b><label for="title"><?php 
print_string("pagetitle", "lesson");
?>
:</label></b><br />
    <input type="text" id="title" name="title" size="80" value="" /></td></tr>
    <?php 
echo "<tr><td><b>";
echo get_string("pagecontents", "lesson") . ":</b><br />\n";
print_textarea($usehtmleditor, 25, 70, 630, 400, "contents");
if ($usehtmleditor) {
    use_html_editor("contents");
}
echo "</td></tr>\n";
switch ($qtype) {
    case LESSON_TRUEFALSE:
        for ($i = 0; $i < 2; $i++) {
            $iplus1 = $i + 1;
            echo "<tr><td><b>" . get_string("answer", "lesson") . " {$iplus1}:</b><br />\n";
            print_textarea(false, 6, 70, 630, 300, "answer[{$i}]");
            echo "</td></tr>\n";
            echo "<tr><td><b>" . get_string("response", "lesson") . " {$iplus1}:</b><br />\n";
            print_textarea(false, 6, 70, 630, 300, "response[{$i}]");
            echo "</td></tr>\n";
            echo "<tr><td><b>" . get_string("jump", "lesson") . " {$iplus1}:</b> \n";
            if ($i) {
                // answers 2, 3, 4... jumpto this page
Example #11
0
 /**
  * Format question display
  */
 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG;
     require_once $CFG->libdir . '/formslib.php';
     $readonly = empty($options->readonly) ? '' : 'disabled="disabled"';
     static $htmleditorused = false;
     // Print formulation
     $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
     $image = get_question_image($question);
     $maxbytes = $question->options->maxbytes;
     $showessay = $question->options->essay;
     $answers =& $question->options->answers;
     $readonly = empty($options->readonly) ? '' : 'disabled="disabled"';
     // Only use the rich text editor for the first essay question on a page.
     $usehtmleditor = can_use_html_editor() && !$htmleditorused;
     $formatoptions = new stdClass();
     $formatoptions->noclean = true;
     $formatoptions->para = false;
     $inputname = $question->name_prefix;
     /// set question text and media
     $questiontext = format_text($question->questiontext, $question->questiontextformat, $formatoptions, $cmoptions->course);
     // get essay response value
     if (isset($state->responses[''])) {
         $value = stripslashes_safe($state->responses['']);
     } else {
         $value = "";
     }
     // essay answer
     $answer = '';
     if ($showessay) {
         if (empty($options->readonly)) {
             // the student needs to type in their answer so print out a text editor
             $answer = print_textarea($usehtmleditor, 18, 80, 630, 400, $inputname, $value, $cmoptions->course, true);
         } else {
             // it is read only, so just format the students answer and output it
             $safeformatoptions = new stdClass();
             $safeformatoptions->para = false;
             $answer = format_text($value, FORMAT_MOODLE, $safeformatoptions, $cmoptions->course);
         }
     }
     // set the file input form
     $struploadform = upload_print_form_fragment(1, array($question->name_prefix . "file"), null, false, null, 0, $maxbytes, true);
     // set file upload feedback and display of uploaded file
     $uploadfeedback = '';
     if (isset($state->uploadfeedback)) {
         $uploadfeedback = $state->uploadfeedback;
     }
     $struploadedfile = '';
     $currentfile = get_student_answer($state->attempt, $question->id);
     if ($currentfile) {
         $struploadedfile = get_string('answer', 'quiz') . ': ' . $currentfile;
     }
     // string prompts for form
     if ($currentfile) {
         $struploadfile = get_string('uploadnew', 'qtype_fileresponse');
     } else {
         $struploadfile = get_string('uploadafile');
     }
     $strmaxsize = get_string('maximumupload') . ' ' . display_size($maxbytes);
     include "{$CFG->dirroot}/question/type/fileresponse/display.html";
     if ($usehtmleditor) {
         use_html_editor($inputname);
         $htmleditorused = true;
     }
 }
Example #12
0
function ewiki_page_edit_form(&$id, &$data, &$hidden_postdata)
{
    global $ewiki_plugins, $ewiki_config, $moodle_format;
    $o = '';
    #-- previously edited, or db fetched content
    if (@$_REQUEST["content"] || @$_REQUEST["version"]) {
        $data = array("version" => &$_REQUEST["version"], "content" => &$_REQUEST["content"]);
    } else {
        if (empty($data["version"])) {
            $data["version"] = 1;
        }
        @($data["content"] .= "");
    }
    #-- normalize to DOS newlines
    $data["content"] = str_replace("\r\n", "\n", $data["content"]);
    $data["content"] = str_replace("\r", "\n", $data["content"]);
    $data["content"] = str_replace("\n", "\r\n", $data["content"]);
    $hidden_postdata["version"] =& $data["version"];
    #-- edit textarea/form
    // deleted name="ewiki", can not find the reference, and it's breaking xhtml
    $o .= ewiki_t("EDIT_FORM_1") . '<form method="post" enctype="multipart/form-data" action="' . ewiki_script("edit", $id) . '" ' . ' accept-charset="' . EWIKI_CHARSET . '">' . "\n";
    $o .= '<div>';
    #-- additional POST vars
    foreach ($hidden_postdata as $name => $value) {
        $o .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />' . "\n";
    }
    ($cols = strtok($ewiki_config["edit_box_size"], "x*/,;:")) && ($rows = strtok("x, ")) || ($cols = 70) && ($rows = 15);
    global $ewiki_use_editor, $ewiki_editor_content;
    $ewiki_editor_content = 1;
    if ($ewiki_use_editor) {
        ob_start();
        $usehtmleditor = can_use_html_editor();
        echo '<table><tr><td>';
        if ($usehtmleditor) {
            //clean and convert before editing
            $options = new object();
            $options->smiley = false;
            $options->filter = false;
            $oldtext = format_text(ewiki_format($data["content"]), $moodle_format, $options);
        } else {
            $oldtext = ewiki_format($data["content"]);
        }
        print_textarea($usehtmleditor, $rows, $cols, 680, 400, "content", $oldtext);
        echo '</td></tr></table>';
        if ($usehtmleditor) {
            use_html_editor("content");
        }
        $o .= ob_get_contents();
        ob_end_clean();
    } else {
        ##### END MOODLE ADDITION #####
        $o .= '<textarea wrap="soft" id="ewiki_content" name="content" rows="' . $rows . '" cols="' . $cols . '">' . s($data["content"]) . "</textarea>" . $GLOBALS["ewiki_t"]["C"]["EDIT_TEXTAREA_RESIZE_JS"];
        ##### BEGIN MOODLE ADDITION #####
    }
    ##### END MOODLE ADDITION #####
    #-- more <input> elements before the submit button
    if ($pf_a = $ewiki_plugins["edit_form_insert"]) {
        foreach ($pf_a as $pf) {
            $o .= $pf($id, $data, $action);
        }
    }
    ##### BEGIN MOODLE ADDITION (Cancel Editing into Button) #####
    $o .= "\n<br />\n" . '<input type="submit" name="save" value="' . ewiki_t("SAVE") . '" />' . "\n" . '<input type="submit" name="preview" value="' . ewiki_t("PREVIEW") . '" />' . "\n" . '<input type="submit" name="canceledit" value="' . ewiki_t("CANCEL_EDIT") . '" />' . "\n";
    #      . ' &nbsp; <a href="'. ewiki_script("", $id) . '">' . ewiki_t("CANCEL_EDIT") . '</a>';
    ##### END MOODLE ADDITION #####
    #-- additional form elements
    if ($pf_a = $ewiki_plugins["edit_form_append"]) {
        foreach ($pf_a as $pf) {
            $o .= $pf($id, $data, $action);
        }
    }
    $o .= "\n</div></form>\n";
    //   . ewiki_t("EDIT_FORM_2");  // MOODLE DELETION
    return '<div class="edit-box">' . $o . '</div>';
}
Example #13
0
 /**
  * Creates the screen for editing tasks.
  *
  * @uses $CFG
  * @return string
  **/
 function make_edit()
 {
     global $CFG;
     $type = optional_param('type', '', PARAM_ALPHA);
     $taskaction = optional_param('taskaction', '', PARAM_ALPHA);
     $taskid = optional_param('taskid', 0, PARAM_INT);
     $output = '';
     if (!$this->can_edit()) {
         error('You are not authorized to view this page');
     }
     /// Actions that handle Processing
     switch ($taskaction) {
         case 'confirmed':
             // Confirmation of deletion
             if (!confirm_sesskey()) {
                 error(get_string('confirmsesskeybad', 'error'));
             }
             if (delete_records('block_task_list', 'id', $taskid)) {
                 // This replaces the ID:
                 //  Anywhere in the list (except the first spot)
                 //  OR at the beginning of the list
                 //  OR the ID is the list and replaces it
                 $this->config->taskorder = preg_replace("/,{$taskid}\\b|\\b{$taskid},|\\b{$taskid}\\b/", '', $this->config->taskorder);
                 $this->instance_config_commit();
                 // Remove from out task list
                 unset($this->tasks[$taskid]);
                 $this->set_message(get_string('taskdeleted', 'block_task_list'), 'notifysuccess');
             } else {
                 $this->set_message(get_string('taskdeletefailed', 'block_task_list'));
             }
             break;
         case 'save':
             // Saving an add or edit form
             if (confirm_sesskey() and data_submitted()) {
                 $task = new stdClass();
                 $task->instanceid = $this->instance->id;
                 $task->type = required_param('type', PARAM_ALPHA);
                 if ($task->type == 'category') {
                     $task->name = required_param('taskname', PARAM_TEXT);
                 } else {
                     $task->name = required_param('taskname', PARAM_RAW);
                 }
                 $task->format = required_param('format', PARAM_INT);
                 $task->timemodified = time();
                 if ($id = optional_param('taskid', 0, PARAM_INT)) {
                     $task->id = $id;
                     $result = update_record('block_task_list', $task);
                 } else {
                     $result = $task->id = insert_record('block_task_list', $task);
                     if ($task->id) {
                         if (empty($this->config->taskorder)) {
                             $this->config->taskorder = $task->id;
                         } else {
                             $this->config->taskorder .= ",{$task->id}";
                         }
                         // Save the order
                         $this->instance_config_commit();
                     }
                 }
                 if ($result) {
                     // Update the tasks object
                     $this->tasks[$task->id] = $task;
                     $this->set_message(get_string('taskitemsaved', 'block_task_list'), 'notifysuccess');
                 } else {
                     $this->set_message(get_string('taskitemnotsaved', 'block_task_list'));
                 }
             }
             break;
     }
     /// Actions that handle display
     switch ($taskaction) {
         case 'edit':
             // Edit button was pushed
             if (!confirm_sesskey()) {
                 error(get_string('confirmsesskeybad', 'error'));
             }
             $name = get_field('block_task_list', 'name', 'id', $taskid);
         case 'add':
             // An option in the add task menu was selected
             if (empty($name)) {
                 $name = '';
             }
             if ($usehtmleditor = can_use_html_editor()) {
                 $format = FORMAT_HTML;
                 $formatstr = get_string('formathtml');
             } else {
                 $format = FORMAT_MOODLE;
                 $formatstr = get_string('formattext');
             }
             $addform = '<h2>' . get_string('editingtask', 'block_task_list', get_string($type, 'block_task_list')) . "</h2>\n                            <form action=\"{$this->baseurl}\" method=\"post\" accept-charset=\"utf-8\">\n                            <input type=\"hidden\" name=\"taskmode\" value=\"edit\" />\n                            <input type=\"hidden\" name=\"taskaction\" value=\"save\" />\n                            <input type=\"hidden\" name=\"taskid\" value=\"{$taskid}\" />\n                            <input type=\"hidden\" name=\"type\" value=\"{$type}\" />\n                            <input type=\"hidden\" name=\"format\" value=\"{$format}\" />\n                            <input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . '" />';
             if ($type == 'category') {
                 $addform .= '<strong>' . get_string('name', 'block_task_list') . ':&nbsp;</strong>' . print_textfield('taskname', s($name), get_string('name', 'block_task_list'), 50, 0, true);
             } else {
                 $addform .= print_textarea($usehtmleditor, 10, 65, 0, 0, 'taskname', $name, $this->course->id, true) . "<br />{$formatstr} " . helpbutton('textformat', get_string('helpformatting'), 'moodle', true, false, '', true);
             }
             $addform .= '<p><span class="button"><input type="submit" value="' . get_string('savechanges') . '" /></span></p>
                          </form>';
             $output .= print_box($addform, 'generalbox boxaligncenter taskedit', '', true);
             // A little hack to make the HTML editor work
             if ($usehtmleditor and $type != 'category') {
                 ob_start();
                 use_html_editor('taskname');
                 $output .= ob_get_contents();
                 ob_end_clean();
             }
             break;
         case 'delete':
             // Delete button pushed
             if (!confirm_sesskey()) {
                 error(get_string('confirmsesskeybad', 'error'));
             }
             // Don't like it, but it works...
             ob_start();
             notice_yesno(get_string('confirmdeletetask', 'block_task_list', $this->print_name($this->tasks[$taskid], true)), $this->baseurl . '&amp;taskmode=edit&amp;taskaction=confirmed&amp;taskid=' . $taskid . '&amp;sesskey=' . sesskey(), $this->baseurl . '&amp;taskmode=edit');
             $output .= ob_get_contents();
             ob_end_clean();
             break;
         default:
             if (empty($this->tasks)) {
                 $this->set_message(get_string('notasksfound', 'block_task_list'));
             } else {
                 // Table setup
                 $table->head = array(get_string('taskitem', 'block_task_list'), get_string('type', 'block_task_list'), get_string('action', 'block_task_list'));
                 $table->align = array('left', 'left', 'center');
                 $table->width = '70%';
                 $table->tablealign = 'center';
                 $table->cellpadding = '5px';
                 $table->cellspacing = '0';
                 $table->data = array();
                 // Get task IDs
                 $taskids = explode(',', $this->config->taskorder);
                 foreach ($taskids as $taskid) {
                     $task = $this->tasks[$taskid];
                     $url = "{$this->baseurl}&amp;taskmode=edit&amp;taskid={$taskid}&amp;sesskey=" . sesskey() . '&amp;';
                     $buttons = '<a href="' . $url . 'taskaction=edit&amp;type=' . $task->type . '">' . '<img src="' . $CFG->pixpath . '/t/edit.gif" height="11" width="11" border="0" alt="' . get_string('edit') . '" /></a>' . '&nbsp;' . '<a href="' . $url . 'taskaction=delete">' . '<img src="' . $CFG->pixpath . '/t/delete.gif" height="11" width="11" border="0" alt="' . get_string('delete') . '" /></a>' . '&nbsp;' . '<a href="' . $this->baseurl . '&amp;taskmode=move&amp;moving=' . $taskid . '">' . '<img src="' . $CFG->pixpath . '/t/move.gif" height="11" width="11" border="0" alt="' . get_string('move') . '" /></a>';
                     $table->data[] = array($this->print_name($task, true), get_string($task->type, 'block_task_list'), $buttons);
                 }
                 $output .= $this->print_table($table, true);
             }
             // Add task item drop-down
             $output .= '<div class="addtaskitem">' . get_string('addtaskitem', 'block_task_list') . ': ' . popup_form($this->baseurl . '&amp;taskmode=edit&amp;taskaction=add&amp;type=', $this->get_task_menu(), 'addtaskitem', '', 'choose', '', '', true) . '</div>';
             break;
     }
     return $output;
 }
Example #14
0
File: lib.php Project: rrusso/EARS
 function print_form()
 {
     global $CFG;
     // If the report form has a course. then we'll allow attachments.
     $special_inputs = '';
     if ($this->courseid) {
         $course = get_record('course', 'id', $this->courseid);
         $special_inputs = '<input type="hidden" name="id" value="' . $this->courseid . '">
                            <input type="hidden" name="MAX_FILE_SIZE" value="' . get_max_upload_file_size($CFG->maxbytes, $course->maxbytes) . '">
                           ' . get_string('attachment', 'block_student_gradeviewer') . '
                            <input type="file" name="attach" size="45"><br/>';
     }
     echo '<form enctype="multipart/form-data" method="POST">
             <div class="report_wrap">
                ' . print_box_start('generalbox', true) . '
                 <div class="report_text" style="width: 65%; margin: auto auto;">
                 <span>' . get_string('body', 'block_student_gradeviewer') . '</span><br/>
                 ' . print_textarea($this->usehtmleditor, 20, 90, null, null, 'report', '', $this->courseid, true) . '
                     <br/>
                     <input type="hidden" name="form_submit" value="1">
                     ' . array_reduce($this->users, array($this, 'reduce_ids')) . get_string('kudo', 'block_student_gradeviewer') . print_checkbox('source', 3, false, '', '', '', true) . '<br/>' . $special_inputs . get_string('anonymous', 'block_student_gradeviewer') . print_checkbox('anonymous', 1, false, '', '', '', true) . '<br/>
                     <input type="submit" value="' . get_string('report', 'block_student_gradeviewer') . '">
                 </div>
                 ' . print_box_end(true) . '
             </div>
           </form>';
     if ($this->usehtmleditor) {
         use_html_editor('report');
     }
 }
 function setup_end()
 {
     global $CFG;
     include $CFG->dirroot . '/mod/bookings/type/common_end.html';
     print_simple_box_end();
     if ($this->usehtmleditor) {
         use_html_editor();
     }
     print_footer($this->course);
 }
Example #16
0
                if ($user->teacher) {
                    $teachers[] = $user->id;
                }
            }
            if ($good) {
                print_heading(get_string('messagedselectedusers'));
                unset($SESSION->emailto[$id]);
                unset($SESSION->emailselect[$id]);
            } else {
                print_heading(get_string('messagedselectedusersfailed'));
            }
            echo '<p align="center"><a href="index.php?id=' . $id . '">' . get_string('backtoparticipants') . '</a></p>';
        }
        print_footer();
        exit;
    } else {
        notify(get_string('nousersyet'));
    }
}
echo '<p align="center"><a href="' . $returnto . '">' . get_string("keepsearching") . '</a>' . (count($SESSION->emailto[$id]) ? ', ' . get_string('usemessageform') : '') . '</p>';
if ((!empty($send) || !empty($preview) || !empty($edit)) && empty($messagebody)) {
    notify(get_string('allfieldsrequired'));
}
if (count($SESSION->emailto[$id])) {
    $usehtmleditor = can_use_richtext_editor();
    require "message.html";
    if ($usehtmleditor) {
        use_html_editor("messagebody");
    }
}
print_footer();
Example #17
0
 /**
  * Prints questions with comment and grade form underneath each question
  *
  * @return void
  * @todo Finish documenting this function
  **/
 function print_questions_and_form($quiz, $question, $userid, $attemptid, $gradeungraded, $gradenextungraded, $ungraded)
 {
     global $CFG;
     // TODO get the context, and put in proper roles an permissions checks.
     $context = NULL;
     $questions[$question->id] =& $question;
     $usehtmleditor = can_use_richtext_editor();
     list($select, $from, $where) = $this->attempts_sql($quiz->id, false, $question->id, $userid, $attemptid, $gradeungraded, $gradenextungraded);
     $sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
     if ($gradenextungraded) {
         $attempts = get_records_sql($select . $from . $where . $sort, 0, QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE);
     } else {
         $attempts = get_records_sql($select . $from . $where . $sort);
     }
     if ($attempts) {
         $firstattempt = current($attempts);
         $fullname = fullname($firstattempt);
         if ($gradeungraded) {
             // getting all ungraded attempts
             print_heading(get_string('gradingungraded', 'quiz_grading', $ungraded), '', 3);
         } else {
             if ($gradenextungraded) {
                 // getting next ungraded attempts
                 print_heading(get_string('gradingnextungraded', 'quiz_grading', QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE), '', 3);
             } else {
                 if ($userid) {
                     print_heading(get_string('gradinguser', 'quiz_grading', $fullname), '', 3);
                 } else {
                     if ($attemptid) {
                         $a = new object();
                         $a->fullname = $fullname;
                         $a->attempt = $firstattempt->attempt;
                         print_heading(get_string('gradingattempt', 'quiz_grading', $a), '', 3);
                     } else {
                         print_heading(get_string('gradingall', 'quiz_grading', count($attempts)), '', 3);
                     }
                 }
             }
         }
         // Display the form with one part for each selected attempt
         echo '<form method="post" action="report.php">' . '<input type="hidden" name="mode" value="grading" />' . '<input type="hidden" name="q" value="' . $quiz->id . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="questionid" value="' . $question->id . '" />';
         foreach ($attempts as $attempt) {
             // Load the state for this attempt (The questions array was created earlier)
             $states = get_question_states($questions, $quiz, $attempt);
             // The $states array is indexed by question id but because we are dealing
             // with only one question there is only one entry in this array
             $state =& $states[$question->id];
             $options = quiz_get_reviewoptions($quiz, $attempt, $context);
             unset($options->questioncommentlink);
             $options->noeditlink = true;
             $copy = $state->manualcomment;
             $state->manualcomment = '';
             $options->readonly = 1;
             $gradedclass = question_state_is_graded($state) ? ' class="highlightgraded" ' : '';
             $gradedstring = question_state_is_graded($state) ? ' ' . get_string('graded', 'quiz_grading') : '';
             $a = new object();
             $a->fullname = fullname($attempt, true);
             $a->attempt = $attempt->attempt;
             // print the user name, attempt count, the question, and some more hidden fields
             echo '<div class="boxaligncenter" width="80%" style="clear:left;padding:15px;">';
             echo "<span{$gradedclass}>" . get_string('gradingattempt', 'quiz_grading', $a);
             echo $gradedstring . "</span>";
             print_question($question, $state, '', $quiz, $options);
             $prefix = "manualgrades[{$attempt->uniqueid}]";
             if (!question_state_is_graded($state)) {
                 $grade = '';
             } else {
                 $grade = round($state->last_graded->grade, 3);
             }
             $state->manualcomment = $copy;
             include $CFG->dirroot . '/question/comment.html';
             echo '</div>';
         }
         echo '<div class="boxaligncenter"><input type="submit" value="' . get_string('savechanges') . '" /></div>' . '</form>';
         if ($usehtmleditor) {
             use_html_editor();
         }
     } else {
         notify(get_string('noattemptstoshow', 'quiz'));
     }
 }
Example #18
0
function webquest_print_upload_form($webquest)
{
    global $CFG;
    if (!($course = get_record("course", "id", $webquest->course))) {
        error("Course is misconfigured");
    }
    if (!($cm = get_coursemodule_from_instance("webquest", $webquest->id, $course->id))) {
        error("Course Module ID was incorrect");
    }
    $usehtmleditor = can_use_html_editor();
    echo "<div align=\"center\">";
    echo "<form enctype=\"multipart/form-data\" method=\"POST\" action=\"upload.php\">";
    echo " <input type=\"hidden\" name=\"id\" value=\"{$cm->id}\" />";
    echo "<table celpadding=\"5\" border=\"1\" align=\"center\">\n";
    // now get the submission
    echo "<tr valign=\"top\"><td><b>" . get_string("title", "webquest") . ":</b>\n";
    echo "<input type=\"text\" name=\"title\" size=\"60\" maxlength=\"100\" value=\"\" />\n";
    echo "</td></tr><tr><td><b>" . get_string("submission", "webquest") . ":</b><br />\n";
    print_textarea($usehtmleditor, 25, 70, 630, 400, "description");
    use_html_editor("description");
    echo "</td></tr><tr><td>\n";
    if ($webquest->nattachments) {
        require_once $CFG->dirroot . '/lib/uploadlib.php';
        for ($i = 0; $i < $webquest->nattachments; $i++) {
            $iplus1 = $i + 1;
            $tag[$i] = get_string("attachment", "webquest") . " {$iplus1}:";
        }
        upload_print_form_fragment($webquest->nattachments, null, $tag, false, null, $course->maxbytes, $webquest->maxbytes, false);
    }
    echo "</td></tr></table>\n";
    echo " <input type=\"submit\" name=\"save\" value=\"" . get_string("submitassignment", "webquest") . "\" />";
    echo "</form>";
    echo "</div>";
}
Example #19
0
         } else {
             echo " [<label for=\"responseeditor[{$n}]\">" . get_string("useeditor", "lesson") . "</label>: " . "<input type=\"checkbox\" id=\"responseeditor[{$n}]\" name=\"responseeditor[{$n}]\" value=\"1\" />";
             helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
             echo "]<br />\n";
             print_textarea(false, 6, 70, 630, 300, "response[{$n}]", $answer->response);
         }
         echo "</td></tr>\n";
         break;
     case LESSON_BRANCHTABLE:
         echo "<tr><td><b><label for=\"edit-answer[{$n}]\">" . get_string("description", "lesson") . " {$nplus1}:</label></b>\n";
         if ($flags & LESSON_ANSWER_EDITOR) {
             echo " [<label for=\"answereditor[{$n}]\">" . get_string("useeditor", "lesson") . "</label>: " . "<input type=\"checkbox\" id=\"answereditor[{$n}]\" name=\"answereditor[{$n}]\" value=\"1\" checked=\"checked\" />";
             helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
             echo "]<br />\n";
             print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[{$n}]", $answer->answer);
             use_html_editor("answer[{$n}]");
             // switch on the editor
         } else {
             echo " [<label for=\"answereditor[{$n}]\">" . get_string("useeditor", "lesson") . "</label>: " . "<input type=\"checkbox\" id=\"answereditor[{$n}]\" name=\"answereditor[{$n}]\" value=\"1\" />";
             helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
             echo "]<br />\n";
             print_textarea(false, 10, 70, 630, 300, "answer[{$n}]", $answer->answer);
         }
         echo "</td></tr>\n";
         break;
 }
 switch ($page->qtype) {
     case LESSON_MATCHING:
         if ($n == 2) {
             echo "<tr><td><b>" . get_string("correctanswerjump", "lesson") . ":</b> \n";
             choose_from_menu($jump, "jumpto[{$n}]", $answer->jumpto, "");
Example #20
0
    echo '</tr>';
} else {
    if ($mode == 'rsstemplate') {
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>';
        echo '<div style="text-align:center"><label for="edit-rsstitletemplate">' . get_string('rsstitletemplate', 'data') . '</label></div>';
        print_textarea($usehtmleditor, 10, 72, 0, 0, 'rsstitletemplate', $data->rsstitletemplate);
        echo '</td>';
        echo '</tr>';
    }
}
echo '<tr><td style="text-align:center" colspan="2">';
echo '<input type="submit" value="' . get_string('savetemplate', 'data') . '" />&nbsp;';
echo '</td></tr></table>';
print_simple_box_end();
echo '</div>';
echo '</form>';
if ($usehtmleditor) {
    use_html_editor('template');
    if ($mode == 'listtemplate') {
        use_html_editor('listtemplateheader');
        use_html_editor('listtemplatefooter');
    } else {
        if ($mode == 'rsstemplate') {
            use_html_editor('rsstitletemplate');
        }
    }
}
/// Finish the page
print_footer($course);
Example #21
0
            if ($courseid == 0) {
                // workaround by Dan for bug #6130
                $courseid = SITEID;
            }
            if (!($course = get_record('course', 'id', $courseid))) {
                error('Incorrect course ID');
            }
            $groupid = groups_get_course_group($course);
            echo '<h2>' . get_string('eventkind', 'calendar') . ':</h2>';
            echo '<div id="selecteventtype">';
            include 'event_select.html';
            echo '</div>';
        } else {
            include 'event_new.html';
            if ($usehtmleditor) {
                use_html_editor("description");
            }
        }
        break;
}
echo '</td>';
// START: Last column (3-month display)
$defaultcourses = calendar_get_default_courses();
//calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
// when adding an event you can not be a guest, so I think it's reasonalbe to ignore defaultcourses
// MDL-10353
calendar_set_filters($courses, $groups, $users);
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
echo '<td class="sidecalendar">';
echo '<div class="sideblock">';
    add_to_log($course->id, "course", "editsection", "editsection.php?id={$section->id}", "{$section->section}");
    redirect("view.php?id={$course->id}");
    exit;
}
/// Otherwise fill and print the form.
if (empty($form)) {
    $form = $section;
} else {
    $form = stripslashes_safe($form);
}
// !! no db access using data from $form beyond this point !!
$usehtmleditor = can_use_html_editor();
/// Inelegant hack for bug 3408
if ($course->format == 'site') {
    $sectionname = get_string('site');
    $stredit = get_string('edit', '', " {$sectionname}");
    $strsummaryof = get_string('summaryof', '', " {$sectionname}");
} else {
    $sectionname = get_section_name($course->format);
    $stredit = get_string('edit', '', " {$sectionname} {$section->section}");
    $strsummaryof = get_string('summaryof', '', " {$sectionname} {$section->section}");
}
print_header_simple($stredit, '', build_navigation(array(array('name' => $stredit, 'link' => null, 'type' => 'misc'))), 'theform.summary');
print_heading($strsummaryof);
print_simple_box_start('center');
include 'editsection.html';
print_simple_box_end();
if ($usehtmleditor) {
    use_html_editor("summary");
}
print_footer($course);
Example #23
0
function question_print_comment_box($question, $state, $attempt, $url)
{
    global $CFG, $QTYPES;
    $prefix = 'response';
    $usehtmleditor = can_use_richtext_editor();
    if (!question_state_is_graded($state) && $QTYPES[$question->qtype]->is_question_manual_graded($question, $attempt->layout)) {
        $grade = '';
    } else {
        $grade = round($state->last_graded->grade, 3);
    }
    echo '<form method="post" action="' . $url . '">';
    include $CFG->dirroot . '/question/comment.html';
    echo '<input type="hidden" name="attempt" value="' . $attempt->uniqueid . '" />';
    echo '<input type="hidden" name="question" value="' . $question->id . '" />';
    echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
    echo '<input type="submit" name="submit" value="' . get_string('save', 'quiz') . '" />';
    echo '</form>';
    if ($usehtmleditor) {
        use_html_editor();
    }
}
Example #24
0
            print_single_button('manage.php', $options, get_string('resetrolenolegacy', 'role'));
        } else {
            print_single_button('manage.php', $options, get_string('resetrole', 'role'));
        }
        $options['action'] = 'duplicate';
        print_single_button('manage.php', $options, get_string('duplicaterole', 'role'));
        print_single_button('manage.php', null, get_string('listallroles', 'role'));
        echo '</div>';
    }
    echo '</div>';
    $lang = str_replace('_utf8', '', current_language());
    print_simple_box_start('center');
    include_once 'manage.html';
    print_simple_box_end();
    if ($usehtmleditor) {
        use_html_editor('description');
    }
} else {
    print_heading_with_help(get_string('roles', 'role'), 'roles');
    $table = new object();
    $table->tablealign = 'center';
    $table->align = array('right', 'left', 'left', 'left');
    $table->wrap = array('nowrap', '', 'nowrap', 'nowrap');
    $table->cellpadding = 5;
    $table->cellspacing = 0;
    $table->width = '90%';
    $table->data = array();
    $table->head = array(get_string('name'), get_string('description'), get_string('shortname'), get_string('edit'));
    /*************************
     * List all current roles *
     **************************/
Example #25
0
         echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />\n";
         echo " <input type=\"hidden\" name=\"sesskey\" value=\"{$USER->sesskey}\" />\n";
         print_textarea(false, 25, 80, 680, 400, "text", $contents);
         echo "</td>\n</tr>\n<tr>\n<td>\n";
         echo " <input type=\"submit\" value=\"" . get_string("savechanges") . "\" />\n";
         echo "</form>\n";
         echo "</td>\n<td>\n";
         echo "<form action=\"coursefiles.php\" method=\"get\">\n";
         echo " <input type=\"hidden\" name=\"id\" value=\"{$id}\" />\n";
         echo " <input type=\"hidden\" name=\"wdir\" value=\"{$wdir}\" />\n";
         echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
         echo " <input type=\"submit\" value=\"" . get_string("cancel") . "\" />\n";
         echo "</form>\n";
         echo "</td></tr></table>\n";
         if ($usehtmleditor) {
             use_html_editor("text");
         }
     }
     html_footer();
     break;
 case "zip":
     if (!empty($name) and confirm_sesskey()) {
         html_header($course, $wdir);
         $name = clean_filename($name);
         $files = array();
         foreach ($USER->filelist as $file) {
             $files[] = "{$basedir}/{$file}";
         }
         if (!zip_files($files, "{$basedir}/{$wdir}/{$name}")) {
             print_error("zipfileserror", "error");
         }
 function print_after_form()
 {
     if (can_use_richtext_editor()) {
         use_html_editor('field_' . $this->field->id, '', 'field_' . $this->field->id);
     }
 }
Example #27
0
} else {
    $focuscursor = "form.name";
}
print_header_simple($streditinga, '', "<a href=\"{$CFG->wwwroot}/mod/{$module->name}/index.php?id={$course->id}\">{$strmodulenameplural}</a> ->\n     {$strnav} {$streditinga}", $focuscursor, "", false);
if (!empty($cm->id)) {
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    $currenttab = 'update';
    include_once $CFG->dirroot . '/' . $CFG->admin . '/roles/tabs.php';
}
unset($SESSION->modform);
// Clear any old ones that may be hanging around.
$modform = "../mod/{$module->name}/mod.html";
if (file_exists($modform)) {
    if ($usehtmleditor = can_use_html_editor()) {
        $defaultformat = FORMAT_HTML;
        $editorfields = '';
    } else {
        $defaultformat = FORMAT_MOODLE;
    }
    $icon = '<img class="icon" src="' . $CFG->modpixpath . '/' . $module->name . '/icon.gif" alt="' . get_string('modulename', $module->name) . '"/>';
    print_heading_with_help($pageheading, "mods", $module->name, $icon);
    print_simple_box_start('center', '', '', 5, 'generalbox', $module->name);
    include_once $modform;
    print_simple_box_end();
    if ($usehtmleditor and empty($nohtmleditorneeded)) {
        use_html_editor($editorfields);
    }
} else {
    notice("This module cannot be added to this course yet! (No file found at: {$modform})", "{$CFG->wwwroot}/course/view.php?id={$course->id}");
}
print_footer($course);
Example #28
0
 /**
  * Prints questions with comment and grade form underneath each question
  *
  * @return void
  * @todo Finish documenting this function
  **/
 function print_questions_and_form($quiz, $question)
 {
     global $CFG, $db;
     // grade question specific parameters
     $gradeall = optional_param('gradeall', 0, PARAM_INT);
     $userid = optional_param('userid', 0, PARAM_INT);
     $attemptid = optional_param('attemptid', 0, PARAM_INT);
     // TODO get the context, and put in proper roles an permissions checks.
     $context = NULL;
     $questions[$question->id] =& $question;
     $usehtmleditor = can_use_richtext_editor();
     $users = get_course_students($quiz->course);
     $userids = implode(',', array_keys($users));
     // this sql joins the attempts table and the user table
     $select = 'SELECT ' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ' AS userattemptid,
                 qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, qa.preview,
                 u.id AS userid, u.firstname, u.lastname, u.picture ';
     $from = 'FROM ' . $CFG->prefix . 'user u LEFT JOIN ' . $CFG->prefix . 'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = ' . $quiz->id . ') ';
     if ($gradeall) {
         // get all user attempts
         $where = 'WHERE u.id IN (' . $userids . ') ';
     } else {
         if ($userid) {
             // get all the attempts for a specific user
             $where = 'WHERE u.id=' . $userid . ' ';
         } else {
             // get a specific attempt
             $where = 'WHERE qa.id=' . $attemptid . ' ';
         }
     }
     // ignore previews
     $where .= ' AND preview = 0 ';
     $where .= 'AND ' . $db->IfNull('qa.attempt', '0') . ' != 0 ';
     $where .= 'AND ' . $db->IfNull('qa.timefinish', '0') . ' != 0 ';
     $sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
     $attempts = get_records_sql($select . $from . $where . $sort);
     // Display the form with one part for each selected attempt
     echo '<form method="post" action="report.php">' . '<input type="hidden" name="mode" value="grading" />' . '<input type="hidden" name="q" value="' . $quiz->id . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="action" value="viewquestion" />' . '<input type="hidden" name="questionid" value="' . $question->id . '" />';
     foreach ($attempts as $attempt) {
         // Load the state for this attempt (The questions array was created earlier)
         $states = get_question_states($questions, $quiz, $attempt);
         // The $states array is indexed by question id but because we are dealing
         // with only one question there is only one entry in this array
         $state =& $states[$question->id];
         $options = quiz_get_reviewoptions($quiz, $attempt, $context);
         unset($options->questioncommentlink);
         $copy = $state->manualcomment;
         $state->manualcomment = '';
         $options->readonly = 1;
         // print the user name, attempt count, the question, and some more hidden fields
         echo '<div class="boxaligncenter" width="80%" style="padding:15px;">' . fullname($attempt, true) . ': ' . get_string('attempt', 'quiz') . $attempt->attempt;
         print_question($question, $state, '', $quiz, $options);
         $prefix = "manualgrades[{$attempt->uniqueid}]";
         $grade = round($state->last_graded->grade, 3);
         $state->manualcomment = $copy;
         include $CFG->dirroot . '/question/comment.html';
         echo '</div>';
     }
     echo '<div class="boxaligncenter"><input type="submit" value="' . get_string('savechanges') . '" /></div>' . '</form>';
     if ($usehtmleditor) {
         use_html_editor();
     }
 }
 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG;
     static $htmleditorused = false;
     $answers =& $question->options->answers;
     $readonly = empty($options->readonly) ? '' : 'disabled="disabled"';
     // Only use the rich text editor for the first essay question on a page.
     $usehtmleditor = can_use_html_editor() && !$htmleditorused;
     $formatoptions = new stdClass();
     $formatoptions->noclean = true;
     $formatoptions->para = false;
     $inputname = $question->name_prefix;
     $stranswer = get_string("answer", "quiz") . ': ';
     /// set question text and media
     $questiontext = format_text($question->questiontext, $question->questiontextformat, $formatoptions, $cmoptions->course);
     $image = get_question_image($question);
     // feedback handling
     $feedback = '';
     if ($options->feedback && !empty($answers)) {
         foreach ($answers as $answer) {
             $feedback = format_text($answer->feedback, '', $formatoptions, $cmoptions->course);
         }
     }
     // get response value
     if (isset($state->responses[''])) {
         $value = stripslashes_safe($state->responses['']);
     } else {
         $value = "";
     }
     // answer
     if (empty($options->readonly)) {
         // the student needs to type in their answer so print out a text editor
         $answer = print_textarea($usehtmleditor, 18, 80, 630, 400, $inputname, $value, $cmoptions->course, true);
     } else {
         // it is read only, so just format the students answer and output it
         $safeformatoptions = new stdClass();
         $safeformatoptions->para = false;
         $answer = format_text($value, FORMAT_MOODLE, $safeformatoptions, $cmoptions->course);
         $answer = '<div class="answerreview">' . $answer . '</div>';
     }
     include "{$CFG->dirroot}/question/type/essay/display.html";
     if ($usehtmleditor && empty($options->readonly)) {
         use_html_editor($inputname);
         $htmleditorused = true;
     }
 }
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
echo "<br />";
helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
echo "<br />";
if ($this->usehtmleditor) {
    helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
    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");