function get_content()
 {
     global $CFG, $OUTPUT;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     if (empty($this->instance)) {
         $this->content->text = '';
         return $this->content;
     }
     $advancedsearch = get_string('advancedsearch', 'block_search_forums');
     $search = get_string('search');
     //Accessibility: replaced <input value=" />" type="submit"> with configurable text/'silent' character.
     // Theme config, $CFG->block_search_button = get_arrow_right() .'<span class="accesshide">'.get_string('search').'</span>';
     $button = isset($CFG->block_search_button) ? $CFG->block_search_button : get_string('go');
     $this->content->text = '<div class="searchform">';
     $this->content->text .= '<form action="' . $CFG->wwwroot . '/mod/forum/search.php" style="display:inline"><fieldset class="invisiblefieldset">';
     $this->content->text .= '<input name="id" type="hidden" value="' . $this->page->course->id . '" />';
     // course
     $this->content->text .= '<label class="accesshide" for="searchform_search">' . $search . '</label>' . '<input id="searchform_search" name="search" type="text" size="16" />';
     $this->content->text .= '<button id="searchform_button" type="submit" title="' . $search . '">' . $button . '</button><br />';
     $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/forum/search.php?id=' . $this->page->course->id . '">' . $advancedsearch . '</a>';
     $this->content->text .= $OUTPUT->help_icon(moodle_help_icon::make('search', $advancedsearch));
     $this->content->text .= '</fieldset></form></div>';
     return $this->content;
 }
Beispiel #2
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;
 }
Beispiel #3
0
/// Upload records section. Only for teachers and the admin.
if (has_capability('mod/data:manageentries', $context)) {
    if ($import) {
        echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
        echo $OUTPUT->heading(get_string('uploadrecords', 'data'), 3);
        $maxuploadsize = get_max_upload_file_size();
        echo '<div style="text-align:center">';
        echo '<form enctype="multipart/form-data" action="import.php" method="post">';
        echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . $maxuploadsize . '" />';
        echo '<input name="d" value="' . $data->id . '" type="hidden" />';
        echo '<input name="sesskey" value="' . sesskey() . '" type="hidden" />';
        echo '<table align="center" cellspacing="0" cellpadding="2" border="0">';
        echo '<tr>';
        echo '<td align="right">' . get_string('csvfile', 'data') . ':</td>';
        echo '<td><input type="file" name="recordsfile" size="30" />';
        echo $OUTPUT->help_icon(moodle_help_icon::make('importcsv', get_string('csvimport', 'data'), 'data'));
        echo '</td><tr>';
        echo '<td align="right">' . get_string('fielddelimiter', 'data') . ':</td>';
        echo '<td><input type="text" name="fielddelimiter" size="6" />';
        echo get_string('defaultfielddelimiter', 'data') . '</td>';
        echo '</tr>';
        echo '<td align="right">' . get_string('fieldenclosure', 'data') . ':</td>';
        echo '<td><input type="text" name="fieldenclosure" size="6" />';
        echo get_string('defaultfieldenclosure', 'data') . '</td>';
        echo '</tr>';
        echo '</table>';
        echo '<input type="submit" value="' . get_string('uploadfile', 'data') . '" />';
        echo '</form>';
        echo '</div>';
        echo $OUTPUT->box_end();
    } else {
Beispiel #4
0
            case LESSON_TRUEFALSE:
            case LESSON_MULTICHOICE:
            case LESSON_SHORTANSWER:
            case LESSON_NUMERICAL:
                echo "<tr><td><b>" . get_string("jump", "lesson") . " {$iplus1}:</b> \n";
                echo $OUTPUT->select(html_select::make($jump, "jumpto[{$i}]", 0, false));
                echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
                if ($lesson->custom) {
                    echo get_string("score", "lesson") . " {$iplus1}: <input type=\"text\" name=\"score[{$i}]\" value=\"0\" size=\"5\" />";
                }
                echo "</td></tr>\n";
                break;
            case LESSON_BRANCHTABLE:
                echo "<tr><td><b>" . get_string("jump", "lesson") . " {$iplus1}:</b> \n";
                echo $OUTPUT->select(html_select::make($jump, "jumpto[{$i}]", 0, false));
                echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
                echo "</td></tr>\n";
                break;
        }
    }
}
// close table and form
?>
    </table><br />
    <input type="button" value="<?php 
print_string("redisplaypage", "lesson");
?>
" 
        onclick="getElementById('editpage').redisplay.value=1;getElementById('editpage').submit();" />
    <input type="submit" value="<?php 
print_string("savepage", "lesson");
                                <input type="text" name="coursetag_sug_keyword" class="coursetag_form_input1a" disabled="disabled" />
                            </div>
                            <div class="coursetag_form_input2">
                                <input type="text" name="coursetag_new_tag" id="coursetag_new_tag" class="coursetag_form_input2a"
                                    onfocus="ctags_getKeywords()" onkeyup="ctags_getKeywords()" maxlength="50" />
                            </div>
                            <div class="coursetag_edit_input3" id="coursetag_sug_btn">
                                <a title="{$arrowtitle}">
                                    <img src="" . {$OUTPUT->old_icon_url}('t/arrow_left') . "" width="10" height="10" alt="enter" onclick="ctags_setKeywords()" />
                                </a>
                            </div>
                        </div>
                    </div>
EOT;
    if ($coursetabs) {
        $deletetagshelp = $OUTPUT->help_icon(moodle_help_icon::make('deletetags', 'deleting tags', $tagslang));
        $editdeletemytag = get_string('editdeletemytag', $tagslang);
        $outstr .= <<<EOT1
                    <div class="coursetag_edit_row">
                        <div class="coursetag_edit_left">
                            {$deletetagshelp}{$editdeletemytag}
                        </div>
                        <div class="coursetag_edit_right">
                            <select name="del_tag">
                                {$selectoptions}
                            </select>
                        </div>
                    </div>
EOT1;
    }
    $submitstr = get_string('submit');
Beispiel #6
0
 function output_quiz_info_table($course, $cm, $quiz, $quizstats, $usingattemptsstring, $currentgroup, $groupstudents, $useallattempts, $download, $reporturl, $everything)
 {
     global $DB, $OUTPUT;
     // Print information on the number of existing attempts
     $quizinformationtablehtml = $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'), 2, 'main');
     $quizinformationtable = new html_table();
     $quizinformationtable->align = array('center', 'center');
     $quizinformationtable->width = '60%';
     $quizinformationtable->class = 'generaltable titlesleft';
     $quizinformationtable->data = array();
     $quizinformationtable->data[] = array(get_string('quizname', 'quiz_statistics'), $quiz->name);
     $quizinformationtable->data[] = array(get_string('coursename', 'quiz_statistics'), $course->fullname);
     if ($cm->idnumber) {
         $quizinformationtable->data[] = array(get_string('idnumbermod'), $cm->idnumber);
     }
     if ($quiz->timeopen) {
         $quizinformationtable->data[] = array(get_string('quizopen', 'quiz'), userdate($quiz->timeopen));
     }
     if ($quiz->timeclose) {
         $quizinformationtable->data[] = array(get_string('quizclose', 'quiz'), userdate($quiz->timeclose));
     }
     if ($quiz->timeopen && $quiz->timeclose) {
         $quizinformationtable->data[] = array(get_string('duration', 'quiz_statistics'), format_time($quiz->timeclose - $quiz->timeopen));
     }
     $format = array('firstattemptscount' => '', 'allattemptscount' => '', 'firstattemptsavg' => 'sumgrades_as_percentage', 'allattemptsavg' => 'sumgrades_as_percentage', 'median' => 'sumgrades_as_percentage', 'standarddeviation' => 'sumgrades_as_percentage', 'skewness' => '', 'kurtosis' => '', 'cic' => 'number_format', 'errorratio' => 'number_format', 'standarderror' => 'sumgrades_as_percentage');
     foreach ($quizstats as $property => $value) {
         if (!isset($format[$property])) {
             continue;
         }
         if (!is_null($value)) {
             switch ($format[$property]) {
                 case 'sumgrades_as_percentage':
                     $formattedvalue = quiz_report_scale_sumgrades_as_percentage($value, $quiz);
                     break;
                 case 'number_format':
                     $formattedvalue = quiz_format_grade($quiz, $value) . '%';
                     break;
                 default:
                     $formattedvalue = $value;
             }
             $quizinformationtable->data[] = array(get_string($property, 'quiz_statistics', $usingattemptsstring), $formattedvalue);
         }
     }
     if (!$this->table->is_downloading()) {
         if (isset($quizstats->timemodified)) {
             list($fromqa, $whereqa, $qaparams) = quiz_report_attempts_sql($quiz->id, $currentgroup, $groupstudents, $useallattempts);
             $sql = 'SELECT COUNT(1) ' . 'FROM ' . $fromqa . ' ' . 'WHERE ' . $whereqa . ' AND qa.timefinish > :time';
             $a = new object();
             $a->lastcalculated = format_time(time() - $quizstats->timemodified);
             if (!($a->count = $DB->count_records_sql($sql, array('time' => $quizstats->timemodified) + $qaparams))) {
                 $a->count = 0;
             }
             $quizinformationtablehtml .= $OUTPUT->box_start('boxaligncenter generalbox boxwidthnormal mdl-align');
             $quizinformationtablehtml .= get_string('lastcalculated', 'quiz_statistics', $a);
             $quizinformationtablehtml .= $OUTPUT->button(html_form::make_button($reporturl->out(true), $reporturl->params() + array('recalculate' => 1), get_string('recalculatenow', 'quiz_statistics')));
             $quizinformationtablehtml .= $OUTPUT->box_end();
         }
         $downloadoptions = $this->table->get_download_menu();
         $quizinformationtablehtml .= '<form action="' . $this->table->baseurl . '" method="post">';
         $quizinformationtablehtml .= '<div class="mdl-align">';
         $quizinformationtablehtml .= '<input type="hidden" name="everything" value="1"/>';
         $quizinformationtablehtml .= '<input type="submit" value="' . get_string('downloadeverything', 'quiz_statistics') . '"/>';
         $select = html_select::make($downloadoptions, 'download', $this->table->defaultdownloadformat, false);
         $select->nothingvalue = '';
         $quizinformationtablehtml .= $OUTPUT->select($select);
         $quizinformationtablehtml .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table')));
         $quizinformationtablehtml .= '</div></form>';
     }
     $quizinformationtablehtml .= $OUTPUT->table($quizinformationtable);
     if (!$this->table->is_downloading()) {
         echo $quizinformationtablehtml;
     } elseif ($everything) {
         $exportclass =& $this->table->export_class_instance();
         if ($download == 'xhtml') {
             echo $quizinformationtablehtml;
         } else {
             $exportclass->start_table(get_string('quizinformation', 'quiz_statistics'));
             $headers = array();
             $row = array();
             foreach ($quizinformationtable->data as $data) {
                 $headers[] = $data[0];
                 $row[] = $data[1];
             }
             $exportclass->output_headers($headers);
             $exportclass->add_data($row);
             $exportclass->finish_table();
         }
     }
 }
Beispiel #7
0
admin_externalpage_print_header();
if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
    echo $OUTPUT->box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
} else {
    if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
        echo $OUTPUT->box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror');
    }
}
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
    echo $OUTPUT->box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
}
// If no recently cron run
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
if (time() - $lastcron > 3600 * 24) {
    $strinstallation = get_string('installation', 'install');
    $helpbutton = $OUTPUT->help_icon(moodle_help_icon::make('install', $strinstallation));
    echo $OUTPUT->box(get_string('cronwarning', 'admin') . '&nbsp;' . $helpbutton, 'generalbox adminwarning');
}
// Print multilang upgrade notice if needed
if (empty($CFG->filter_multilang_converted)) {
    echo $OUTPUT->box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning');
}
// Alert if we are currently in maintenance mode
if (!empty($CFG->maintenance_enabled)) {
    echo $OUTPUT->box(get_string('sitemaintenancewarning2', 'admin', "{$CFG->wwwroot}/{$CFG->admin}/settings.php?section=maintenancemode"), 'generalbox adminwarning');
}
//////////////////////////////////////////////////////////////////////////////////////////////////
////  IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> ' . '<a href="http://docs.moodle.org/en/Release" title="' . $CFG->version . '">' . $CFG->release . '</a><br />' . 'Copyright &copy; 1999 onwards, Martin Dougiamas<br />' . 'and <a href="http://docs.moodle.org/en/Credits">many other contributors</a>.<br />' . '<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
echo $OUTPUT->box($copyrighttext, 'copyright');
//////////////////////////////////////////////////////////////////////////////////////////////////
Beispiel #8
0
         echo "<a title=\"{$strallowchoice}\" href=\"subscribe.php?id={$forum->id}&amp;force=no\">{$strallowchoice}</a>";
     } else {
         echo $streveryoneisnowsubscribed;
     }
     echo '</span><br />';
 } else {
     if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
         $strsubscriptionsoff = get_string('disallowsubscribe', 'forum');
         echo $strsubscriptionsoff;
         echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strsubscriptionsoff, "forum"));
     } else {
         $streveryonecannowchoose = get_string("everyonecannowchoose", "forum");
         $strforcesubscribe = get_string("forcesubscribe", "forum");
         $strshowsubscribers = get_string("showsubscribers", "forum");
         echo '<span class="helplink">' . get_string("allowsallsubscribe", 'forum') . '</span><br />';
         echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strforcesubscribe, "forum"));
         echo '&nbsp;';
         if (has_capability('mod/forum:managesubscriptions', $context)) {
             echo "<span class=\"helplink\"><a title=\"{$strforcesubscribe}\" href=\"subscribe.php?id={$forum->id}&amp;force=yes\">{$strforcesubscribe}</a></span>";
         } else {
             echo '<span class="helplink">' . $streveryonecannowchoose . '</span>';
         }
         if (has_capability('mod/forum:viewsubscribers', $context)) {
             echo "<br />";
             echo "<span class=\"helplink\"><a href=\"subscribers.php?id={$forum->id}\">{$strshowsubscribers}</a></span>";
         }
         echo '<div class="helplink" id="subscriptionlink">', forum_get_subscribe_link($forum, $context, array('forcesubscribed' => '', 'cantsubscribe' => '')), '</div>';
     }
 }
 if (forum_tp_can_track_forums($forum)) {
     echo '<div class="helplink" id="trackinglink">' . forum_get_tracking_link($forum) . '</div>';
Beispiel #9
0
 /**
  * Print the Your progress help icon if the completion tracking is enabled.
  * @global object
  * @return void
  */
 public function print_help_icon()
 {
     global $PAGE, $OUTPUT;
     if ($this->is_enabled() && !$PAGE->user_is_editing() && isloggedin() && !isguestuser()) {
         echo '<span id = "completionprogressid" class="completionprogress">' . get_string('yourprogress', 'completion') . ' ';
         echo $OUTPUT->help_icon(moodle_help_icon::make('completionicons', get_string('completionicons', 'completion'), 'completion'));
         echo '</span>';
     }
 }
Beispiel #10
0
/**
 * Print a help button.
 *
 * Prints a special help button that is a link to the "live" emoticon popup
 *
 * @todo Finish documenting this function
 *
 * @global object
 * @global object
 * @param string $form ?
 * @param string $field ?
 * @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
 * @return string|void Depending on value of $return
 */
function emoticonhelpbutton($form, $field, $return = false)
{
    global $SESSION, $OUTPUT;
    $SESSION->inserttextform = $form;
    $SESSION->inserttextfield = $field;
    $helpicon = moodle_help_icon::make('emoticons2', get_string('helpemoticons'), 'moodle', true);
    $helpicon->image->src = $OUTPUT->old_icon_url('s/smiley');
    $helpicon->image->add_class('emoticon');
    $helpicon->style = "margin-left:3px; padding-right:1px;width:15px;height:15px;";
    $help = $OUTPUT->help_icon($helpicon);
    if (!$return) {
        echo $help;
    } else {
        return $help;
    }
}
Beispiel #11
0
     $mygroupid = groups_get_activity_group($cm);
     //get students in conjunction with groupmode
     if ($groupmode > 0) {
         if ($mygroupid > 0) {
             $students = feedback_get_complete_users($cm, $mygroupid);
         } else {
             $students = feedback_get_complete_users($cm);
         }
     } else {
         $students = feedback_get_complete_users($cm);
     }
     $completedFeedbackCount = feedback_get_completeds_group_count($feedback, $mygroupid);
     if ($feedback->course == SITEID) {
         echo '<div class="mdl-align"><a href="' . htmlspecialchars('analysis_course.php?id=' . $id . '&courseid=' . $courseid) . '">';
         echo get_string('course') . ' ' . get_string('analysis', 'feedback') . ' (' . get_string('completed_feedbacks', 'feedback') . ': ' . intval($completedFeedbackCount) . ')</a>';
         echo $OUTPUT->help_icon(moodle_help_icon::make('viewcompleted', '', 'feedback', true));
         echo '</div>';
     } else {
         echo '<div class="mdl-align"><a href="' . htmlspecialchars('analysis.php?id=' . $id . '&courseid=' . $courseid) . '">';
         echo get_string('analysis', 'feedback') . ' (' . get_string('completed_feedbacks', 'feedback') . ': ' . intval($completedFeedbackCount) . ')</a>';
         echo '</div>';
     }
 }
 //####### viewreports-start
 if ($capabilities->viewreports) {
     //print the list of students
     echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
     echo isset($groupselect) ? $groupselect : '';
     echo '<div class="clearer"></div>';
     echo '<div class="mdl-align"><table><tr><td width="400">';
     if (!$students) {
Beispiel #12
0
 protected function add_header_cells()
 {
     global $OUTPUT;
     echo '<th colspan="' . count($this->displaypermissions) . '" scope="col">' . get_string('permission', 'role') . ' ' . $OUTPUT->help_icon(moodle_help_icon::make('permissions', get_string('permissions', 'role'))) . '</th>';
     echo '<th class="risk" colspan="' . count($this->allrisks) . '" scope="col">' . get_string('risks', 'role') . '</th>';
 }
Beispiel #13
0
/**
 * If there is a media file associated with this 
 * lesson, return a block_contents that displays it.
 *
 * @param int $cmid Course Module ID for this lesson
 * @param object $lesson Full lesson record object
 * @return block_contents
 **/
function lesson_mediafile_block_contents($cmid, $lesson)
{
    global $OUTPUT;
    if (empty($lesson->mediafile)) {
        return null;
    }
    $url = '/mod/lesson/mediafile.php?id=' . $cmid;
    $options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width=' . $lesson->mediawidth . ',height=' . $lesson->mediaheight;
    $name = 'lessonmediafile';
    $link = html_link::make($url, get_string('mediafilepopup', 'lesson'));
    $link->add_action(new popup_action('click', $link->url, $name, $options));
    $link->title = get_string('mediafilepopup', 'lesson');
    $content .= $OUTPUT->link($link);
    $content .= $OUTPUT->help_icon(moodle_help_icon::make("mediafilestudent", get_string("mediafile", "lesson"), "lesson"));
    $bc = new block_contents();
    $bc->title = get_string('linkedmedia', 'lesson');
    $bc->set_classes('mediafile');
    $bc->content = $content;
    return $bc;
}
Beispiel #14
0
}
//Get the user theme
$USER = $DB->get_record('user', array('id' => $chatuser->userid));
//Setup course, lang and theme
$PAGE->set_course($DB->get_record('course', array('id' => $chatuser->course)));
$PAGE->requires->js('mod/chat/gui_sockets/chat_gui_sockets.js')->in_head();
$PAGE->requires->js_function_call('setfocus');
// TODO: there will be two onload in body tag, does it matter?
print_header('', '', '', 'inputform.chat_message', '', false, '&nbsp;', '', false);
?>

    <form action="../empty.php" method="get" target="empty" id="inputform"
          onsubmit="return empty_field_and_submit();">
        <input type="text" name="chat_message" size="60" value="" />
        <?php 
echo $OUTPUT->help_icon(moodle_help_icon::make("chatting", get_string("helpchatting", "chat"), "chat", true));
?>
    </form>
    
    <form action="<?php 
echo "http://{$CFG->chat_serverhost}:{$CFG->chat_serverport}/";
?>
" method="get" target="empty" id="sendform">
        <input type="hidden" name="win" value="message" />
        <input type="hidden" name="chat_message" value="" />
        <input type="hidden" name="chat_msgidnr" value="0" />
        <input type="hidden" name="chat_sid" value="<?php 
echo $chat_sid;
?>
" />
    </form>
Beispiel #15
0
 public function get_header_cell()
 {
     global $OUTPUT;
     return '<th class="header" scope="col">' . get_string('plusfactor', 'grades') . $OUTPUT->help_icon(moodle_help_icon::make('plusfactor', 'plusfactor', 'grade')) . '</th>';
 }
Beispiel #16
0
 function create_analysis_table(&$users, &$attempts, &$questions, &$options, &$tables)
 {
     global $OUTPUT;
     $is_html = $options['reportformat'] == 'htm';
     // the fields we are interested in, in the order we want them
     $fields = array('correct', 'wrong', 'ignored', 'hints', 'clues', 'checks', 'weighting');
     $string_fields = array('correct', 'wrong', 'ignored');
     $q = array();
     // statistics about the $q(uestions)
     $f = array();
     // statistics about the $f(ields)
     ////////////////////////////////////////////
     // compile the statistics about the questions
     ////////////////////////////////////////////
     foreach ($questions as $id => $question) {
         // extract scores for attempts at this question
         $scores = array();
         foreach ($question->attempts as $attempt) {
             $scores[] = $attempt->score;
         }
         // sort scores values (in ascending order)
         asort($scores);
         // get the borderline high and low scores
         $count = count($scores);
         switch ($count) {
             case 0:
                 $lo_score = 0;
                 $hi_score = 0;
                 break;
             case 1:
                 $lo_score = 0;
                 $hi_score = $scores[0];
                 break;
             default:
                 $lo_score = $scores[round($count * 1 / 3)];
                 $hi_score = $scores[round($count * 2 / 3)];
                 break;
         }
         // get statistics for each attempt which includes this question
         foreach ($question->attempts as $attempt) {
             $is_hi_score = $attempt->score >= $hi_score;
             $is_lo_score = $attempt->score < $lo_score;
             // reference to the response to the current question
             $response =& $attempt->responses[$id];
             // update statistics for fields in this response
             foreach ($fields as $field) {
                 if (!isset($q[$id])) {
                     $q[$id] = array();
                 }
                 if (!isset($f[$field])) {
                     $f[$field] = array('count' => 0);
                 }
                 if (!isset($q[$id][$field])) {
                     $q[$id][$field] = array('count' => 0);
                 }
                 $values = explode(',', $response->{$field});
                 $values = array_unique($values);
                 foreach ($values as $value) {
                     // $value should be an integer (string_id or count)
                     if (is_numeric($value)) {
                         $f[$field]['count']++;
                         if (!isset($q[$id][$field][$value])) {
                             $q[$id][$field][$value] = 0;
                         }
                         $q[$id][$field]['count']++;
                         $q[$id][$field][$value]++;
                     }
                 }
             }
             // end foreach $field
             // initialize counters for this question, if necessary
             if (!isset($q[$id]['count'])) {
                 $q[$id]['count'] = array('hi' => 0, 'lo' => 0, 'correct' => 0, 'total' => 0, 'sum' => 0);
             }
             // increment counters
             $q[$id]['count']['sum'] += $response->score;
             $q[$id]['count']['total']++;
             if ($response->score == 100) {
                 $q[$id]['count']['correct']++;
                 if ($is_hi_score) {
                     $q[$id]['count']['hi']++;
                 } else {
                     if ($is_lo_score) {
                         $q[$id]['count']['lo']++;
                     }
                 }
             }
         }
         // end foreach attempt
     }
     // end foreach question
     // check we have some details
     if (count($q)) {
         $showhideid = 'showhide';
         // shortcuts for html tags
         $bold_start = $is_html ? '<strong>' : "";
         $bold_end = $is_html ? '</strong>' : "";
         $div_start = $is_html ? '<div id="' . $showhideid . '">' : "";
         $div_end = $is_html ? '</div>' : "";
         $font_red = $is_html ? '<font color="red" size="-2">' : '';
         $font_blue = $is_html ? '<font color="blue" size="-2">' : '';
         $font_green = $is_html ? '<font color="green" size="-2">' : '';
         $font_brown = $is_html ? '<font color="brown" size="-2">' : '';
         $font_end = $is_html ? '</font>' . "\n" : '';
         $br = $is_html ? '<br />' : "\n";
         $space = $is_html ? '&nbsp;' : "";
         $no_value = $is_html ? '--' : "";
         $help_button = $is_html ? $OUTPUT->help_icon(moodle_help_icon::make("discrimination", get_string('discrimination', 'quiz'), "quiz")) : "";
         // table properties
         unset($table);
         $table->border = 1;
         $table->width = '100%';
         $table->caption = get_string('itemanal', 'quiz');
         if ($is_html) {
             $table->caption .= $OUTPUT->help_icon(moodle_help_icon::make('analysistable', $table->caption, 'hotpot'));
         }
         // initialize legend, if necessary
         if (!empty($options['reportshowlegend'])) {
             if (empty($tables) || empty($tables[0]->legend)) {
                 $table->legend = array();
             } else {
                 $table->legend = $tables[0]->legend;
                 unset($tables[0]->legend);
             }
         }
         // headings for name, attempt number and score/grade
         $table->head = array($space);
         $table->align = array('right');
         $table->size = array(80);
         // question headings
         $this->add_question_headings($questions, $table, 'left', 0);
         // initialize statistics
         $table->stat = array();
         $table->statheadercols = array(0);
         // add headings for the $foot of the $table
         $table->foot = array();
         $table->foot[0] = array(get_string('average', 'hotpot'));
         $table->foot[1] = array(get_string('percentcorrect', 'quiz'));
         $table->foot[2] = array(get_string('discrimination', 'quiz') . $help_button);
         // maximum discrimination index (also default the default value)
         $max_d_index = 10;
         ////////////////////////////////////////////
         // format the statistics into the $table
         ////////////////////////////////////////////
         // add $stat(istics) and $foot of $table
         $questionids = array_keys($q);
         foreach ($questionids as $col => $id) {
             $row = 0;
             // print the question text if there is no legend
             if (empty($table->legend)) {
                 // add button to show/hide question text
                 if (!isset($table->stat[0])) {
                     $button = $is_html ? hotpot_showhide_button($showhideid) : "";
                     $table->stat[0] = array(get_string('question', 'quiz') . $button);
                 }
                 // add the question name/text
                 $name = hotpot_get_question_name($questions[$id]);
                 $table->stat[$row++][$col + 1] = $div_start . $bold_start . $name . $bold_end . $div_end . $space;
             }
             // add details about each field
             foreach ($fields as $field) {
                 // check this row is required
                 if ($f[$field]['count']) {
                     $values = array();
                     $string_type = array_search($field, $string_fields);
                     // get the value of each response to this field
                     // and the count of that value
                     foreach ($q[$id][$field] as $value => $count) {
                         if (is_numeric($value) && $count) {
                             if (is_numeric($string_type)) {
                                 $value = hotpot_string($value);
                                 $this->set_legend($table, $col, $value, $questions[$id]);
                                 switch ($string_type) {
                                     case 0:
                                         // correct
                                         $font_start = $font_red;
                                         break;
                                     case 1:
                                         // wrong
                                         $font_start = $font_blue;
                                         break;
                                     case 2:
                                         // ignored
                                         $font_start = $font_brown;
                                         break;
                                 }
                             } else {
                                 // numeric field
                                 $font_start = $font_green;
                             }
                             $values[] = $font_start . round(100 * $count / $q[$id]['count']['total']) . '%' . $font_end . ' ' . $value;
                         }
                     }
                     // end foreach $value => $count
                     // initialize stat(istics) row for this field, if required
                     if (!isset($table->stat[$row])) {
                         $table->stat[$row] = array(get_string($field, 'hotpot'));
                     }
                     // sort the values by frequency (using user-defined function)
                     usort($values, "hotpot_sort_stat_values");
                     // add stat(istics) values for this field
                     $table->stat[$row++][$col + 1] = count($values) ? implode($br, $values) : $space;
                 }
             }
             // end foreach field
             // default percent correct and discrimination index for this question
             $average = $no_value;
             $percent = $no_value;
             $d_index = $no_value;
             if (isset($q[$id]['count'])) {
                 // average and percent correct
                 if ($q[$id]['count']['total']) {
                     $average = round($q[$id]['count']['sum'] / $q[$id]['count']['total']) . '%';
                     $percent = round(100 * $q[$id]['count']['correct'] / $q[$id]['count']['total']) . '%';
                     $percent .= ' (' . $q[$id]['count']['correct'] . '/' . $q[$id]['count']['total'] . ')';
                 }
                 // discrimination index
                 if ($q[$id]['count']['lo']) {
                     $d_index = min($max_d_index, round($q[$id]['count']['hi'] / $q[$id]['count']['lo'], 1));
                 } else {
                     $d_index = $q[$id]['count']['hi'] ? $max_d_index : 0;
                 }
                 $d_index .= ' (' . $q[$id]['count']['hi'] . '/' . $q[$id]['count']['lo'] . ')';
             }
             $table->foot[0][$col + 1] = $average;
             $table->foot[1][$col + 1] = $percent;
             $table->foot[2][$col + 1] = $d_index;
         }
         // end foreach $question ($col)
         // add javascript to show/hide question text
         if (isset($table->stat[0]) && $is_html && empty($table->legend)) {
             $i = count($table->stat[0]);
             $table->stat[0][$i - 1] .= hotpot_showhide_set($showhideid);
         }
         $tables[] =& $table;
         $this->create_legend_table($tables, $table);
     }
     // end if (empty($q)
 }
Beispiel #17
0
    function get_content()
    {
        global $CFG, $SITE, $USER, $SCRIPT, $OUTPUT;
        if (empty($CFG->usetags)) {
            $this->content->text = '';
            return $this->content;
        }
        if (empty($this->config->numberoftags)) {
            $this->config->numberoftags = 80;
        }
        if ($this->content !== NULL) {
            return $this->content;
        }
        if (empty($this->instance)) {
            $this->content = '';
            return $this->content;
        }
        $this->content = new stdClass();
        $this->content->footer = '';
        /// Get a list of tags
        require_once $CFG->dirroot . '/tag/locallib.php';
        if (empty($CFG->block_tags_showcoursetags) or !$CFG->block_tags_showcoursetags) {
            $this->content->text = tag_print_cloud($this->config->numberoftags, true);
            // start of show course tags section
        } else {
            require_once $CFG->dirroot . '/tag/coursetagslib.php';
            // Permissions and page awareness
            $systemcontext = get_context_instance(CONTEXT_SYSTEM);
            $isguest = has_capability('moodle/legacy:guest', $systemcontext, $USER->id, false);
            $loggedin = isloggedin() && !$isguest;
            $coursepage = $canedit = false;
            $coursepage = isset($this->page->course->id) && $this->page->course->id != SITEID;
            $mymoodlepage = $SCRIPT == '/my/index.php' ? true : false;
            $sitepage = isset($this->page->course->id) && $this->page->course->id == SITEID && !$mymoodlepage;
            $coursecontext = get_context_instance(CONTEXT_COURSE, $this->page->course->id);
            if ($coursepage) {
                $canedit = has_capability('moodle/tag:create', $systemcontext);
            }
            // Check rss feed - temporarily removed until Dublin Core tags added
            // provides a feed of users course tags for each unit they have tagged
            //$rssfeed = '';
            //if (file_exists($CFG->dataroot.'/'.SITEID.'/usertagsrss/'.$USER->id.'/user_unit_tags_rss.xml')) {
            //    $rssfeed = '/file.php/'.SITEID.'/usertagsrss/'.$USER->id.'/user_unit_tags_rss.xml';
            //}
            // Language strings
            $tagslang = 'block_tags';
            // DB hits to get groups of marked up tags (if available)
            //TODO check whether time limited personal tags are required
            $numoftags = $this->config->numberoftags;
            $sort = 'name';
            $alltags = $officialtags = $coursetags = $commtags = $mytags = $coursetagdivs = $courseflag = '';
            if ($sitepage or $coursepage) {
                $alltags = coursetag_print_cloud(coursetag_get_all_tags($sort, $this->config->numberoftags), true);
                $officialtags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', $numoftags, $sort), true);
                $commtags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', $numoftags, $sort), true);
                if ($loggedin) {
                    $mytags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', $numoftags, $sort), true);
                }
            }
            if ($coursepage) {
                $coursetags = coursetag_print_cloud(coursetag_get_tags($this->page->course->id, 0, '', $numoftags, $sort), true);
                if (!$coursetags) {
                    $coursetags = get_string('notagsyet', $tagslang);
                }
                $courseflag = '&amp;courseid=' . $this->page->course->id;
            }
            if ($mymoodlepage) {
                $mytags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id, 'default', $numoftags, $sort), true);
                $officialtags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'official', $numoftags, $sort), true);
                $commtags = coursetag_print_cloud(coursetag_get_tags(0, 0, 'default', $numoftags, $sort), true);
            }
            // Prepare the divs and javascript that displays the groups of tags (and which is displayed first)
            $moretags = $CFG->wwwroot . '/tag/coursetags_more.php';
            $moretagstitle = get_string('moretags', $tagslang);
            $moretagsstring = get_string('more', $tagslang);
            $displayblock = 'style="display:block"';
            $displaynone = 'style="display:none"';
            //only one div created below will be displayed at a time
            if ($alltags) {
                if ($sitepage) {
                    $display = $displayblock;
                } else {
                    $display = $displaynone;
                }
                $alltagscontent = '
                    <div id="f_alltags" ' . $display . '>' . get_string("alltags", $tagslang) . '<div class="coursetag_list">' . $alltags . '</div>
                        <div class="coursetag_morelink">
                            <a href="' . $moretags . '?show=all' . $courseflag . '" title="' . $moretagstitle . '">' . $moretagsstring . '</a>
                        </div>
                    </div>';
                $coursetagdivs .= '"f_alltags", ';
            }
            if ($mytags) {
                if ($mymoodlepage) {
                    $display = $displayblock;
                } else {
                    $display = $displaynone;
                }
                $mytagscontent = '
                    <div id="f_mytags" ' . $display . '>';
                /*if ($rssfeed) { // - temporarily removed
                      $mytagscontent .= link_to_popup_window(
                          $rssfeed, $name='popup',
                          '<img src="'.$CFG->wwwroot.'/pix/rss.gif" alt="User Unit Tags RSS" /> My Unit Tags RSS',
                          $height=600, $width=800,
                          $title='My Unit Tags RSS', $options='menubar=1,scrollbars,resizable', $return=true).'<br />';
                  }*/
                $mytagscontent .= get_string('mytags', $tagslang) . '<div class="coursetag_list">' . $mytags . '</div>
                        <div class="coursetag_morelink">
                            <a href="' . $moretags . '?show=my' . $courseflag . '" title="' . $moretagstitle . '">' . $moretagsstring . '</a>
                        </div>
                    </div>';
                $coursetagdivs .= '"f_mytags", ';
            }
            if ($officialtags) {
                if ($mytags or $alltags) {
                    $display = $displaynone;
                } else {
                    $display = $displayblock;
                }
                $officialtagscontent = '
                    <div id="f_officialtags" ' . $display . '>' . get_string('officialtags', $tagslang) . '<div class="coursetag_list">' . $officialtags . '</div>
                        <div class="coursetag_morelink">
                            <a href="' . $moretags . '?show=official' . $courseflag . '" title="' . $moretagstitle . '">' . $moretagsstring . '</a>
                        </div>
                    </div>';
                $coursetagdivs .= '"f_officialtags", ';
            }
            if ($coursetags) {
                if ($coursepage) {
                    $display = $displayblock;
                } else {
                    $display = $displaynone;
                }
                $coursetagscontent = '
                    <div id="f_coursetags" ' . $display . '>' . get_string('coursetags', $tagslang) . '<div class="coursetag_list">' . $coursetags . '</div>
                        <div class="coursetag_morelink">
                            <a href="' . $moretags . '?show=course' . $courseflag . '" title="' . $moretagstitle . '">' . $moretagsstring . '</a>
                        </div>
                    </div>';
                $coursetagdivs .= '"f_coursetags", ';
            }
            if ($commtags) {
                $commtagscontent = '
                    <div id="f_commtags" ' . $displaynone . '>' . get_string('communitytags', $tagslang) . '<div class="coursetag_list">' . $commtags . '</div>
                        <div class="coursetag_morelink">
                            <a href="' . $moretags . '?show=community' . $courseflag . '" title="' . $moretagstitle . '">' . $moretagsstring . '</a>
                        </div>
                    </div>';
                $coursetagdivs .= '"f_commtags", ';
            }
            // Tidy up the end of a javascript array and add javascript
            $coursetagdivs = rtrim($coursetagdivs, ', ');
            $this->content->text .= coursetag_get_jscript($coursetagdivs);
            // Add the divs (containing the tags) to the block's content
            if ($alltags) {
                $this->content->text .= $alltagscontent;
            }
            if ($mytags) {
                $this->content->text .= $mytagscontent;
            }
            if ($officialtags) {
                $this->content->text .= $officialtagscontent;
            }
            if ($coursetags) {
                $this->content->text .= $coursetagscontent;
            }
            if ($commtags) {
                $this->content->text .= $commtagscontent;
            }
            // add the input form section (allowing a user to tag the current course) and navigation, or loggin message
            if ($loggedin) {
                // only show the input form on course pages for those allowed (or not barred)
                if ($coursepage && $canedit) {
                    //$this->content->footer .= coursetag_get_jscript();
                    $tagthisunit = get_string('tagthisunit', $tagslang);
                    $buttonadd = get_string('add', $tagslang);
                    $arrowtitle = get_string('arrowtitle', $tagslang);
                    $coursetaghelpbutton = $OUTPUT->help_icon(moodle_help_icon::make('addtags', 'adding tags', $tagslang));
                    $sesskey = sesskey();
                    $arrowright = $OUTPUT->old_icon_url('t/arrow_left');
                    $this->content->footer .= <<<EOT
                        <hr />
                        <form action="{$CFG->wwwroot}/tag/coursetags_add.php" method="post" id="coursetag"
                                onsubmit="return ctags_checkinput(this.coursetag_new_tag.value)">
                            <div style="display: none;">
                                <input type="hidden" name="entryid" value="{$this->page}->course->id" />
                                <input type="hidden" name="userid" value="{$USER->id}" />
                                <input type="hidden" name="sesskey" value="{$sesskey}" />
                            </div>
                            <div><label for="coursetag_new_tag">{$tagthisunit}</label></div>
                            <div class="coursetag_form_wrapper">
                            <div class="coursetag_form_positioner">
                                <div class="coursetag_form_input1">
                                    <input type="text" name="coursetag_sug_keyword" class="coursetag_form_input1a" disabled="disabled" />
                                </div>
                                <div class="coursetag_form_input2">
                                    <input type="text" name="coursetag_new_tag" id="coursetag_new_tag" class="coursetag_form_input2a"
                                        onfocus="ctags_getKeywords()" onkeyup="ctags_getKeywords()" maxlength="50" />
                                </div>
                                <div class="coursetag_form_input3" id="coursetag_sug_btn">
                                    <a title="{$arrowtitle}">
                                        <img src="{$arrowright}" width="10" height="10" alt="enter" onclick="ctags_setKeywords()" />
                                    </a>
                                </div>
                            </div>
                            <div style="display: inline;">
                                <button type="submit">{$buttonadd}</button>
                                {$coursetaghelpbutton}
                            </div>
                            </div>
                        </form>
EOT;
                    // add the edit link
                    $this->content->footer .= '
                        <div>
                        <a href="' . $CFG->wwwroot . '/tag/coursetags_edit.php?courseid=' . $this->page->course->id . '"
                        title="' . get_string('edittags', $tagslang) . '">' . get_string('edittags', $tagslang) . '</a>
                        </div>';
                }
                // Navigation elements at the bottom of the block
                // show the alternative displays options if available
                if ($mytags or $officialtags or $commtags or $coursetags) {
                    $this->content->footer .= '<div id="coursetagslinks"></div>';
                }
                // This section sets the order of the links
                $coursetagslinks = array();
                if ($mytags) {
                    $coursetagslinks['my'] = array('title' => get_string('mytags2', $tagslang), 'onclick' => 'f_mytags', 'text' => get_string('mytags1', $tagslang));
                }
                // because alltags is always present, only show link if there is something else as well
                if ($alltags and ($mytags or $officialtags or $commtags or $coursetags)) {
                    $coursetagslinks['all'] = array('title' => get_string('alltags2', $tagslang), 'onclick' => 'f_alltags', 'text' => get_string('alltags1', $tagslang));
                }
                if ($officialtags) {
                    $coursetagslinks['off'] = array('title' => get_string('officialtags2', $tagslang), 'onclick' => 'f_officialtags', 'text' => get_string('officialtags1', $tagslang));
                }
                //if ($commtags) {
                //    $coursetagslinks['com'] = array('title'=>get_string('communitytags2', $tagslang),
                //                                    'onclick'=>'f_commtags',
                //                                    'text'=>get_string('communitytags1', $tagslang));
                //}
                if ($coursetags) {
                    $coursetagslinks['crs'] = array('title' => get_string('coursetags2', $tagslang), 'onclick' => 'f_coursetags', 'text' => get_string('coursetags1', $tagslang));
                }
                $this->content->footer .= coursetag_get_jscript_links($coursetagslinks);
            } else {
                //if not logged in
                $this->content->footer = '<hr />' . get_string('please', $tagslang) . '
                    <a href="' . get_login_url() . '">' . get_string('login', $tagslang) . '
                        </a> ' . get_string('tagunits', $tagslang);
            }
        }
        // end of show course tags section
        return $this->content;
    }
Beispiel #18
0
    $link2 .= '<b>' . $orderalpha . '</b> | ';
} else {
    $link2 .= '<a href="' . $myurl2 . '&amp;sort=alpha' . $courselink . '">' . $orderalpha . '</a> | ';
}
if ($sort == 'popularity') {
    $link2 .= '<b>' . $orderpop . '</b> | ';
} else {
    $link2 .= '<a href="' . $myurl2 . '&amp;sort=popularity' . $courselink . '">' . $orderpop . '</a> | ';
}
if ($sort == 'date') {
    $link2 .= '<b>' . $orderdate . '</b>';
} else {
    $link2 .= '<a href="' . $myurl2 . '&amp;sort=date' . $courselink . '">' . $orderdate . '</a>';
}
// Prepare output
$fclass = '';
// make the tags larger when there are not so many
if (strlen($tags) < 10000) {
    $fclass = 'coursetag_more_large';
}
$outstr = '
    <div class="coursetag_more_title">
        <div style="padding-bottom:5px">' . $welcome . $OUTPUT->help_icon(moodle_help_icon::make('usingtags', 'using tags', $tagslang)) . '
        </div>
        <div class="coursetag_more_link">' . $link1 . '</div>
        <div class="coursetag_more_link">' . $link2 . '</div>
    </div>
    <div class="coursetag_more_tags ' . $fclass . '">' . $tags . '
    </div>';
echo $outstr;
echo $OUTPUT->footer();
Beispiel #19
0
    echo '<td class="wikisearchform">';
    wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
    echo '</td>';
    /// Internal Wikilinks
    echo '<td class="wikilinksblock">';
    wiki_print_wikilinks_block($cm->id, $wiki->ewikiacceptbinary);
    echo '</td>';
    /// Administrative Links
    if ($canedit) {
        echo '<td class="wikiadminactions">';
        wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $ewiki_title, $wiki->htmlmode != 2, $course);
        echo '</td>';
    }
    /// Formatting Rules
    echo '<td class="howtowiki">';
    echo $OUTPUT->help_icon(moodle_help_icon::make('howtowiki', get_string('howtowiki', 'wiki'), 'wiki'));
    echo '</td>';
    echo '</tr></table>';
}
echo '</div>
    <div id="wiki-view" class="mwiki">
    ';
if ($wiki_entry && $ewiki_title == $wiki_entry->pagename && !empty($wiki->intro)) {
    if (trim(strip_tags($wiki->intro))) {
        echo $OUTPUT->box(format_module_intro('wiki', $wiki, $cm->id), 'generalbox', 'intro');
    }
}
// The wiki Contents
if (!empty($canedit)) {
    /// Print tabs with commands for this page
    $tabs = array('view', 'edit', 'links', 'info');
Beispiel #20
0
$basemenu[0] = get_string('startdate') . ' (' . userdate($course->startdate, $timeformat) . ')';
$basemenu[1] = get_string('enrolmentstart');
$basemenu[2] = get_string('enrolmentend');
if ($course->enrollable != 2 || ($course->enrolstartdate == 0 || $course->enrolstartdate <= $today) && ($course->enrolenddate == 0 || $course->enrolenddate > $today)) {
    $basemenu[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')';
}
if ($course->enrollable == 2) {
    if ($course->enrolstartdate > 0) {
        $basemenu[4] = get_string('courseenrolstartdate') . ' (' . userdate($course->enrolstartdate, $timeformat) . ')';
    }
    if ($course->enrolenddate > 0) {
        $basemenu[5] = get_string('courseenrolenddate') . ' (' . userdate($course->enrolenddate, $timeformat) . ')';
    }
}
$title = get_string('extendenrol');
echo $OUTPUT->heading($title . $OUTPUT->help_icon(moodle_help_icon::make('extendenrol', $title)));
echo "<form method=\"post\" action=\"extendenrol.php\">\n";
echo '<input type="hidden" name="id" value="' . $course->id . '" />';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
$table = new html_table();
$table->head = array(get_string('fullnameuser'), get_string('enrolmentstart'), get_string('enrolmentend'), get_string('extendperiod'), get_string('startingfrom'));
$table->align = array('left', 'center', 'center', 'center');
$table->width = "600";
$nochange = get_string('nochange');
$notavailable = get_string('notavailable');
foreach ($_POST as $k => $v) {
    if (preg_match('/^user(\\d+)$/', $k, $m)) {
        if (!($user = $DB->get_record_sql("SELECT *\n                                             FROM {user} u\n                                             JOIN {role_assignments} ra ON u.id=ra.userid\n                                            WHERE u.id=? AND ra.contextid = ?", array($m[1], $context->id)))) {
            continue;
        }
        $userbasemenu = $basemenu;
Beispiel #21
0
echo '<input type="hidden" name="id" value="' . $id . '" />';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
$sql = "select c.id, c.shortname\n              from {course} c\n             where c.shortname " . $DB->sql_ilike() . " ?\n                   OR c.fullname " . $DB->sql_ilike() . " ?";
$params = array("%{$searchcourse}%", "%{$searchcourse}%");
if (($courses = $DB->get_records_sql_menu($sql, $params)) && !empty($searchcourse)) {
    echo ' ' . get_string('courses') . ': ';
    echo $OUTPUT->select(html_select::make($courses, 'coursefilter', $coursefilter));
    echo '<input type="submit" value="' . get_string('mapcourse', 'feedback') . '"/>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('mapcourses', '', 'feedback', true));
    echo '<input type="button" value="' . get_string('searchagain') . '" onclick="document.location=\'mapcourse.php?id=' . $id . '\'"/>';
    echo '<input type="hidden" name="searchcourse" value="' . $searchcourse . '"/>';
    echo '<input type="hidden" name="feedbackid" value="' . $feedback->id . '"/>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('searchcourses', '', 'feedback', true));
} else {
    echo '<input type="text" name="searchcourse" value="' . $searchcourse . '"/> <input type="submit" value="' . get_string('searchcourses') . '"/>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('searchcourses', '', 'feedback', true));
}
echo '</form>';
if ($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) {
    $table = new flexible_table('coursemaps');
    $table->define_columns(array('course'));
    $table->define_headers(array(get_string('mappedcourses', 'feedback')));
    $table->setup();
    foreach ($coursemap as $cmap) {
        $table->add_data(array('<a href="' . htmlspecialchars('unmapcourse.php?id=' . $id . '&cmapid=' . $cmap->id) . '"><img src="' . $OUTPUT->old_icon_url('t/delete') . '" alt="Delete" /></a> (' . $cmap->shortname . ') ' . $cmap->fullname));
    }
    $table->print_html();
} else {
    echo '<h3>' . get_string('mapcoursenone', 'feedback') . '</h3>';
}
echo $OUTPUT->box_end();
Beispiel #22
0
    foreach ($users as $u) {
        $data = array('<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $u->userid . '&amp;course=' . $course->id . '">' . fullname($u, true) . '</a>' . "\n", !empty($u->count) ? get_string('yes') . ' (' . $u->count . ') ' : get_string('no'), '<input type="checkbox" name="user' . $u->userid . '" value="' . $u->count . '" />' . "\n");
        $table->add_data($data);
    }
    $table->print_html();
    if ($perpage == SHOW_ALL_PAGE_SIZE) {
        echo '<div id="showall"><a href="' . $baseurl . '&amp;perpage=' . DEFAULT_PAGE_SIZE . '">' . get_string('showperpage', '', DEFAULT_PAGE_SIZE) . '</a></div>' . "\n";
    } else {
        if ($matchcount > 0 && $perpage < $matchcount) {
            echo '<div id="showall"><a href="' . $baseurl . '&amp;perpage=' . SHOW_ALL_PAGE_SIZE . '">' . get_string('showall', '', $matchcount) . '</a></div>' . "\n";
        }
    }
    echo '<input type="button" onclick="checkall()" value="' . get_string('selectall') . '" /> ' . "\n";
    echo '<input type="button" onclick="checknone()" value="' . get_string('deselectall') . '" /> ' . "\n";
    if ($perpage >= $matchcount) {
        echo '<input type="button" onclick="checknos()" value="' . get_string('selectnos') . '" />' . "\n";
    }
    $displaylist['messageselect.php'] = get_string('messageselectadd');
    $select = new html_select();
    $select->options = $displaylist;
    $select->name = "formaction";
    $select->label = get_string("withselectedusers");
    $select->add_action('change', 'conditionalsubmit', array('formid' => 'studentsform'));
    echo $OUTPUT->select($select);
    echo $OUTPUT->help_icon(moodle_help_icon::make("participantswithselectedusers", get_string("withselectedusers")));
    echo '<input type="submit" value="' . get_string('ok') . '" />' . "\n";
    echo '</div>' . "\n";
    echo '</form>' . "\n";
    echo '</div>' . "\n";
}
echo $OUTPUT->footer();
Beispiel #23
0
function hotpot_print_report_selector(&$course, &$hotpot, &$formdata)
{
    global $CFG, $DB, $OUTPUT;
    $reports = hotpot_get_report_names('overview,simplestat,fullstat');
    print '<form method="post" action="' . "{$CFG->wwwroot}/mod/hotpot/report.php?hp={$hotpot->id}" . '">';
    print '<table cellpadding="2" align="center">';
    $menus = array();
    $menus['mode'] = array();
    foreach ($reports as $name) {
        if ($name == 'overview' || $name == 'simplestat' || $name == 'fullstat') {
            $module = "quiz";
            // standard reports
        } else {
            if ($name == 'click' && empty($hotpot->clickreporting)) {
                $module = "";
                // clickreporting is disabled
            } else {
                $module = "hotpot";
                // custom reports
            }
        }
        if ($module) {
            $menus['mode'][$name] = get_string("report{$name}", $module);
        }
    }
    $menus['reportusers'] = array('allusers' => get_string('allusers', 'hotpot'), 'allparticipants' => get_string('allparticipants'));
    // groups
    if ($groups = groups_get_all_groups($course->id)) {
        foreach ($groups as $gid => $group) {
            $menus['reportusers']["group{$gid}"] = get_string('group') . ': ' . format_string($group->name);
        }
    }
    // get users who have ever atetmpted this HotPot
    $users = $DB->get_records_sql("\n        SELECT \n            u.id, u.firstname, u.lastname\n        FROM \n            {user} u,\n            {hotpot_attempts} ha\n        WHERE\n            u.id = ha.userid AND ha.hotpot=?\n        ORDER BY\n            u.lastname\n    ", array($hotpot->id));
    if (!empty($users)) {
        // get context
        $cm = get_coursemodule_from_instance('hotpot', $hotpot->id);
        $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
        $teachers = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:viewreport');
        $students = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:attempt');
        // current students
        if (!empty($students)) {
            $firsttime = true;
            foreach ($users as $user) {
                if (array_key_exists($user->id, $teachers)) {
                    continue;
                    // skip teachers
                }
                if (array_key_exists($user->id, $students)) {
                    if ($firsttime) {
                        $firsttime = false;
                        // so we only do this once
                        $menus['reportusers']['existingstudents'] = get_string('existingstudents');
                        $menus['reportusers'][] = '------';
                    }
                    $menus['reportusers']["{$user->id}"] = fullname($user);
                    unset($users[$user->id]);
                }
            }
            unset($students);
        }
        // others (former students, teachers, admins, course creators)
        $firsttime = true;
        foreach ($users as $user) {
            if ($firsttime) {
                $firsttime = false;
                // so we only do this once
                $menus['reportusers'][] = '======';
            }
            $menus['reportusers']["{$user->id}"] = fullname($user);
        }
    }
    $menus['reportattempts'] = array('all' => get_string('attemptsall', 'hotpot'), 'best' => get_string('attemptsbest', 'hotpot'), 'first' => get_string('attemptsfirst', 'hotpot'), 'last' => get_string('attemptslast', 'hotpot'));
    print '<tr><td>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('reportcontent', get_string('reportcontent', 'hotpot'), 'hotpot'));
    print '</td><th align="right" scope="col">' . get_string('reportcontent', 'hotpot') . ':</th><td colspan="7">';
    foreach ($menus as $name => $options) {
        $value = $formdata[$name];
        print $OUTPUT->select(html_select::make($options, $name, $value, false));
    }
    print '<input type="submit" value="' . get_string('reportbutton', 'hotpot') . '" /></td></tr>';
    $menus = array();
    $menus['reportformat'] = array();
    $menus['reportformat']['htm'] = get_string('reportformathtml', 'hotpot');
    if (file_exists("{$CFG->libdir}/excel") || file_exists("{$CFG->libdir}/excellib.class.php")) {
        $menus['reportformat']['xls'] = get_string('reportformatexcel', 'hotpot');
    }
    $menus['reportformat']['txt'] = get_string('reportformattext', 'hotpot');
    if (trim($CFG->hotpot_excelencodings)) {
        $menus['reportencoding'] = array(get_string('none') => '');
        $encodings = explode(',', $CFG->hotpot_excelencodings);
        foreach ($encodings as $encoding) {
            $encoding = trim($encoding);
            if ($encoding) {
                $menus['reportencoding'][$encoding] = $encoding;
            }
        }
    }
    $menus['reportwrapdata'] = array('1' => get_string('yes'), '0' => get_string('no'));
    $menus['reportshowlegend'] = array('1' => get_string('yes'), '0' => get_string('no'));
    print '<tr><td>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('reportformat', get_string('reportformat', 'hotpot'), 'hotpot'));
    print '</td>';
    foreach ($menus as $name => $options) {
        $value = $formdata[$name];
        print '<th align="right" scope="col">' . get_string($name, 'hotpot') . ':</th><td>' . $OUTPUT->select(html_select::make($options, $name, $value, false)) . '</td>';
    }
    print '</tr>';
    print '</table>';
    print '<hr size="1" noshade="noshade" />';
    print '</form>' . "\n";
}
Beispiel #24
0
         $link->add_action(new popup_action('click', $link->url));
         echo $OUTPUT->link($link);
     }
     echo '</fieldset>';
 }
 // show the content of the original English file either in core space or plugin space
 if ($origlocation != '' && $origplugin != '') {
     // non-core help file
     $ensrc = "{$CFG->dirroot}/{$origlocation}/{$origplugin}/lang/en_utf8/help/{$currentfile}";
 } else {
     // core help file
     $ensrc = "{$enlangdir}/{$currentfile}";
 }
 if (is_readable($ensrc)) {
     echo '<fieldset><legend>' . $strlangmasterenglish;
     echo $OUTPUT->help_icon(moodle_help_icon::make('langpackages', $strlangmasterenglish));
     echo '</legend>';
     echo "<div class='mdl-align'>\n<textarea rows=\"{$fileeditorrows}\" cols=\"{$fileeditorcols}\" name=\"\">";
     echo htmlspecialchars(file_get_contents($ensrc));
     echo "</textarea>\n</div>\n";
     $preview_url = lang_help_preview_url($currentfile, true, 'en_utf8');
     // do not display en_utf8_local
     if ($preview_url) {
         $link = html_link::make($preview_url, get_string('preview'));
         $link->add_action(new popup_action('click', $link->url));
         echo $OUTPUT->link($link);
     }
     echo '</fieldset>';
 }
 echo '</div>';
 // translator box
Beispiel #25
0
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
$state_names = note_get_state_names();
// the first time list hack
if (empty($users)) {
    foreach ($_POST as $k => $v) {
        if (preg_match('/^user(\\d+)$/', $k, $m)) {
            $users[] = $m[1];
        }
    }
}
$strpublishstate = get_string('publishstate', 'notes');
$userlist = array();
foreach ($users as $k => $v) {
    if (!($user = $DB->get_record('user', array('id' => $v)))) {
        continue;
    }
    echo '<input type="hidden" name="userid[' . $k . ']" value="' . $v . '" />';
    $userlist[] = fullname($user, true);
}
echo '<p>';
echo get_string('users') . ': ' . implode(', ', $userlist) . '.';
echo '</p>';
echo '<p>' . get_string('content', 'notes');
echo $OUTPUT->help_icon(moodle_help_icon::make('writing', get_string('helpwriting')));
echo '<br /><textarea name="content" rows="5" cols="50">' . strip_tags(@$content) . '</textarea></p>';
echo '<p>' . $strpublishstate;
echo $OUTPUT->help_icon(moodle_help_icon::make('status', $strpublishstate, 'notes'));
echo $OUTPUT->select(html_select::make($state_names, 'state', empty($state) ? NOTES_STATE_PUBLIC : $state, false));
echo '</p>';
echo '<input type="submit" value="' . get_string('savechanges') . '" /></div></form>';
echo $OUTPUT->footer();
Beispiel #26
0
echo '<legend class="ftoggler">' . get_string('providers_config', 'message') . '</legend>';
$providers = message_get_my_providers();
$processors = $DB->get_records('message_processors');
$number_procs = count($processors);
echo '<table cellpadding="2"><tr><td>&nbsp;</td>' . "\n";
foreach ($processors as $processorid => $processor) {
    echo '<th align="center">' . get_string($processor->name, 'messageprocessor_' . $processor->name) . '</th>';
}
echo '</tr>';
foreach ($providers as $providerid => $provider) {
    $providername = get_string('messageprovider:' . $provider->name, $provider->component);
    /// TODO XXX: This is only a quick hack ... helpfile locations should be provided as part of the provider definition
    if ($provider->component == 'moodle') {
        $helpbtn = $OUTPUT->help_icon(moodle_help_icon::make('moodle_' . $provider->name, $providername, 'message'));
    } else {
        $helpbtn = $OUTPUT->help_icon(moodle_help_icon::make('message_' . $provider->name, $providername, basename($provider->component)));
    }
    echo '<tr><th align="right">' . $providername . $helpbtn . '</th><td colspan="' . $number_procs . '"></td></tr>' . "\n";
    foreach (array('loggedin', 'loggedoff') as $state) {
        $state_res = get_string($state, 'message');
        echo '<tr><td align="right">' . $state_res . '</td>' . "\n";
        foreach ($processors as $processorid => $processor) {
            if (!isset($preferences->{$provider->component . '_' . $provider->name . '_' . $state})) {
                $checked = '';
            } else {
                if (!isset($preferences->{$provider->component . '_' . $provider->name . '_' . $state}[$processor->name])) {
                    $checked = '';
                } else {
                    $checked = $preferences->{$provider->component . '_' . $provider->name . '_' . $state}[$processor->name] == 1 ? " checked=\"checked\"" : "";
                }
            }
Beispiel #27
0
        echo '<div class="mdl-align"><a href="' . htmlspecialchars('analysis.php?id=' . $id . '&courseid=' . $courseid) . '">';
        echo get_string('completed_feedbacks', 'feedback') . '</a>';
        echo '</div>';
    }
}
echo '<p>';
//####### mapcourse-start
if ($capabilities->mapcourse) {
    if ($feedback->course == SITEID) {
        echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
        echo '<div class="mdl-align">';
        echo '<form action="mapcourse.php" method="get">';
        echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
        echo '<input type="hidden" name="id" value="' . $id . '" />';
        echo '<button type="submit">' . get_string('mapcourses', 'feedback') . '</button>';
        echo $OUTPUT->help_icon(moodle_help_icon::make('mapcourse', '', 'feedback', true));
        echo '</form>';
        echo '<br />';
        echo '</div>';
        echo $OUTPUT->box_end();
    }
}
//####### mapcourse-end
//####### completed-start
if ($capabilities->complete) {
    echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
    //check, whether the feedback is open (timeopen, timeclose)
    $checktime = time();
    if ($feedback->timeopen > $checktime or $feedback->timeclose < $checktime and $feedback->timeclose > 0) {
        echo $OUTPUT->box_start('generalbox boxaligncenter');
        echo '<h2><font color="red">' . get_string('feedback_is_not_open', 'feedback') . '</font></h2>';
Beispiel #28
0
        mark_context_dirty($systemcontext->path);
        add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?action=reset&roleid=' . $roleid, $roles[$roleid]->localname, '', $USER->id);
        redirect($defineurl . '?action=view&amp;roleid=' . $roleid);
        break;
}
/// Print the page header and tabs.
admin_externalpage_print_header();
$currenttab = 'manage';
include_once 'managetabs.php';
/// Initialise table.
$table = new html_table();
$table->tablealign = 'center';
$table->align = array('left', 'left', 'left', 'left');
$table->wrap = array('nowrap', '', 'nowrap', 'nowrap');
$table->width = '90%';
$table->head = array(get_string('role') . ' ' . $OUTPUT->help_icon(moodle_help_icon::make('roles', get_string('roles'))), get_string('description'), get_string('shortname'), get_string('edit'));
/// Get some strings outside the loop.
$stredit = get_string('edit');
$strduplicate = get_string('duplicate');
$strdelete = get_string('delete');
$strmoveup = get_string('moveup');
$strmovedown = get_string('movedown');
/// Print a list of roles with edit/copy/delete/reorder icons.
$table->data = array();
$lastrole = end($roles);
foreach ($roles as $role) {
    /// Basic data.
    $row = array('<a href="' . $defineurl . '?action=view&amp;roleid=' . $role->id . '">' . $role->localname . '</a>', format_text($role->description, FORMAT_HTML), s($role->shortname), '');
    /// Icons:
    // move up
    if ($role->sortorder != 0) {
Beispiel #29
0
 /**
  *  Display all the submissions ready for grading
  *
  * @global object
  * @global object
  * @global object
  * @global object
  * @param string $message
  * @return bool|void
  */
 function display_submissions($message = '')
 {
     global $CFG, $DB, $USER, $DB, $OUTPUT;
     require_once $CFG->libdir . '/gradelib.php';
     /* first we check to see if the form has just been submitted
      * to request user_preference updates
      */
     if (isset($_POST['updatepref'])) {
         $perpage = optional_param('perpage', 10, PARAM_INT);
         $perpage = $perpage <= 0 ? 10 : $perpage;
         set_user_preference('assignment_perpage', $perpage);
         set_user_preference('assignment_quickgrade', optional_param('quickgrade', 0, PARAM_BOOL));
     }
     /* next we get perpage and quickgrade (allow quick grade) params
      * from database
      */
     $perpage = get_user_preferences('assignment_perpage', 10);
     $quickgrade = get_user_preferences('assignment_quickgrade', 0);
     $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id);
     if (!empty($CFG->enableoutcomes) and !empty($grading_info->outcomes)) {
         $uses_outcomes = true;
     } else {
         $uses_outcomes = false;
     }
     $page = optional_param('page', 0, PARAM_INT);
     $strsaveallfeedback = get_string('saveallfeedback', 'assignment');
     /// Some shortcuts to make the code read better
     $course = $this->course;
     $assignment = $this->assignment;
     $cm = $this->cm;
     $tabindex = 1;
     //tabindex for quick grading tabbing; Not working for dropdowns yet
     add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id=' . $this->cm->id, $this->assignment->id, $this->cm->id);
     $navigation = build_navigation($this->strsubmissions, $this->cm);
     print_header_simple(format_string($this->assignment->name, true), "", $navigation, '', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm));
     $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
     if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
         echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">' . get_string('seeallcoursegrades', 'grades') . '</a></div>';
     }
     if (!empty($message)) {
         echo $message;
         // display messages here if any
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// Check to see if groups are being used in this assignment
     /// find out current groups mode
     $groupmode = groups_get_activity_groupmode($cm);
     $currentgroup = groups_get_activity_group($cm, true);
     groups_print_activity_menu($cm, 'submissions.php?id=' . $this->cm->id);
     /// Get all ppl that are allowed to submit assignments
     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));
         }
     }
     $tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade');
     if ($uses_outcomes) {
         $tablecolumns[] = 'outcome';
         // no sorting based on outcomes column
     }
     $tableheaders = array('', get_string('fullname'), get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified') . ' (' . get_string('submission', 'assignment') . ')', get_string('lastmodified') . ' (' . get_string('grade') . ')', get_string('status'), get_string('finalgrade', 'grades'));
     if ($uses_outcomes) {
         $tableheaders[] = get_string('outcome', 'grades');
     }
     require_once $CFG->libdir . '/tablelib.php';
     $table = new flexible_table('mod-assignment-submissions');
     $table->define_columns($tablecolumns);
     $table->define_headers($tableheaders);
     $table->define_baseurl($CFG->wwwroot . '/mod/assignment/submissions.php?id=' . $this->cm->id . '&amp;currentgroup=' . $currentgroup);
     $table->sortable(true, 'lastname');
     //sorted by lastname by default
     $table->collapsible(true);
     $table->initialbars(true);
     $table->column_suppress('picture');
     $table->column_suppress('fullname');
     $table->column_class('picture', 'picture');
     $table->column_class('fullname', 'fullname');
     $table->column_class('grade', 'grade');
     $table->column_class('submissioncomment', 'comment');
     $table->column_class('timemodified', 'timemodified');
     $table->column_class('timemarked', 'timemarked');
     $table->column_class('status', 'status');
     $table->column_class('finalgrade', 'finalgrade');
     if ($uses_outcomes) {
         $table->column_class('outcome', 'outcome');
     }
     $table->set_attribute('cellspacing', '0');
     $table->set_attribute('id', 'attempts');
     $table->set_attribute('class', 'submissions');
     $table->set_attribute('width', '100%');
     //$table->set_attribute('align', 'center');
     $table->no_sorting('finalgrade');
     $table->no_sorting('outcome');
     // Start working -- this is necessary as soon as the niceties are over
     $table->setup();
     if (empty($users)) {
         echo $OUTPUT->heading(get_string('nosubmitusers', 'assignment'));
         return true;
     }
     /// Construct the SQL
     if ($where = $table->get_sql_where()) {
         $where .= ' AND ';
     }
     if ($sort = $table->get_sql_sort()) {
         $sort = ' ORDER BY ' . $sort;
     }
     $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 {user} u ' . 'LEFT JOIN {assignment_submissions} s ON u.id = s.userid
                                                               AND s.assignment = ' . $this->assignment->id . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
     $table->pagesize($perpage, count($users));
     ///offset used to calculate index of student in that particular query, needed for the pop up to know who's next
     $offset = $page * $perpage;
     $strupdate = get_string('update');
     $strgrade = get_string('grade');
     $grademenu = make_grades_menu($this->assignment->grade);
     if (($ausers = $DB->get_records_sql($select . $sql . $sort, null, $table->get_page_start(), $table->get_page_size())) !== false) {
         $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
         foreach ($ausers as $auser) {
             $final_grade = $grading_info->items[0]->grades[$auser->id];
             $grademax = $grading_info->items[0]->grademax;
             $final_grade->formatted_grade = round($final_grade->grade, 2) . ' / ' . round($grademax, 2);
             $locked_overridden = 'locked';
             if ($final_grade->overridden) {
                 $locked_overridden = 'overridden';
             }
             /// Calculate user status
             $auser->status = $auser->timemarked > 0 && $auser->timemarked >= $auser->timemodified;
             $picture = $OUTPUT->user_picture(moodle_user_picture::make($auser, $course->id));
             if (empty($auser->submissionid)) {
                 $auser->grade = -1;
                 //no submission yet
             }
             if (!empty($auser->submissionid)) {
                 ///Prints student answer and student modified date
                 ///attach file or print link to student answer, depending on the type of the assignment.
                 ///Refer to print_student_answer in inherited classes.
                 if ($auser->timemodified > 0) {
                     $studentmodified = '<div id="ts' . $auser->id . '">' . $this->print_student_answer($auser->id) . userdate($auser->timemodified) . '</div>';
                 } else {
                     $studentmodified = '<div id="ts' . $auser->id . '">&nbsp;</div>';
                 }
                 ///Print grade, dropdown or text
                 if ($auser->timemarked > 0) {
                     $teachermodified = '<div id="tt' . $auser->id . '">' . userdate($auser->timemarked) . '</div>';
                     if ($final_grade->locked or $final_grade->overridden) {
                         $grade = '<div id="g' . $auser->id . '" class="' . $locked_overridden . '">' . $final_grade->formatted_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $select = html_select::make(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'));
                             $select->nothingvalue = '-1';
                             $select->tabindex = $tabindex++;
                             $menu = $OUTPUT->select($select);
                             $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                         } else {
                             $grade = '<div id="g' . $auser->id . '">' . $this->display_grade($auser->grade) . '</div>';
                         }
                     }
                 } else {
                     $teachermodified = '<div id="tt' . $auser->id . '">&nbsp;</div>';
                     if ($final_grade->locked or $final_grade->overridden) {
                         $grade = '<div id="g' . $auser->id . '" class="' . $locked_overridden . '">' . $final_grade->formatted_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $select = html_select::make(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'));
                             $select->nothingvalue = '-1';
                             $select->tabindex = $tabindex++;
                             $menu = $OUTPUT->select($select);
                             $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                         } else {
                             $grade = '<div id="g' . $auser->id . '">' . $this->display_grade($auser->grade) . '</div>';
                         }
                     }
                 }
                 ///Print Comment
                 if ($final_grade->locked or $final_grade->overridden) {
                     $comment = '<div id="com' . $auser->id . '">' . shorten_text(strip_tags($final_grade->str_feedback), 15) . '</div>';
                 } else {
                     if ($quickgrade) {
                         $comment = '<div id="com' . $auser->id . '">' . '<textarea tabindex="' . $tabindex++ . '" name="submissioncomment[' . $auser->id . ']" id="submissioncomment' . $auser->id . '" rows="2" cols="20">' . $auser->submissioncomment . '</textarea></div>';
                     } else {
                         $comment = '<div id="com' . $auser->id . '">' . shorten_text(strip_tags($auser->submissioncomment), 15) . '</div>';
                     }
                 }
             } else {
                 $studentmodified = '<div id="ts' . $auser->id . '">&nbsp;</div>';
                 $teachermodified = '<div id="tt' . $auser->id . '">&nbsp;</div>';
                 $status = '<div id="st' . $auser->id . '">&nbsp;</div>';
                 if ($final_grade->locked or $final_grade->overridden) {
                     $grade = '<div id="g' . $auser->id . '">' . $final_grade->formatted_grade . '</div>';
                 } else {
                     if ($quickgrade) {
                         // allow editing
                         $select = html_select::make(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'));
                         $select->nothingvalue = '-1';
                         $select->tabindex = $tabindex++;
                         $menu = $OUTPUT->select($select);
                         $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                     } else {
                         $grade = '<div id="g' . $auser->id . '">-</div>';
                     }
                 }
                 if ($final_grade->locked or $final_grade->overridden) {
                     $comment = '<div id="com' . $auser->id . '">' . $final_grade->str_feedback . '</div>';
                 } else {
                     if ($quickgrade) {
                         $comment = '<div id="com' . $auser->id . '">' . '<textarea tabindex="' . $tabindex++ . '" name="submissioncomment[' . $auser->id . ']" id="submissioncomment' . $auser->id . '" rows="2" cols="20">' . $auser->submissioncomment . '</textarea></div>';
                     } else {
                         $comment = '<div id="com' . $auser->id . '">&nbsp;</div>';
                     }
                 }
             }
             if (empty($auser->status)) {
                 /// Confirm we have exclusively 0 or 1
                 $auser->status = 0;
             } else {
                 $auser->status = 1;
             }
             $buttontext = $auser->status == 1 ? $strupdate : $strgrade;
             ///No more buttons, we use popups ;-).
             $popup_url = '/mod/assignment/submissions.php?id=' . $this->cm->id . '&userid=' . $auser->id . '&mode=single' . '&offset=' . $offset++;
             $link = html_link::make($popup_url, $buttontext);
             $link->add_action(new popup_action('click', $link->url, 'grade' . $auser->id, array('height' => 600, 'width' => 700)));
             $link->title = $buttontext;
             $button = $OUTPUT->link($link);
             $status = '<div id="up' . $auser->id . '" class="s' . $auser->status . '">' . $button . '</div>';
             $finalgrade = '<span id="finalgrade_' . $auser->id . '">' . $final_grade->str_grade . '</span>';
             $outcomes = '';
             if ($uses_outcomes) {
                 foreach ($grading_info->outcomes as $n => $outcome) {
                     $outcomes .= '<div class="outcome"><label>' . $outcome->name . '</label>';
                     $options = make_grades_menu(-$outcome->scaleid);
                     if ($outcome->grades[$auser->id]->locked or !$quickgrade) {
                         $options[0] = get_string('nooutcome', 'grades');
                         $outcomes .= ': <span id="outcome_' . $n . '_' . $auser->id . '">' . $options[$outcome->grades[$auser->id]->grade] . '</span>';
                     } else {
                         $outcomes .= ' ';
                         $select = html_select::make($options, 'outcome_' . $n . '[' . $auser->id . ']', $outcome->grades[$auser->id]->grade, get_string('nooutcome', 'grades'));
                         $select->nothingvalue = '0';
                         $select->tabindex = $tabindex++;
                         $select->id = 'outcome_' . $n . '_' . $auser->id;
                         $outcomes .= $OUTPUT->select($select);
                     }
                     $outcomes .= '</div>';
                 }
             }
             $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&amp;course=' . $course->id . '">' . fullname($auser) . '</a>';
             $row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade);
             if ($uses_outcomes) {
                 $row[] = $outcomes;
             }
             $table->add_data($row);
         }
     }
     /// Print quickgrade form around the table
     if ($quickgrade) {
         echo '<form action="submissions.php" id="fastg" method="post">';
         echo '<div>';
         echo '<input type="hidden" name="id" value="' . $this->cm->id . '" />';
         echo '<input type="hidden" name="mode" value="fastgrade" />';
         echo '<input type="hidden" name="page" value="' . $page . '" />';
         echo '</div>';
     }
     $table->print_html();
     /// Print the whole table
     if ($quickgrade) {
         $lastmailinfo = get_user_preferences('assignment_mailinfo', 1) ? 'checked="checked"' : '';
         echo '<div class="fgcontrols">';
         echo '<div class="emailnotification">';
         echo '<label for="mailinfo">' . get_string('enableemailnotification', 'assignment') . '</label>';
         echo '<input type="hidden" name="mailinfo" value="0" />';
         echo '<input type="checkbox" id="mailinfo" name="mailinfo" value="1" ' . $lastmailinfo . ' />';
         echo $OUTPUT->help_icon(moodle_help_icon::make('emailnotification', get_string('enableemailnotification', 'assignment'), 'assignment')) . '</p></div>';
         echo '</div>';
         echo '<div class="fastgbutton"><input type="submit" name="fastg" value="' . get_string('saveallfeedback', 'assignment') . '" /></div>';
         echo '</div>';
         echo '</form>';
     }
     /// End of fast grading form
     /// Mini form for setting user preference
     echo '<div class="qgprefs">';
     echo '<form id="options" action="submissions.php?id=' . $this->cm->id . '" method="post"><div>';
     echo '<input type="hidden" name="updatepref" value="1" />';
     echo '<table id="optiontable">';
     echo '<tr><td>';
     echo '<label for="perpage">' . get_string('pagesize', 'assignment') . '</label>';
     echo '</td>';
     echo '<td>';
     echo '<input type="text" id="perpage" name="perpage" size="1" value="' . $perpage . '" />';
     echo $OUTPUT->help_icon(moodle_help_icon::make('pagesize', get_string('pagesize', 'assignment'), 'assignment'));
     echo '</td></tr>';
     echo '<tr><td>';
     echo '<label for="quickgrade">' . get_string('quickgrade', 'assignment') . '</label>';
     echo '</td>';
     echo '<td>';
     $checked = $quickgrade ? 'checked="checked"' : '';
     echo '<input type="checkbox" id="quickgrade" name="quickgrade" value="1" ' . $checked . ' />';
     echo $OUTPUT->help_icon(moodle_help_icon::make('quickgrade', get_string('quickgrade', 'assignment'), 'assignment')) . '</p></div>';
     echo '</td></tr>';
     echo '<tr><td colspan="2">';
     echo '<input type="submit" value="' . get_string('savepreferences') . '" />';
     echo '</td></tr></table>';
     echo '</div></form></div>';
     ///End of mini form
     echo $OUTPUT->footer();
 }
Beispiel #30
0
 /**
  * Add a single button.
  *
  * @param string $elementname name of the element to add the item to
  * @param array $button arguments to pass to function $function
  * @param boolean $suppresscheck whether to throw an error if the element
  *                                  doesn't exist.
  * @param string $function - function to generate html from the arguments in $button
  * @param string $function
  */
 function setHelpButton($elementname, $button, $suppresscheck = false, $function = 'helpbutton')
 {
     global $OUTPUT;
     if (array_key_exists($elementname, $this->_elementIndex)) {
         //_elements has a numeric index, this code accesses the elements by name
         $element =& $this->_elements[$this->_elementIndex[$elementname]];
         $buttonparams = array('page', 'text', 'module', 'image', 'linktext', 'text', 'return', 'imagetext');
         $helpiconoptions = array('page' => null, 'text' => null, 'module' => 'moodle', 'image' => null, 'linktext' => false);
         foreach ($button as $key => $val) {
             if (isset($button[$key])) {
                 $helpiconoptions[$buttonparams[$key]] = $val;
             }
         }
         $helpicon = moodle_help_icon::make($helpiconoptions['page'], $helpiconoptions['text'], $helpiconoptions['module'], $helpiconoptions['linktext']);
         if (!$helpiconoptions['image']) {
             $helpicon->image = false;
         }
         $element->_helpbutton = $OUTPUT->help_icon($helpicon);
     } elseif (!$suppresscheck) {
         print_error('nonexistentformelements', 'form', '', $elementname);
     }
 }