function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode = '', $hook = '', $printicons = 1, $ratings = NULL, $aliases = true)
{
    global $CFG, $USER, $DB, $OUTPUT;
    $user = $DB->get_record('user', array('id' => $entry->userid));
    $strby = get_string('writtenby', 'glossary');
    $return = false;
    if ($entry) {
        echo '<table class="glossarypost encyclopedia" cellspacing="0">';
        echo '<tr valign="top">';
        echo '<td class="left picture">';
        echo $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id));
        echo '</td>';
        echo '<th class="entryheader">';
        echo '<div class="concept">';
        glossary_print_entry_concept($entry);
        echo '</div>';
        $fullname = fullname($user);
        $by = new object();
        $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $course->id . '">' . $fullname . '</a>';
        $by->date = userdate($entry->timemodified);
        echo '<span class="author">' . get_string('bynameondate', 'forum', $by) . '</span>';
        echo '</th>';
        echo '<td class="entryapproval">';
        glossary_print_entry_approval($cm, $entry, $mode);
        echo '</td>';
        echo '</tr>';
        echo '<tr valign="top">';
        echo '<td class="left side" rowspan="2">&nbsp;</td>';
        echo '<td colspan="2" class="entry">';
        if ($entry->attachment) {
            $entry->course = $course->id;
            if (strlen($entry->definition) % 2) {
                $align = 'right';
            } else {
                $align = 'left';
            }
            glossary_print_entry_attachment($entry, $cm, null, $align, false);
        }
        glossary_print_entry_definition($entry, $glossary, $cm);
        if ($printicons or $ratings or $aliases) {
            echo '</td></tr>';
            echo '<tr>';
            echo '<td colspan="2" class="entrylowersection">';
            $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
            echo ' ';
        }
        echo '</td></tr>';
        echo "</table>\n";
    } else {
        echo '<div style="text-align:center">';
        print_string('noentry', 'glossary');
        echo '</div>';
    }
    return $return;
}
 function col_picture($attempt)
 {
     global $COURSE, $OUTPUT;
     $user = new object();
     $user->id = $attempt->userid;
     $user->lastname = $attempt->lastname;
     $user->firstname = $attempt->firstname;
     $user->imagealt = $attempt->imagealt;
     $user->picture = $attempt->picture;
     return $OUTPUT->user_picture(moodle_user_picture::make($user, $COURSE->id));
 }
Exemple #3
0
function format_user_list($data, $course)
{
    global $CFG, $DB, $COURSE, $OUTPUT;
    $users = array();
    foreach ($data as $v) {
        $user['name'] = fullname($v);
        $user['url'] = $CFG->wwwroot . '/user/view.php?id=' . $v->id . '&amp;course=' . $course->id;
        $user['picture'] = $OUTPUT->user_picture(moodle_user_picture::make($v, $COURSE->id));
        $user['id'] = $v->id;
        $users[] = $user;
    }
    return $users;
}
 function definition_after_data()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     $mform =& $this->_form;
     if ($userid = $mform->getElementValue('id')) {
         $user = $DB->get_record('user', array('id' => $userid));
     } else {
         $user = false;
     }
     // if language does not exist, use site default lang
     if ($langsel = $mform->getElementValue('lang')) {
         $lang = reset($langsel);
         // missing _utf8 in language, add it before further processing. MDL-11829 MDL-16845
         if (strpos($lang, '_utf8') === false) {
             $lang = $lang . '_utf8';
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($lang);
         }
         // check lang exists
         if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($CFG->lang);
         }
     }
     // user can not change own auth method
     if ($userid == $USER->id) {
         $mform->hardFreeze('auth');
         $mform->hardFreeze('preference_auth_forcepasswordchange');
     }
     // admin must choose some password and supply correct email
     if (!empty($USER->newadminuser)) {
         $mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
     }
     // require password for new users
     if ($userid == -1) {
         $mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
     }
     // print picture
     if (!empty($CFG->gdversion)) {
         $image_el =& $mform->getElement('currentpicture');
         if ($user and $user->picture) {
             $userpic = moodle_user_picture::make($user, SITEID);
             $userpic->alttext = true;
             $image_el->setValue($OUTPUT->user_picture($userpic));
         } else {
             $image_el->setValue(get_string('none'));
         }
     }
     /// Next the customisable profile fields
     profile_definition_after_data($mform, $userid);
 }
 function get_content()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     if (!$CFG->messaging) {
         return '';
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance) or empty($USER->id) or isguest() or empty($CFG->messaging)) {
         return $this->content;
     }
     $this->content->footer = '<a href="' . $CFG->wwwroot . '/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">' . get_string('messages', 'message') . '</a>...';
     $users = $DB->get_records_sql("SELECT m.useridfrom AS id, COUNT(m.useridfrom) AS count,\n                                              u.firstname, u.lastname, u.picture, u.imagealt, u.lastaccess\n                                         FROM {user} u, {message} m \n                                        WHERE m.useridto = ? AND u.id = m.useridfrom\n                                     GROUP BY m.useridfrom, u.firstname,u.lastname,u.picture,u.lastaccess,u.imagealt", array($USER->id));
     //Now, we have in users, the list of users to show
     //Because they are online
     if (!empty($users)) {
         $this->content->text .= '<ul class="list">';
         foreach ($users as $user) {
             $timeago = format_time(time() - $user->lastaccess);
             $this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . SITEID . '" title="' . $timeago . '">';
             $this->content->text .= $OUTPUT->user_picture(moodle_user_picture::make($user, SITEID));
             $this->content->text .= fullname($user) . '</a></div>';
             $this->content->text .= '<div class="message"><a href="' . $CFG->wwwroot . '/message/discussion.php?id=' . $user->id . '" onclick="this.target=\'message_' . $user->id . '\'; return openpopup(\'/message/discussion.php?id=' . $user->id . '\', \'message_' . $user->id . '\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="' . $OUTPUT->old_icon_url('t/message') . '" alt="" />&nbsp;' . $user->count . '</a>';
             $this->content->text .= '</div></li>';
         }
         $this->content->text .= '</ul>';
     } else {
         $this->content->text .= '<div class="info">';
         $this->content->text .= get_string('nomessages', 'message');
         $this->content->text .= '</div>';
     }
     return $this->content;
 }
Exemple #6
0
    function get_user_window($sessionid)
    {
        global $CFG, $PAGE;
        static $str;
        $info =& $this->sets_info[$sessionid];
        $PAGE->set_course($info['course']);
        $timenow = time();
        if (empty($str)) {
            $str->idle = get_string("idle", "chat");
            $str->beep = get_string("beep", "chat");
            $str->day = get_string("day");
            $str->days = get_string("days");
            $str->hour = get_string("hour");
            $str->hours = get_string("hours");
            $str->min = get_string("min");
            $str->mins = get_string("mins");
            $str->sec = get_string("sec");
            $str->secs = get_string("secs");
            $str->years = get_string('years');
        }
        ob_start();
        $refresh_inval = $CFG->chat_refresh_userlist * 1000;
        echo <<<EOD
        <html><head>
        <meta http-equiv="refresh" content="{$refresh_inval}">
        <style type="text/css"> img{border:0} </style>
        <script type="text/javascript">
        //<![CDATA[
        function openpopup(url,name,options,fullscreen) {
            fullurl = "{$CFG->wwwroot}" + url;
            windowobj = window.open(fullurl,name,options);
            if (fullscreen) {
                windowobj.moveTo(0,0);
                windowobj.resizeTo(screen.availWidth,screen.availHeight);
            }
            windowobj.focus();
            return false;
        }
        //]]>
        </script></head><body><table><tbody>
EOD;
        // Get the users from that chatroom
        $users = $this->chatrooms[$info['chatid']]['users'];
        foreach ($users as $usersessionid => $userid) {
            // Fetch each user's sessionid and then the rest of his data from $this->sets_info
            $userinfo = $this->sets_info[$usersessionid];
            $lastping = $timenow - $userinfo['chatuser']->lastmessageping;
            $popuppar = '\'/user/view.php?id=' . $userinfo['user']->id . '&amp;course=' . $userinfo['courseid'] . '\',\'user' . $userinfo['chatuser']->id . '\',\'\'';
            echo '<tr><td width="35">';
            echo '<a target="_new" onclick="return openpopup(' . $popuppar . ');" href="' . $CFG->wwwroot . '/user/view.php?id=' . $userinfo['chatuser']->id . '&amp;course=' . $userinfo['courseid'] . '">';
            echo $OUTPUT->user_picture(moodle_user_picture::make($userinfo['user'], 0));
            echo "</a></td><td valign=\"center\">";
            echo "<p><font size=\"1\">";
            echo fullname($userinfo['user']) . "<br />";
            echo "<font color=\"#888888\">{$str->idle}: " . format_time($lastping, $str) . "</font> ";
            echo '<a target="empty" href="http://' . $CFG->chat_serverhost . ':' . $CFG->chat_serverport . '/?win=beep&amp;beep=' . $userinfo['user']->id . '&chat_sid=' . $sessionid . '">' . $str->beep . "</a>\n";
            echo "</font></p>";
            echo "<td></tr>";
        }
        echo '</tbody></table>';
        // About 2K of HTML comments to force browsers to render the HTML
        // echo $GLOBALS['CHAT_DUMMY_DATA'];
        echo "</body>\n</html>\n";
        return ob_get_clean();
    }
Exemple #7
0
/// Print user panel body
$timenow = time();
$stridle = get_string('idle', 'chat');
$strbeep = get_string('beep', 'chat');
echo '<div style="display: none"><a href="' . $refreshurl . '" id="refreshLink">Refresh link</a></div>';
echo '<table width="100%">';
foreach ($chatusers as $chatuser) {
    $lastping = $timenow - $chatuser->lastmessageping;
    $min = (int) ($lastping / 60);
    $sec = $lastping - $min * 60;
    $min = $min < 10 ? '0' . $min : $min;
    $sec = $sec < 10 ? '0' . $sec : $sec;
    $idle = $min . ':' . $sec;
    echo '<tr><td width="35">';
    echo "<a target=\"_blank\" onClick=\"return openpopup('/user/view.php?id={$chatuser->id}&amp;course={$courseid}','user{$chatuser->id}','');\" href=\"{$CFG->wwwroot}/user/view.php?id={$chatuser->id}&amp;course={$courseid}\">";
    echo $OUTPUT->user_picture(moodle_user_picture::make($chatuser, 0));
    echo '</a></td><td valign="center">';
    echo '<p><font size="1">';
    echo fullname($chatuser) . '<br />';
    echo "<span class=\"dimmed_text\">{$stridle} <span name=\"uidles\" id=\"uidle{$chatuser->id}\">{$idle}</span></span>";
    echo " <a href=\"users.php?chat_sid={$chat_sid}&amp;beep={$chatuser->id}\">{$strbeep}</a>";
    echo '</font></p>';
    echo '</td></tr>';
}
// added 2 </div>s, xhtml strict complaints
echo '</table>';
echo $OUTPUT->footer();
//
// Support HTTP Keep-Alive by printing Content-Length
//
// If the user pane is refreshing often, using keepalives
function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode = '', $hook = '', $printicons = 1, $ratings = NULL, $aliases = true)
{
    global $CFG, $USER, $DB, $OUTPUT;
    $user = $DB->get_record('user', array('id' => $entry->userid));
    $strby = get_string('writtenby', 'glossary');
    if ($entry) {
        echo '<table class="glossarypost TEMPLATE">';
        echo '<tr>';
        echo '<td class="entryheader">';
        //Use this function to show author's image
        //Comments: Configuration not supported
        echo $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id));
        //Line separator to show this template fine. :-)
        echo '<br />';
        //Use this code to show author's name
        //Comments: Configuration not supported
        $fullname = fullname($user);
        $by = new object();
        $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $course->id . '">' . $fullname . '</a>';
        $by->date = userdate($entry->timemodified);
        echo '<span class="author">' . get_string('bynameondate', 'forum', $by) . '</span>' . '<br />';
        //Use this code to show modification date
        //Comments: Configuration not supported
        echo get_string('lastedited') . ': ' . userdate($entry->timemodified) . '<br /></span>';
        //Use this function to show the approval button. It'll be shown if necessary
        //Comments: You can configure this parameters:
        //----Define where to show the approval button
        $approvalalign = 'right';
        //Values: left, center and right (default right)
        //----Define if the approval button must be showed into a 100% width table
        $approvalinsidetable = true;
        //Values: true, false (default true)
        //Call the function
        glossary_print_entry_approval($cm, $entry, $mode, $approvalalign, $approvalinsidetable);
        //Line separator to show this template fine. :-)
        echo '<br />';
        echo '</td>';
        echo '<td class="entryattachment">';
        //Use this function to show the attachment. It'll be showed if necessary
        //Comments: You can configure this parameters:
        //----Define how to show the attachment
        $attachmentformat = 'html';
        //Values: html (link) and NULL (inline image if possible) (default NULL)
        //----Define where to show the attachment
        $attachmentalign = 'right';
        //Values: left, center and right (default right)
        //----Define if the attachment must be showed into a 100% width table
        $attachmentinsidetable = true;
        //Values: true, false (default true)
        //Call the function
        glossary_print_entry_attachment($entry, $cm, $attachmentformat, $attachmentalign, $attachmentinsidetable);
        //Line separator to show this template fine. :-)
        echo "<br />\n";
        echo '</td></tr>';
        echo '<tr valign="top">';
        echo '<td class="entry">';
        //Use this function to print the concept in a heading <h3>
        //Comments: Configuration not supported
        glossary_print_entry_concept($entry);
        //Line separator not normally needed now.
        //echo "<br />\n";
        //Use this function to show the definition
        //Comments: Configuration not supported
        glossary_print_entry_definition($entry, $glossary, $cm);
        //Line separator to show this template fine. :-)
        echo "<br />\n";
        //Use this function to show aliases, editing icons and ratings (all know as the 'lower section')
        //Comments: You can configure this parameters:
        //----Define when to show the aliases popup
        //    use it only if you are really sure!
        //$aliases = true; //Values: true, false (Default: true)
        //----Uncoment this line to avoid ratings being showed
        //    use it only if you are really sure! You can define this in the glossary conf. page.
        //$ratings = NULL;
        //----Uncoment this line to avoid editing icons being showed
        //    use it only if you are really sure!
        //$printicons = false;
        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
        echo '</td>';
        echo '</tr>';
        echo "</table>\n";
    } else {
        echo '<div style="text-align:center">';
        print_string('noentry', 'glossary');
        echo '</div>';
    }
    return $return;
}
Exemple #9
0
 /**
  * Prints a table with users and their attempts
  *
  * @return void
  * @todo Add current grade to the table
  *       Finnish documenting
  **/
 function view_question($quiz, $question, $totalattempts, $ungraded)
 {
     global $CFG, $DB, $OUTPUT;
     $usercount = count($this->users);
     // set up table
     $tablecolumns = array('picture', 'fullname', 'timefinish', 'grade');
     $tableheaders = array('', get_string('name'), get_string("completedon", "quiz"), '');
     $table = new flexible_table('mod-quiz-report-grading');
     $table->define_columns($tablecolumns);
     $table->define_headers($tableheaders);
     $table->define_baseurl($this->viewurl->out());
     $table->sortable(true);
     $table->initialbars($usercount > 20);
     // will show initialbars if there are more than 20 users
     $table->pageable(true);
     $table->collapsible(true);
     $table->column_suppress('fullname');
     $table->column_suppress('picture');
     $table->column_suppress('grade');
     $table->column_class('picture', 'picture');
     // attributes in the table tag
     $table->set_attribute('cellspacing', '0');
     $table->set_attribute('id', 'attempts');
     $table->set_attribute('class', 'generaltable generalbox');
     $table->set_attribute('align', 'center');
     //$table->set_attribute('width', '50%');
     // get it ready!
     $table->setup();
     list($select, $from, $where, $params) = $this->attempts_sql($quiz->id, true, $question->id);
     if ($table->get_sql_where()) {
         // forgot what this does
         $where .= 'AND ' . $table->get_sql_where();
     }
     // sorting of the table
     if ($sort = $table->get_sql_sort()) {
         $sort = 'ORDER BY ' . $sort;
         // seems like I would need to have u. or qa. infront of the ORDER BY attribues... but seems to work..
     } else {
         // my default sort rule
         $sort = 'ORDER BY u.firstname, u.lastname, qa.timefinish ASC';
     }
     // set up the pagesize
     $table->pagesize(QUIZ_REPORT_DEFAULT_PAGE_SIZE, $totalattempts);
     // get the attempts and process them
     if ($attempts = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size())) {
         echo '<div id="tablecontainer">';
         // grade all link
         $links = "<strong><a href=\"report.php?mode=grading&amp;gradeall=1&amp;q={$quiz->id}&amp;questionid={$question->id}\">" . get_string('gradeall', 'quiz_grading', $totalattempts) . '</a></strong>';
         if ($ungraded > 0) {
             $links .= "<br /><strong><a href=\"report.php?mode=grading&amp;gradeungraded=1&amp;q={$quiz->id}&amp;questionid={$question->id}\">" . get_string('gradeungraded', 'quiz_grading', $ungraded) . '</a></strong>';
             if ($ungraded > QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE) {
                 $links .= "<br /><strong><a href=\"report.php?mode=grading&amp;gradenextungraded=1&amp;q={$quiz->id}&amp;questionid={$question->id}\">" . get_string('gradenextungraded', 'quiz_grading', QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE) . '</a></strong>';
             }
         }
         $table->add_data_keyed(array('grade' => $links));
         $table->add_separator();
         foreach ($attempts as $attempt) {
             $picture = $OUTPUT->user_picture(moodle_user_picture::make($attempt->userid, $quiz->course));
             // link to student profile
             $userlink = "<a href=\"{$CFG->wwwroot}/user/view.php?id={$attempt->userid}&amp;course={$quiz->course}\">" . fullname($attempt, true) . '</a>';
             $gradedclass = question_state_is_graded($attempt) ? ' class="highlightgraded" ' : '';
             $gradedstring = question_state_is_graded($attempt) ? ' ' . get_string('graded', 'quiz_grading') : '';
             // link for the attempt
             $attemptlink = "<a {$gradedclass}href=\"report.php?mode=grading&amp;q={$quiz->id}&amp;questionid={$question->id}&amp;attemptid={$attempt->attemptid}\">" . userdate($attempt->timefinish, get_string('strftimedatetime')) . $gradedstring . '</a>';
             // grade all attempts for this user
             $gradelink = "<a href=\"report.php?mode=grading&amp;q={$quiz->id}&amp;questionid={$question->id}&amp;userid={$attempt->userid}\">" . get_string('grade') . '</a>';
             $table->add_data(array($picture, $userlink, $attemptlink, $gradelink));
         }
         $table->add_separator();
         $table->add_data_keyed(array('grade' => $links));
         // print everything here
         $table->print_html();
         echo '</div>';
     } else {
         echo $OUTPUT->notification(get_string('noattemptstoshow', 'quiz'));
     }
 }
Exemple #10
0
                    }
                    echo $OUTPUT->table($table);
                }
            }
        } else {
            notice('No users to report');
        }
    }
} else {
    // User SCO report
    if (!empty($userdata)) {
        echo $OUTPUT->box_start('generalbox boxaligncenter');
        //print_heading(format_string($sco->title));
        echo $OUTPUT->heading('<a href="' . $CFG->wwwroot . '/mod/scorm/player.php?a=' . $scorm->id . '&amp;mode=browse&amp;scoid=' . $sco->id . '" target="_new">' . format_string($sco->title) . '</a>');
        echo '<div class="mdl-align">' . "\n";
        $userpic = moodle_user_picture::make($user, $course->id);
        $userpic->image->src = $userdata->picture;
        echo $OUTPUT->user_picture($userpic);
        echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$user}&amp;course={$course->id}\">" . "{$userdata->firstname} {$userdata->lastname}</a><br />";
        $scoreview = '';
        if ($trackdata = scorm_get_tracks($sco->id, $user, $attempt)) {
            if ($trackdata->score_raw != '') {
                $scoreview = get_string('score', 'scorm') . ':&nbsp;' . $trackdata->score_raw;
            }
            if ($trackdata->status == '') {
                $trackdata->status = 'notattempted';
            }
        } else {
            $trackdata->status = 'notattempted';
            $trackdata->total_time = '';
        }
Exemple #11
0
/**
 * Prints a note object
 *
 * @param note  $note the note object to print
 * @param int   $detail OR-ed NOTES_SHOW_xyz flags that specify which note parts to print
 */
function note_print($note, $detail = NOTES_SHOW_FULL)
{
    global $CFG, $USER, $DB, $OUTPUT;
    if (!($user = $DB->get_record('user', array('id' => $note->userid)))) {
        debugging("User {$note->userid} not found");
        return;
    }
    if (!($author = $DB->get_record('user', array('id' => $note->usermodified)))) {
        debugging("User {$note->usermodified} not found");
        return;
    }
    $context = get_context_instance(CONTEXT_COURSE, $note->courseid);
    $systemcontext = get_context_instance(CONTEXT_SYSTEM);
    $authoring = new object();
    $authoring->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $author->id . '&amp;course=' . $note->courseid . '">' . fullname($author) . '</a>';
    $authoring->date = userdate($note->lastmodified);
    echo '<div class="notepost ' . $note->publishstate . 'notepost' . ($note->usermodified == $USER->id ? ' ownnotepost' : '') . '" id="note-' . $note->id . '">';
    // print note head (e.g. author, user refering to, etc)
    if ($detail & NOTES_SHOW_HEAD) {
        echo '<div class="header">';
        echo '<div class="user">';
        echo $OUTPUT->user_picture(moodle_user_picture::make($user, $note->courseid));
        echo fullname($user) . '</div>';
        echo '<div class="info">' . get_string('bynameondate', 'notes', $authoring) . ' (' . get_string('created', 'notes') . ': ' . userdate($note->created) . ')</div>';
        echo '</div>';
    }
    // print note content
    if ($detail & NOTES_SHOW_BODY) {
        echo '<div class="content">';
        echo format_text($note->content, $note->format);
        echo '</div>';
    }
    // print note options (e.g. delete, edit)
    if ($detail & NOTES_SHOW_FOOT) {
        if (has_capability('moodle/notes:manage', $systemcontext) && $note->publishstate == NOTES_STATE_SITE || has_capability('moodle/notes:manage', $context) && ($note->publishstate == NOTES_STATE_PUBLIC || $note->usermodified == $USER->id)) {
            echo '<div class="footer"><p>';
            echo '<a href="' . $CFG->wwwroot . '/notes/edit.php?id=' . $note->id . '">' . get_string('edit') . '</a> | ';
            echo '<a href="' . $CFG->wwwroot . '/notes/delete.php?id=' . $note->id . '">' . get_string('delete') . '</a>';
            echo '</p></div>';
        }
    }
    echo '</div>';
}
Exemple #12
0
    unset($USER->subscriptionsediting);
}
/// Check to see if groups are being used in this forum
groups_print_activity_menu($cm, "subscribers.php?id={$forum->id}");
$currentgroup = groups_get_activity_group($cm);
$groupmode = groups_get_activity_groupmode($cm);
if (empty($USER->subscriptionsediting)) {
    /// Display an overview of subscribers
    if (!($users = forum_subscribed_users($course, $forum, $currentgroup, $context))) {
        echo $OUTPUT->heading(get_string("nosubscribers", "forum"));
    } else {
        echo $OUTPUT->heading(get_string("subscribersto", "forum", "'" . format_string($forum->name) . "'"));
        echo '<table align="center" cellpadding="5" cellspacing="5">';
        foreach ($users as $user) {
            echo '<tr><td>';
            echo $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id));
            echo '</td><td>';
            echo fullname($user);
            echo '</td><td>';
            echo $user->email;
            echo '</td></tr>';
        }
        echo "</table>";
    }
    echo $OUTPUT->footer();
    exit;
}
/// We are in editing mode.
$strexistingsubscribers = get_string("existingsubscribers", 'forum');
$strpotentialsubscribers = get_string("potentialsubscribers", 'forum');
$straddsubscriber = get_string("addsubscriber", 'forum');
 function get_content()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     $timetoshowusers = 300;
     //Seconds default
     if (isset($CFG->block_online_users_timetosee)) {
         $timetoshowusers = $CFG->block_online_users_timetosee * 60;
     }
     $timefrom = 100 * floor((time() - $timetoshowusers) / 100);
     // Round to nearest 100 seconds for better query cache
     //Calculate if we are in separate groups
     $isseparategroups = $this->page->course->groupmode == SEPARATEGROUPS && $this->page->course->groupmodeforce && !has_capability('moodle/site:accessallgroups', $this->page->context);
     //Get the user current group
     $currentgroup = $isseparategroups ? groups_get_course_group($this->page->course) : NULL;
     $groupmembers = "";
     $groupselect = "";
     $rafrom = "";
     $rawhere = "";
     $params = array();
     //Add this to the SQL to show only group users
     if ($currentgroup !== NULL) {
         $groupmembers = ", {groups_members} gm";
         $groupselect = "AND u.id = gm.userid AND gm.groupid = :currentgroup";
         $params['currentgroup'] = $currentgroup;
     }
     if ($this->page->course->id == SITEID) {
         // Site-level
         $sql = "SELECT u.id, u.username, u.firstname, u.lastname, u.picture, MAX(u.lastaccess) AS lastaccess\n                      FROM {user} u {$groupmembers}\n                     WHERE u.lastaccess > {$timefrom}\n                           {$groupselect}\n                  GROUP BY u.id, u.username, u.firstname, u.lastname, u.picture\n                  ORDER BY lastaccess DESC ";
         $csql = "SELECT COUNT(u.id), u.id\n                      FROM {user} u {$groupmembers}\n                     WHERE u.lastaccess > {$timefrom}\n                           {$groupselect}\n                  GROUP BY u.id";
     } else {
         // Course-level
         if (!has_capability('moodle/role:viewhiddenassigns', $this->page->context)) {
             $pcontext = get_related_contexts_string($this->page->context);
             $rafrom = ", {role_assignments} ra";
             $rawhere = " AND ra.userid = u.id AND ra.contextid {$pcontext} AND ra.hidden = 0";
         }
         $sql = "SELECT u.id, u.username, u.firstname, u.lastname, u.picture, MAX(ul.timeaccess) AS lastaccess\n                      FROM {user_lastaccess} ul, {user} u {$groupmembers} {$rafrom}\n                     WHERE ul.timeaccess > {$timefrom}\n                           AND u.id = ul.userid\n                           AND ul.courseid = :courseid\n                           {$groupselect} {$rawhere}\n                  GROUP BY u.id, u.username, u.firstname, u.lastname, u.picture\n                  ORDER BY lastaccess DESC";
         $csql = "SELECT u.id\n                      FROM {user_lastaccess} ul, {user} u {$groupmembers} {$rafrom}\n                     WHERE ul.timeaccess > {$timefrom}\n                           AND u.id = ul.userid\n                           AND ul.courseid = :courseid\n                           {$groupselect} {$rawhere}\n                  GROUP BY u.id";
         $params['courseid'] = $this->page->course->id;
     }
     //Calculate minutes
     $minutes = floor($timetoshowusers / 60);
     // Verify if we can see the list of users, if not just print number of users
     if (!has_capability('block/online_users:viewlist', $this->page->context)) {
         if (!($usercount = $DB->count_records_sql($csql, $params))) {
             $usercount = get_string("none");
         }
         $this->content->text = "<div class=\"info\">" . get_string("periodnminutes", "block_online_users", $minutes) . ": {$usercount}</div>";
         return $this->content;
     }
     if ($users = $DB->get_records_sql($sql, $params, 0, 50)) {
         // We'll just take the most recent 50 maximum
         foreach ($users as $user) {
             $users[$user->id]->fullname = fullname($user);
         }
     } else {
         $users = array();
     }
     if (count($users) < 50) {
         $usercount = "";
     } else {
         $usercount = $DB->count_records_sql($csql, $params);
         $usercount = ": {$usercount}";
     }
     $this->content->text = "<div class=\"info\">(" . get_string("periodnminutes", "block_online_users", $minutes) . "{$usercount})</div>";
     //Now, we have in users, the list of users to show
     //Because they are online
     if (!empty($users)) {
         //Accessibility: Don't want 'Alt' text for the user picture; DO want it for the envelope/message link (existing lang string).
         //Accessibility: Converted <div> to <ul>, inherit existing classes & styles.
         $this->content->text .= "<ul class='list'>\n";
         if (!empty($USER->id) && has_capability('moodle/site:sendmessage', $this->page->context) && !empty($CFG->messaging) && !isguest()) {
             $canshowicon = true;
         } else {
             $canshowicon = false;
         }
         foreach ($users as $user) {
             $this->content->text .= '<li class="listentry">';
             $timeago = format_time(time() - $user->lastaccess);
             //bruno to calculate correctly on frontpage
             $userpic = moodle_user_picture::make($user, $this->page->course->id);
             $userpic->size = 16;
             if ($user->username == 'guest') {
                 $this->content->text .= '<div class="user">' . $OUTPUT->user_picture($userpic);
                 $this->content->text .= get_string('guestuser') . '</div>';
             } else {
                 $this->content->text .= '<div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $this->page->course->id . '" title="' . $timeago . '">';
                 $this->content->text .= '<div class="user">' . $OUTPUT->user_picture($userpic);
                 $this->content->text .= $user->fullname . '</a></div>';
             }
             if ($canshowicon and $USER->id != $user->id and $user->username != 'guest') {
                 // Only when logged in and messaging active etc
                 $this->content->text .= '<div class="message"><a title="' . get_string('messageselectadd') . '" href="' . $CFG->wwwroot . '/message/discussion.php?id=' . $user->id . '" onclick="this.target=\'message_' . $user->id . '\';return openpopup(\'/message/discussion.php?id=' . $user->id . '\', \'message_' . $user->id . '\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">' . '<img class="iconsmall" src="' . $OUTPUT->old_icon_url('t/message') . '" alt="' . get_string('messageselectadd') . '" /></a></div>';
             }
             $this->content->text .= "</li>\n";
         }
         $this->content->text .= '</ul><div class="clearer"><!-- --></div>';
     } else {
         $this->content->text .= "<div class=\"info\">" . get_string("none") . "</div>";
     }
     return $this->content;
 }
/// Work out the base URL of this page.
$baseurl = $CFG->wwwroot . '/mod/quiz/reviewquestion.php?attempt=' . $attemptobj->get_attemptid() . '&amp;question=' . $questionid;
/// Log this review.
add_to_log($attemptobj->get_courseid(), 'quiz', 'review', 'reviewquestion.php?attempt=' . $attemptobj->get_attemptid() . '&question=' . $questionid . ($stateid ? '&state=' . $stateid : ''), $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Print the page header
$headtags = $attemptobj->get_question_html_head_contributions($questionid);
print_header('', '', '', '', $headtags);
echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
// for overlib
/// Print infobox
$rows = array();
/// User picture and name.
if ($attemptobj->get_userid() != $USER->id) {
    // Print user picture and name
    $student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
    $picture = $OUTPUT->user_picture(moodle_user_picture::make($student, $attemptobj->get_courseid()));
    $rows[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $student->id . '&amp;course=' . $attemptobj->get_courseid() . '">' . fullname($student, true) . '</a></td></tr>';
}
/// Quiz name.
$rows[] = '<tr><th scope="row" class="cell">' . get_string('modulename', 'quiz') . '</th><td class="cell">' . format_string($attemptobj->get_quiz_name()) . '</td></tr>';
/// Question name.
$rows[] = '<tr><th scope="row" class="cell">' . get_string('question', 'quiz') . '</th><td class="cell">' . format_string($attemptobj->get_question($questionid)->name) . '</td></tr>';
/// Other attempts at the quiz.
if ($attemptobj->has_capability('mod/quiz:viewreports')) {
    $attemptlist = $attemptobj->links_to_other_attempts($baseurl);
    if ($attemptlist) {
        $rows[] = '<tr><th scope="row" class="cell">' . get_string('attempts', 'quiz') . '</th><td class="cell">' . $attemptlist . '</td></tr>';
    }
}
/// Timestamp of this action.
$timestamp = $attemptobj->get_question_state($questionid)->timestamp;
Exemple #15
0
 /**
  * Add a new comment
  * @param string $content
  * @return mixed
  */
 public function add($content)
 {
     global $CFG, $DB, $USER, $OUTPUT;
     if (empty($this->postcap)) {
         return COMMENT_ERROR_INSUFFICIENT_CAPS;
     }
     $now = time();
     $newcmt = new stdclass();
     $newcmt->contextid = $this->contextid;
     $newcmt->commentarea = $this->commentarea;
     $newcmt->itemid = $this->itemid;
     $newcmt->content = $content;
     $newcmt->format = FORMAT_MOODLE;
     $newcmt->userid = $USER->id;
     $newcmt->timecreated = $now;
     if (!empty($this->plugintype)) {
         // moodle module will check content
         $ret = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'add', array(&$newcmt, $this->options), true);
         if (!$ret) {
             return COMMENT_ERROR_MODULE_REJECT;
         }
     }
     $cmt_id = $DB->insert_record('comments', $newcmt);
     if (!empty($cmt_id)) {
         $newcmt->id = $cmt_id;
         $newcmt->time = userdate($now, get_string('strftimerecent', 'langconfig'));
         $newcmt->username = fullname($USER);
         $newcmt->content = format_text($newcmt->content);
         $userpic = moodle_user_picture::make($USER, $this->course->id);
         $userpic->size = 16;
         $newcmt->avatar = $OUTPUT->user_picture($userpic);
         return $newcmt;
     } else {
         return COMMENT_ERROR_DB;
     }
 }
Exemple #16
0
/**
 * Basically, this function prints the results of "hotpot_get_recent_activity"
 *
 * @global object
 * @global object
 * @global object
 * @param object $activity
 * @param object $course
 * @param bool $detail
 */
function hotpot_print_recent_mod_activity($activity, $course, $detail = false)
{
    global $CFG, $THEME, $USER, $OUTPUT;
    if (isset($THEME->cellcontent2)) {
        $bgcolor = ' bgcolor="' . $THEME->cellcontent2 . '"';
    } else {
        $bgcolor = '';
    }
    print '<table border="0" cellpadding="3" cellspacing="0">';
    print '<tr><td' . $bgcolor . ' class="forumpostpicture" width="35" valign="top">';
    echo $OUTPUT->user_picture(moodle_user_picture::make($activity->user, $course));
    print '</td><td width="100%"><font size="2">';
    if ($detail) {
        // activity icon
        $src = "" . $OUTPUT->mod_icon_url('icon', $activity->type) . "";
        print '<img src="' . $src . '" class="icon" alt="' . $activity->type . '" /> ';
        // link to activity
        $href = "{$CFG->wwwroot}/mod/hotpot/view.php?hp={$activity->instance}";
        print '<a href="' . $href . '">' . $activity->name . '</a> - ';
    }
    if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course))) {
        // score (with link to attempt details)
        $href = "{$CFG->wwwroot}/mod/hotpot/review.php?hp={$activity->instance}&attempt=" . $activity->content->attemptid;
        print '<a href="' . $href . '">(' . hotpot_format_score($activity->content) . ')</a> ';
        // attempt number
        print get_string('attempt', 'quiz') . ' - ' . $activity->content->attempt . '<br />';
    }
    // link to user
    $href = "{$CFG->wwwroot}/user/view.php?id={$activity->user}->userid&course={$course}";
    print '<a href="' . $href . '">' . $activity->user->fullname . '</a> ';
    // time and date
    print ' - ' . userdate($activity->timestamp);
    // duration
    $duration = format_time($activity->content->timestart - $activity->content->timefinish);
    print " &nbsp; ({$duration})";
    print "</font></td></tr>";
    print "</table>";
}
Exemple #17
0
if (!($ratings = glossary_get_ratings($entry->id, $sqlsort))) {
    print_error('ratingno', 'glossary');
} else {
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
    echo "<tr>";
    echo "<th class=\"header\" scope=\"col\">&nbsp;</th>";
    echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id={$entry->id}&amp;sort=firstname\">{$strname}</a></th>";
    echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id={$entry->id}&amp;sort=rating\">{$strrating}</a></th>";
    echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id={$entry->id}&amp;sort=time\">{$strtime}</a></th>";
    echo "</tr>";
    foreach ($ratings as $rating) {
        if (has_capability('mod/glossary:manageentries', $context)) {
            echo '<tr class="teacher">';
        } else {
            echo '<tr>';
        }
        echo '<td class="picture">';
        $userpic = moodle_user_picture::make($rating, $glossary->course);
        $userpic->link = true;
        echo $OUTPUT->user_picture($userpic);
        echo '</td>';
        echo '<td class="author"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $rating->id . '&amp;course=' . $glossary->course . '">' . fullname($rating) . '</a></td>';
        echo '<td style="white-space:nowrap" align="center" class="rating">' . $scalemenu[$rating->rating] . '</td>';
        echo '<td style="white-space:nowrap" align="center" class="time">' . userdate($rating->time) . '</td>';
        echo "</tr>\n";
    }
    echo "</table>";
    echo "<br />";
}
echo $OUTPUT->close_window_button();
echo $OUTPUT->footer();
Exemple #18
0
if ($chat->chattime and $chat->schedule) {
    // A chat is scheduled
    echo "<p class=\"nextchatsession\">{$strnextsession}: " . userdate($chat->chattime) . ' (' . usertimezone($USER->timezone) . ')</p>';
} else {
    echo '<br />';
}
if ($chat->intro) {
    echo $OUTPUT->box(format_module_intro('chat', $chat, $cm->id), 'generalbox', 'intro');
}
chat_delete_old_users();
if ($chatusers = chat_get_users($chat->id, $currentgroup, $cm->groupingid)) {
    $timenow = time();
    $OUTPUT->box_start('generalbox');
    echo $OUTPUT->heading($strcurrentusers);
    echo '<table id="chatcurrentusers">';
    foreach ($chatusers as $chatuser) {
        $lastping = $timenow - $chatuser->lastmessageping;
        echo '<tr><td class="chatuserimage">';
        echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$chatuser->id}&amp;course={$chat->course}\">";
        echo $OUTPUT->user_picture(moodle_user_picture::make($chatuser, $COURSE->id));
        echo '</a></td><td class="chatuserdetails">';
        echo '<p>';
        echo fullname($chatuser) . '<br />';
        echo "<span class=\"idletime\">{$stridle}: " . format_time($lastping) . "</span>";
        echo '</p>';
        echo '</td></tr>';
    }
    echo '</table>';
    $OUTPUT->box_end();
}
echo $OUTPUT->footer();
Exemple #19
0
 function get_studentnameshtml()
 {
     global $CFG, $USER;
     $studentshtml = '';
     $showuserimage = $this->get_pref('showuserimage');
     $showuseridnumber = $this->get_pref('showuseridnumber');
     $fixedstudents = $this->is_fixed_students();
     $strsortasc = $this->get_lang_string('sortasc', 'grades');
     $strsortdesc = $this->get_lang_string('sortdesc', 'grades');
     $strfirstname = $this->get_lang_string('firstname');
     $strlastname = $this->get_lang_string('lastname');
     if ($this->sortitemid === 'lastname') {
         if ($this->sortorder == 'ASC') {
             $lastarrow = print_arrow('up', $strsortasc, true);
         } else {
             $lastarrow = print_arrow('down', $strsortdesc, true);
         }
     } else {
         $lastarrow = '';
     }
     if ($this->sortitemid === 'firstname') {
         if ($this->sortorder == 'ASC') {
             $firstarrow = print_arrow('up', $strsortasc, true);
         } else {
             $firstarrow = print_arrow('down', $strsortdesc, true);
         }
     } else {
         $firstarrow = '';
     }
     if ($fixedstudents) {
         $studentshtml .= '<div class="left_scroller">
             <table id="fixed_column" class="fixed_grades_column">
                 <tbody class="leftbody">';
         $colspan = '';
         if ($showuseridnumber) {
             $colspan = 'colspan="2"';
         }
         $levels = count($this->gtree->levels) - 1;
         for ($i = 0; $i < $levels; $i++) {
             $studentshtml .= '
                     <tr class="heading name_row">
                         <td ' . $colspan . ' class="fixedcolumn cell c0 topleft"> </td>
                     </tr>
                     ';
         }
         $studentshtml .= '<tr class="heading"><th id="studentheader" class="header c0" scope="col"><a href="' . $this->baseurl . '&amp;sortitemid=firstname">' . $strfirstname . '</a> ' . $firstarrow . '/ <a href="' . $this->baseurl . '&amp;sortitemid=lastname">' . $strlastname . '</a>' . $lastarrow . '</th>';
         if ($showuseridnumber) {
             if ('idnumber' == $this->sortitemid) {
                 if ($this->sortorder == 'ASC') {
                     $idnumberarrow = print_arrow('up', $strsortasc, true);
                 } else {
                     $idnumberarrow = print_arrow('down', $strsortdesc, true);
                 }
             } else {
                 $idnumberarrow = '';
             }
             $studentshtml .= '<th class="header c0 useridnumber" scope="col"><a href="' . $this->baseurl . '&amp;sortitemid=idnumber">' . get_string('idnumber') . '</a> ' . $idnumberarrow . '</th>';
         }
         $studentshtml .= '</tr>';
         if ($USER->gradeediting[$this->courseid]) {
             $studentshtml .= '<tr class="controls"><th class="header c0 controls" scope="row" ' . $colspan . '>' . $this->get_lang_string('controls', 'grades') . '</th></tr>';
         }
         $row_classes = array(' even ', ' odd ');
         foreach ($this->users as $userid => $user) {
             $user_pic = null;
             if ($showuserimage) {
                 $user_pic = '<div class="userpic">' . $OUTPUT->user_picture(moodle_user_picture::make($user, $this->courseid)) . "</div>\n";
             }
             $studentshtml .= '<tr class="r' . $this->rowcount++ . $row_classes[$this->rowcount % 2] . '">' . '<th class="c0 user" scope="row" onclick="set_row(this.parentNode.rowIndex);">' . $user_pic . '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $this->course->id . '">' . fullname($user) . "</a></th>\n";
             if ($showuseridnumber) {
                 $studentshtml .= '<th class="header c0 useridnumber" onclick="set_row(this.parentNode.rowIndex);">' . $user->idnumber . "</th>\n";
             }
             $studentshtml .= "</tr>\n";
         }
         if ($this->get_pref('showranges')) {
             $studentshtml .= '<tr class="range r' . $this->rowcount++ . '">' . '<th class="header c0 range " ' . $colspan . ' scope="row">' . $this->get_lang_string('range', 'grades') . '</th></tr>';
         }
         // Averages heading
         $straverage_group = get_string('groupavg', 'grades');
         $straverage = get_string('overallaverage', 'grades');
         $showaverages = $this->get_pref('showaverages');
         $showaverages_group = $this->currentgroup && $showaverages;
         if ($showaverages_group) {
             $studentshtml .= '<tr class="groupavg r' . $this->rowcount++ . '"><th class="header c0" ' . $colspan . 'scope="row">' . $straverage_group . '</th></tr>';
         }
         if ($showaverages) {
             $studentshtml .= '<tr class="avg r' . $this->rowcount++ . '"><th class="header c0" ' . $colspan . 'scope="row">' . $straverage . '</th></tr>';
         }
         $studentshtml .= '</tbody>
             </table>
         </div>
         <div class="right_scroller">
             <table id="user-grades" class="">
                 <tbody class="righttest">';
     } else {
         $studentshtml .= '<table id="user-grades" class="gradestable flexible boxaligncenter generaltable">
                             <tbody>';
     }
     return $studentshtml;
 }
Exemple #20
0
/**
 * prints a single comment entry
 *
 * @global object
 * @global object
 * @global object
 * @uses CONTEXT_MODULE
 * @param object $data
 * @param string $comment
 * @param int $page
 * @return void Output is echo'd
 */
function data_print_comment($data, $comment, $page = 0)
{
    global $USER, $CFG, $DB, $OUTPUT;
    $cm = get_coursemodule_from_instance('data', $data->id);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    $stredit = get_string('edit');
    $strdelete = get_string('delete');
    $user = $DB->get_record('user', array('id' => $comment->userid));
    echo '<table cellspacing="0" align="center" width="50%" class="datacomment forumpost">';
    echo '<tr class="header"><td class="picture left">';
    echo $OUTPUT->user_picture(moodle_user_picture::make($user, $data->course));
    echo '</td>';
    echo '<td class="topic starter" align="left"><div class="author">';
    $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
    $by = new object();
    $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $data->course . '">' . $fullname . '</a>';
    $by->date = userdate($comment->modified);
    print_string('bynameondate', 'data', $by);
    echo '</div></td></tr>';
    echo '<tr><td class="left side">';
    if ($groups = groups_get_all_groups($data->course, $comment->userid, $cm->groupingid)) {
        print_group_picture($groups, $data->course, false, false, true);
    } else {
        echo '&nbsp;';
    }
    // Actual content
    echo '</td><td class="content" align="left">' . "\n";
    // Print whole message
    echo format_text($comment->content, $comment->format);
    // Commands
    echo '<div class="commands">';
    if (data_isowner($comment->recordid) or has_capability('mod/data:managecomments', $context)) {
        echo '<a href="' . $CFG->wwwroot . '/mod/data/comment.php?rid=' . $comment->recordid . '&amp;mode=edit&amp;commentid=' . $comment->id . '&amp;page=' . $page . '">' . $stredit . '</a>';
        echo '| <a href="' . $CFG->wwwroot . '/mod/data/comment.php?rid=' . $comment->recordid . '&amp;mode=delete&amp;commentid=' . $comment->id . '&amp;page=' . $page . '">' . $strdelete . '</a>';
    }
    echo '</div>';
    echo '</td></tr></table>' . "\n\n";
}
Exemple #21
0
/**
 * @param int $cmid
 * @param array $results
 * @param int $courseid
 */
function survey_print_all_responses($cmid, $results, $courseid)
{
    global $OUTPUT;
    $table = new html_table();
    $table->head = array("", get_string("name"), get_string("time"));
    $table->align = array("", "left", "left");
    $table->size = array(35, "", "");
    foreach ($results as $a) {
        $table->data[] = array($OUTPUT->user_picture(moodle_user_picture::make($a, $courseid)), $OUTPUT->link("report.php?action=student&student={$a->id}&id={$cmid}", fullname($a)), userdate($a->time));
    }
    echo $OUTPUT->table($table);
}
Exemple #22
0
function ewiki_entry_downloads($row, $show_section = 0, $fullinfo = false)
{
    global $ewiki_binary_icons, $ewiki_upload_sections, $DB, $OUTPUT;
    $meta =& $row["meta"];
    $id = $row["id"];
    $p_title = basename($meta["Content-Location"]);
    $p_time = userdate($row["created"]);
    $p_hits = $row["hits"] ? $row["hits"] : "0";
    $p_size = $meta["size"];
    $p_size = isset($p_size) ? ", " . ($p_size >= 4096 ? round($p_size / 1024) . "K" : $p_size . " bytes") : "";
    $p_ct1 = $meta["Content-Type"];
    $p_ct2 = $meta["X-Content-Type"];
    if ($p_ct1 == $p_ct2) {
        unset($p_ct2);
    }
    if ($p_ct1 && !$p_ct2) {
        $p_ct = "<tt>{$p_ct1}</tt>";
    } elseif (!$p_ct1 && $p_ct2) {
        $p_ct = "<tt>{$p_ct2}</tt>";
    } elseif ($p_ct1 && $p_ct2) {
        $p_ct = "<tt>{$p_ct1}</tt>, <tt>{$p_ct2}</tt>";
    } else {
        $p_ct = "<tt>application/octet-stream</tt>";
    }
    $p_section = $ewiki_upload_sections[$meta["section"]];
    $p_section = $p_section ? $p_section : $meta["section"];
    $p_comment = strlen($meta["comment"]) ? '<table border="1" cellpadding="2" cellspacing="0"><tr><td class="lighter">' . str_replace('</p>', '', str_replace('<p>', '', ewiki_format($meta["comment"]))) . '</td></tr></table>' : "<br />";
    $p_icon = "";
    /*foreach ($ewiki_binary_icons as $str => $i) {
         if (empty($str) || strstr($row["Content-Location"], $str) || strstr($p_ct, $str) || strstr($p_ct2, $str)) { 
            $p_icon = $i;
            $p_icon_t = $str;
         }
      }*/
    /// Moodle Icon Handling
    global $CFG;
    $p_icon = $OUTPUT->old_icon_url(file_extension_icon($id));
    $p_icon_t = '';
    $info->id = $id;
    $info->size = $p_size;
    $info->icon = $p_icon ? '<img src="' . $p_icon . '" alt="[' . $p_icon_t . ']" class="icon" /> ' : '';
    $info->time = $p_time;
    $info->hits = $p_hits;
    $info->section = $show_section ? ewiki_t('dwnl_section') . ": {$p_section}<br />" : '';
    $info->type = $p_ct;
    $info->url = ewiki_script_binary("", $row["id"]);
    $info->title = $p_title;
    $info->comment = format_text($p_comment);
    if ($fullinfo) {
        if ($user = $DB->get_record('user', array('id' => $row['userid']))) {
            if (!isset($course->id)) {
                $course->id = 1;
            }
            $userpic = moodle_user_picture::make($user->id, $course->id);
            $userpic->link = true;
            $picture = $OUTPUT->user_picture($userpic);
            $value = $picture . $OUTPUT->link("{$CFG->wwwroot}/user/view.php?id={$user->id}&course={$course->id}", fullname($user));
        }
        $o .= '<a href="' . $info->url . '">' . $info->icon . $info->title . '</a>' . $info->size . '<br />' . $info->comment . $info->section . " " . get_string("fileisoftype", "wiki") . ": " . $info->type . '<br />' . get_string("uploadedon", "wiki") . ": " . $info->time . ", " . ' by ' . $value . '<br />' . get_string("downloadtimes", "wiki", $info->hits) . "<br />" . '<br /><br />';
    } else {
        //       global $moodle_format;   // from wiki/view.php
        $o .= '<a href="' . $info->url . '">' . $info->icon . $info->title . '</a>' . $info->size . '<br />' . $info->comment . '<br /><br />';
        //        $o = format_text($o, $moodle_format);
    }
    ewiki_t("DWNL_ENTRY_FORMAT", $info);
    return $o;
}
Exemple #23
0
 function definition_after_data()
 {
     global $CFG, $DB, $OUTPUT;
     $mform =& $this->_form;
     $userid = $mform->getElementValue('id');
     // if language does not exist, use site default lang
     if ($langsel = $mform->getElementValue('lang')) {
         $lang = reset($langsel);
         // missing _utf8 in language, add it before further processing. MDL-11829 MDL-16845
         if (strpos($lang, '_utf8') === false) {
             $lang = $lang . '_utf8';
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($lang);
         }
         // check lang exists
         if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($CFG->lang);
         }
     }
     if ($user = $DB->get_record('user', array('id' => $userid))) {
         // remove description
         if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
             $mform->removeElement('description');
         }
         // print picture
         if (!empty($CFG->gdversion)) {
             $image_el =& $mform->getElement('currentpicture');
             if ($user and $user->picture) {
                 $userpic = moodle_user_picture::make($user, SITEID);
                 $userpic->size = 64;
                 $image_el->setValue($OUTPUT->user_picture($userpic));
             } else {
                 $image_el->setValue(get_string('none'));
             }
         }
         /// disable fields that are locked by auth plugins
         $fields = get_user_fieldnames();
         $authplugin = get_auth_plugin($user->auth);
         foreach ($fields as $field) {
             if (!$mform->elementExists($field)) {
                 continue;
             }
             $configvariable = 'field_lock_' . $field;
             if (isset($authplugin->config->{$configvariable})) {
                 if ($authplugin->config->{$configvariable} === 'locked') {
                     $mform->hardFreeze($field);
                     $mform->setConstant($field, $user->{$field});
                 } else {
                     if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
                         $mform->hardFreeze($field);
                         $mform->setConstant($field, $user->{$field});
                     }
                 }
             }
         }
         /// Next the customisable profile fields
         profile_definition_after_data($mform, $user->id);
     } else {
         profile_definition_after_data($mform, 0);
     }
 }
Exemple #24
0
/**
 * Prints all users who has completed a specified feedback since a given time
 * many thanks to Manolescu Dorel, who contributed these two functions
 *
 * @global object
 * @param object $activity
 * @param int $courseid
 * @param string $detail
 * @param array $modnames
 * @return void Output is echo'd
 */
function feedback_print_recent_mod_activity($activity, $courseid, $detail, $modnames)
{
    global $CFG, $OUTPUT;
    echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">';
    echo "<tr><td class=\"userpicture\" valign=\"top\">";
    echo $OUTPUT->user_picture(moodle_user_picture::make($activity->user, $courseid));
    echo "</td><td>";
    if ($detail) {
        $modname = $modnames[$activity->type];
        echo '<div class="title">';
        echo "<img src=\"" . $OUTPUT->mod_icon_url('icon', $activity->type) . "\" " . "class=\"icon\" alt=\"{$modname}\" />";
        echo "<a href=\"{$CFG->wwwroot}/mod/feedback/view.php?id={$activity->cmid}\">{$activity->name}</a>";
        echo '</div>';
    }
    echo '<div class="title">';
    echo '</div>';
    echo '<div class="user">';
    echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$activity->user->userid}&amp;course={$courseid}\">" . "{$activity->user->fullname}</a> - " . userdate($activity->timestamp);
    echo '</div>';
    echo "</td></tr></table>";
    return;
}
Exemple #25
0
    message_remove_contact($removecontact);
}
if ($blockcontact and confirm_sesskey()) {
    add_to_log(SITEID, 'message', 'block contact', 'history.php?user1=' . $blockcontact . '&amp;user2=' . $USER->id, $blockcontact);
    message_block_contact($blockcontact);
}
if ($unblockcontact and confirm_sesskey()) {
    add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1=' . $unblockcontact . '&amp;user2=' . $USER->id, $unblockcontact);
    message_unblock_contact($unblockcontact);
}
//$PAGE->set_title('Message History');
$PAGE->set_generaltype('popup');
echo $OUTPUT->header();
echo '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
echo '<td width="100">';
$userpic = moodle_user_picture::make($user, SITEID);
$userpic->size = 48;
$userpic->link = true;
echo $OUTPUT->user_picture($userpic) . '</td>';
echo '<td valign="middle" align="center">';
echo '<div class="name">' . fullname($user) . '</div>';
echo '<div class="commands">';
if ($contact = $DB->get_record('message_contacts', array('userid' => $USER->id, 'contactid' => $user->id))) {
    if ($contact->blocked) {
        message_contact_link($user->id, 'add', false, 'user.php?id=' . $user->id, true);
        message_contact_link($user->id, 'unblock', false, 'user.php?id=' . $user->id, true);
    } else {
        message_contact_link($user->id, 'remove', false, 'user.php?id=' . $user->id, true);
        message_contact_link($user->id, 'block', false, 'user.php?id=' . $user->id, true);
    }
} else {
Exemple #26
0
$strname = get_string('name');
print_header($strratings);
if (!($ratings = data_get_ratings($record->id, $sqlsort))) {
    print_error('noratingforrecord', 'data');
} else {
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
    echo "<tr>";
    echo "<th class=\"header\" scope=\"col\">&nbsp;</th>";
    echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id={$record->id}&amp;sort=firstname\">{$strname}</a></th>";
    echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id={$id}&amp;sort=rating\">{$strrating}</a></th>";
    echo "</tr>";
    foreach ($ratings as $rating) {
        if (has_capability('mod/data:manageentries', $context)) {
            echo '<tr class="forumpostheadertopic">';
        } else {
            echo '<tr class="forumpostheader">';
        }
        echo '<td class="picture">';
        $userpic = moodle_user_picture::make($rating, $data->course);
        $userpic->link = true;
        echo $OUTPUT->user_picture($userpic);
        echo '</td>';
        echo '<td class="author">' . $OUTPUT->link($CFG->wwwroot . '/user/view.php?id=' . $rating->id . '&course=' . $data->course, fullname($rating)) . '</td>';
        echo '<td style="white-space:nowrap" align="center" class="rating">' . $scalemenu[$rating->rating] . '</td>';
        echo "</tr>\n";
    }
    echo "</table>";
    echo "<br />";
}
echo $OUTPUT->close_window_button();
echo $OUTPUT->footer();
Exemple #27
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();
 }
Exemple #28
0
}
$scalemenu = make_grades_menu($forum->scale);
$strratings = get_string('ratings', 'forum');
$strrating = get_string('rating', 'forum');
$strname = get_string('name');
$strtime = get_string('time');
print_header("{$strratings}: " . format_string($post->subject));
if (!($ratings = forum_get_ratings($post->id, $sqlsort))) {
    print_error('noresult', 'forum', '', format_string($post->subject));
} else {
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
    echo "<tr>";
    echo "<th class=\"header\" scope=\"col\">&nbsp;</th>";
    echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id={$post->id}&amp;sort=firstname\">{$strname}</a></th>";
    echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id={$post->id}&amp;sort=rating\">{$strrating}</a></th>";
    echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id={$post->id}&amp;sort=time\">{$strtime}</a></th>";
    echo "</tr>";
    foreach ($ratings as $rating) {
        echo '<tr class="forumpostheader">';
        echo "<td>";
        echo $OUTPUT->user_picture(moodle_user_picture::make($rating, $forum->course));
        echo '</td><td>' . fullname($rating) . '</td>';
        echo '<td style="white-space:nowrap" align="center" class="rating">' . $scalemenu[$rating->rating] . "</td>";
        echo '<td style="white-space:nowrap" align="center" class="time">' . userdate($rating->time) . "</td>";
        echo "</tr>\n";
    }
    echo "</table>";
    echo "<br />";
}
echo $OUTPUT->close_window_button();
echo $OUTPUT->footer();
Exemple #29
0
/**
 * @global object
 * @global object
 * @param object $message
 * @param int $courseid
 * @param object $sender
 * @param object $currentuser
 * @param string $chat_lastrow
 * @return bool|string Returns HTML or false
 */
function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chat_lastrow = NULL)
{
    global $CFG, $USER, $OUTPUT;
    $output = new object();
    $output->beep = false;
    // by default
    $output->refreshusers = false;
    // by default
    // Use get_user_timezone() to find the correct timezone for displaying this message:
    // It's either the current user's timezone or else decided by some Moodle config setting
    // First, "reset" $USER->timezone (which could have been set by a previous call to here)
    // because otherwise the value for the previous $currentuser will take precedence over $CFG->timezone
    $USER->timezone = 99;
    $tz = get_user_timezone($currentuser->timezone);
    // Before formatting the message time string, set $USER->timezone to the above.
    // This will allow dst_offset_on (called by userdate) to work correctly, otherwise the
    // message times appear off because DST is not taken into account when it should be.
    $USER->timezone = $tz;
    $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz);
    $message->picture = $OUTPUT->user_picture(moodle_user_picture::make($sender, $courseid));
    if ($courseid) {
        $message->picture = "<a onclick=\"window.open('{$CFG->wwwroot}/user/view.php?id={$sender->id}&amp;course={$courseid}')\" href=\"{$CFG->wwwroot}/user/view.php?id={$sender->id}&amp;course={$courseid}\">{$message->picture}</a>";
    }
    //Calculate the row class
    if ($chat_lastrow !== NULL) {
        $rowclass = ' class="r' . $chat_lastrow . '" ';
    } else {
        $rowclass = '';
    }
    // Start processing the message
    if (!empty($message->system)) {
        // System event
        $output->text = $message->strtime . ': ' . get_string('message' . $message->message, 'chat', fullname($sender));
        $output->html = '<table class="chat-event"><tr' . $rowclass . '><td class="picture">' . $message->picture . '</td><td class="text">';
        $output->html .= '<span class="event">' . $output->text . '</span></td></tr></table>';
        $output->basic = '<dl><dt class="event">' . $message->strtime . ': ' . get_string('message' . $message->message, 'chat', fullname($sender)) . '</dt></dl>';
        if ($message->message == 'exit' or $message->message == 'enter') {
            $output->refreshusers = true;
            //force user panel refresh ASAP
        }
        return $output;
    }
    // It's not a system event
    $text = $message->message;
    /// Parse the text to clean and filter it
    $options = new object();
    $options->para = false;
    $text = format_text($text, FORMAT_MOODLE, $options, $courseid);
    // And now check for special cases
    $special = false;
    if (substr($text, 0, 5) == 'beep ') {
        /// It's a beep!
        $special = true;
        $beepwho = trim(substr($text, 5));
        if ($beepwho == 'all') {
            // everyone
            $outinfo = $message->strtime . ': ' . get_string('messagebeepseveryone', 'chat', fullname($sender));
            $outmain = '';
            $output->beep = true;
            // (eventually this should be set to
            //  to a filename uploaded by the user)
        } else {
            if ($beepwho == $currentuser->id) {
                // current user
                $outinfo = $message->strtime . ': ' . get_string('messagebeepsyou', 'chat', fullname($sender));
                $outmain = '';
                $output->beep = true;
            } else {
                //something is not caught?
                return false;
            }
        }
    } else {
        if (substr($text, 0, 1) == '/') {
            /// It's a user command
            // support some IRC commands
            $pattern = '#(^\\/)(\\w+).*#';
            preg_match($pattern, trim($text), $matches);
            $command = $matches[2];
            switch ($command) {
                case 'me':
                    $special = true;
                    $outinfo = $message->strtime;
                    $outmain = '*** <b>' . $sender->firstname . ' ' . substr($text, 4) . '</b>';
                    break;
            }
        } elseif (substr($text, 0, 2) == 'To') {
            $pattern = '#To[[:space:]](.*):(.*)#';
            preg_match($pattern, trim($text), $matches);
            $special = true;
            $outinfo = $message->strtime;
            $outmain = $sender->firstname . ' ' . get_string('saidto', 'chat') . ' <i>' . $matches[1] . '</i>: ' . $matches[2];
        }
    }
    if (!$special) {
        $outinfo = $message->strtime . ' ' . $sender->firstname;
        $outmain = $text;
    }
    /// Format the message as a small table
    $output->text = strip_tags($outinfo . ': ' . $outmain);
    $output->html = "<table class=\"chat-message\"><tr{$rowclass}><td class=\"picture\" valign=\"top\">{$message->picture}</td><td class=\"text\">";
    $output->html .= "<span class=\"title\">{$outinfo}</span>";
    if ($outmain) {
        $output->html .= ": {$outmain}";
        $output->basic = '<dl><dt class="title">' . $outinfo . ':</dt><dd class="text">' . $outmain . '</dd></dl>';
    } else {
        $output->basic = '<dl><dt class="title">' . $outinfo . '</dt></dl>';
    }
    $output->html .= "</td></tr></table>";
    return $output;
}
Exemple #30
0
/**
 * Print a row of contactlist displaying user picture, messages waiting and 
 * block links etc
 * @param $contact contact object containing all fields required for $OUTPUT->user_picture()
 * @param $incontactlist is the user a contact of ours?
 */
function message_print_contactlist_user($contact, $incontactlist = true)
{
    global $OUTPUT;
    $fullname = fullname($contact);
    $fullnamelink = $fullname;
    /// are there any unread messages for this contact?
    if ($contact->messagecount > 0) {
        $fullnamelink = '<strong>' . $fullnamelink . ' (' . $contact->messagecount . ')</strong>';
    }
    if ($incontactlist) {
        $strcontact = message_contact_link($contact->id, 'remove', true);
        $strblock = '';
    } else {
        $strcontact = message_contact_link($contact->id, 'add', true);
        $strblock = '&nbsp;' . message_contact_link($contact->id, 'block', true);
    }
    $strhistory = message_history_link($contact->id, 0, true, '', '', 'icon');
    echo '<tr><td class="pix">';
    $userpic = moodle_user_picture::make($contact, SITEID);
    $userpic->size = 20;
    $userpic->link = true;
    echo $OUTPUT->user_picture($userpic);
    echo '</td>';
    echo '<td class="contact">';
    $popupoptions = array('height' => 500, 'width' => 500, 'menubar' => false, 'location' => false, 'status' => true, 'scrollbars' => true, 'resizable' => true);
    $link = html_link::make("/message/discussion.php?id={$contact->id}", $fullnamelink);
    $link->add_action(new popup_action('click', $link->url, "message_{$contact->id}", $popupoptions));
    $link->title = get_string('sendmessageto', 'message', $fullname);
    echo $OUTPUT->link($link);
    echo '</td>';
    echo '<td class="link">&nbsp;' . $strcontact . $strblock . '&nbsp;' . $strhistory . '</td>';
    echo '</tr>';
}