function block_exabis_eportfolio_print_extcomments($itemid) { $stredit = get_string('edit'); $strdelete = get_string('delete'); $comments = get_records("block_exabeporitemcomm", "itemid", $itemid, 'timemodified DESC'); if (!$comments) { return; } foreach ($comments as $comment) { $user = get_record('user', 'id', $comment->userid); echo '<table cellspacing="0" class="forumpost blogpost blog" width="100%">'; echo '<tr class="header"><td class="picture left">'; print_user_picture($comment->userid, SITEID, $user->picture); echo '</td>'; echo '<td class="topic starter"><div class="author">'; $fullname = fullname($user, $comment->userid); $by = new object(); $by->name = $fullname; $by->date = userdate($comment->timemodified); print_string('bynameondate', 'forum', $by); echo '</div></td></tr>'; echo '<tr><td class="left side">'; echo '</td><td class="content">' . "\n"; echo format_text($comment->entry); echo '</td></tr></table>' . "\n\n"; } }
function definition_after_data() { global $CFG, $DB; $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) { $image_el->setValue(print_user_picture($user, SITEID, $user->picture, 64, true, false, '', true)); } 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); } }
/** * Creates a new Hawthorn object. * @param object $course Moodle course object. If not supplied, uses $COURSE. * Only required field is ->id. */ function get_hawthorn($course = null) { global $USER, $COURSE, $CFG; if ($course == null) { $course = $COURSE; } $context = get_context_instance(CONTEXT_COURSE, $course->id); // Work out user permissions $permissions = ''; if (has_capability('block/hawthorn:chat', $context)) { $permissions .= 'rw'; } if (has_capability('block/hawthorn:moderate', $context)) { $permissions .= 'm'; } if (has_capability('block/hawthorn:admin', $context)) { $permissions .= 'a'; } // Get user picture URL $userpic = print_user_picture($USER, $COURSE->id, NULL, 0, true, false); $userpic = preg_replace('~^.*src="([^"]*)".*$~', '$1', $userpic); // Decide key expiry (ms). Usually 1 hour, unless session timeout is lower. $keyExpiry = 3600000; if ($CFG->sessiontimeout * 1000 < $keyExpiry) { // Set expiry to session timeout (note that the JS will make a re-acquire // request 5 minutes before this) $keyExpiry = $CFG->sessiontimeout * 1000; } // Get server list $servers = empty($CFG->block_hawthorn_servers) ? array() : explode(',', $CFG->block_hawthorn_servers); $magicnumber = empty($CFG->block_hawthorn_magicnumber) ? 'xxx' : $CFG->block_hawthorn_magicnumber; // Construct Hawthorn object return new hawthorn($magicnumber, $servers, hawthorn::escapeId($USER->username), fullname($USER), $userpic, $permissions, $CFG->wwwroot . '/blocks/hawthorn/hawthorn.js', $CFG->wwwroot . '/blocks/hawthorn/popup.php', $CFG->wwwroot . '/blocks/hawthorn/reacquire.php', false, $keyExpiry); }
function get_content() { global $USER, $CFG; 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 = get_records_sql("SELECT m.useridfrom as id, COUNT(m.useridfrom) as count,\n u.firstname, u.lastname, u.picture, u.lastaccess\n FROM {$CFG->prefix}user u, \n {$CFG->prefix}message m \n WHERE m.useridto = '{$USER->id}' \n AND u.id = m.useridfrom\n GROUP BY m.useridfrom, u.firstname,u.lastname,u.picture,u.lastaccess"); //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 . '&course=' . $this->instance->pageid . '" title="' . $timeago . '">'; $this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 0, true, false, '', false); $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="' . $CFG->pixpath . '/t/message.gif" alt="" /> ' . $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; }
function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode = '', $hook = '', $printicons = 1, $ratings = NULL, $aliases = true) { global $CFG, $USER, $DB; $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">'; print_user_picture($user, $course->id, $user->picture); 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 . '&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"> </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 view_feedback($submission = NULL) { global $USER; if (!$submission) { /// Get submission for this assignment $submission = $this->get_submission($USER->id); } if (empty($submission->timemarked)) { /// Nothing to show, so print nothing if ($this->count_responsefiles($USER->id)) { print_heading(get_string('responsefiles', 'assignment', $this->course->teacher), '', 3); $responsefiles = $this->print_responsefiles($USER->id, true); print_simple_box($responsefiles, 'center'); } return; } /// We need the teacher info if (!($teacher = get_record('user', 'id', $submission->teacher))) { error('Could not find the teacher'); } /// Print the feedback print_heading(get_string('submissionfeedback', 'assignment'), '', 3); echo '<table cellspacing="0" class="feedback">'; echo '<tr>'; echo '<td class="left picture">'; print_user_picture($teacher->id, $this->course->id, $teacher->picture); echo '</td>'; echo '<td class="topic">'; echo '<div class="from">'; echo '<div class="fullname">' . fullname($teacher) . '</div>'; echo '<div class="time">' . userdate($submission->timemarked) . '</div>'; echo '</div>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="left side"> </td>'; echo '<td class="content">'; if ($this->assignment->grade) { echo '<div class="grade">'; echo get_string("grade") . ': ' . $this->display_grade($submission->grade); echo '</div>'; echo '<div class="clearer"></div>'; } echo '<div class="comment">'; echo format_text($submission->submissioncomment, $submission->format); echo '</div>'; echo '</tr>'; echo '<tr>'; echo '<td class="left side"> </td>'; echo '<td class="content">'; echo $this->print_responsefiles($USER->id, true); echo '</tr>'; echo '</table>'; }
function col_picture($attempt) { global $COURSE; $user = new object(); $user->id = $attempt->userid; $user->lastname = $attempt->lastname; $user->firstname = $attempt->firstname; $user->imagealt = $attempt->imagealt; $user->picture = $attempt->picture; return print_user_picture($user, $COURSE->id, $attempt->picture, false, true); }
function format_user_list($data, $course) { global $CFG, $DB; $users = array(); foreach ($data as $v) { $user['name'] = fullname($v); $user['url'] = $CFG->wwwroot . '/user/view.php?id=' . $v->id . '&course=' . $course->id; $user['picture'] = print_user_picture($v->id, 0, $v->picture, false, true, false); $user['id'] = $v->id; $users[] = $user; } return $users; }
function definition_after_data() { global $CFG; $mform =& $this->_form; $userid = $mform->getElementValue('id'); // if language does not exist, use site default lang if ($langsel = $mform->getElementValue('lang')) { $lang = reset($langsel); 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 = get_record('user', 'id', $userid)) { // print picture if (!empty($CFG->gdversion)) { $image_el =& $mform->getElement('currentpicture'); if ($user and $user->picture) { $image_el->setValue(print_user_picture($user->id, SITEID, $user->picture, 64, true, false, '', true)); } else { $image_el->setValue(get_string('none')); } } /// disable fields that are locked by auth plugins $fields = get_user_fieldnames(); $freezefields = array(); $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') { $freezefields[] = $field; } else { if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') { $freezefields[] = $field; } } } } $mform->hardFreeze($freezefields); } /// Next the customisable profile fields profile_definition_after_data($mform); }
function definition_after_data() { global $USER, $CFG; $mform =& $this->_form; if ($userid = $mform->getElementValue('id')) { $user = get_record('user', 'id', $userid); } else { $user = false; } // if language does not exist, use site default lang if ($langsel = $mform->getElementValue('lang')) { $lang = reset($langsel); 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'); $email_el =& $mform->getElement('email'); if ($email_el->getValue() == 'root@localhost') { $email_el->setValue(''); } } // 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) { $image_el->setValue(print_user_picture($user, SITEID, $user->picture, 64, true, false, '', true)); } else { $image_el->setValue(get_string('none')); } } /// Next the customisable profile fields profile_definition_after_data($mform); }
function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode = "", $hook = "", $printicons = 1, $ratings = NULL, $aliases = true) { global $CFG, $USER; $user = get_record('user', 'id', $entry->userid); $strby = get_string('writtenby', 'glossary'); $return = false; if ($entry) { echo '<table class="glossarypost fullwithauthor" cellspacing="0">'; echo '<tr valign="top">'; echo '<td class="picture">'; print_user_picture($user->id, $course->id, $user->picture); 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 . '&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="entryattachment">'; glossary_print_entry_approval($cm, $entry, $mode); glossary_print_entry_attachment($entry, 'html', 'right'); echo '</td>'; echo '</tr>'; echo '<tr valign="top">'; echo '<td class="left"> </td>'; echo '<td colspan="2" class="entry">'; glossary_print_entry_definition($entry); echo '</td></tr>'; echo '<tr valign="top">'; echo '<td class="left"> </td>'; 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; }
/** * Display all the submissions ready for grading */ function display_submissions($message = '') { global $CFG, $db, $USER; 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; } $teacherattempts = true; /// Temporary measure $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->assignment->id, $this->assignment->id, $this->cm->id); $navlinks = array(); $navlinks[] = array('name' => $this->strassignments, 'link' => "index.php?id={$course->id}", 'type' => 'activity'); $navlinks[] = array('name' => format_string($this->assignment->name, true), 'link' => "view.php?a={$this->assignment->id}", 'type' => 'activityinstance'); $navlinks[] = array('name' => $this->strsubmissions, 'link' => '', 'type' => 'title'); $navigation = build_navigation($navlinks); print_header_simple(format_string($this->assignment->name, true), "", $navigation, '', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm)); if (!empty($message)) { echo $message; // display messages here if any } $context = get_context_instance(CONTEXT_MODULE, $cm->id); /// 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 $users = get_users_by_capability($context, 'mod/assignment:submit', '', '', '', '', $currentgroup, '', false); $users = array_keys($users); if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) { $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') . ' (' . $course->student . ')', get_string('lastmodified') . ' (' . $course->teacher . ')', 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 . '&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', '90%'); //$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(); /// Check to see if groups are being used in this assignment if (!$teacherattempts) { $teachers = get_course_teachers($course->id); if (!empty($teachers)) { $keys = array_keys($teachers); } foreach ($keys as $key) { unset($users[$key]); } } if (empty($users)) { print_heading(get_string('noattempts', '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, s.id AS submissionid, s.grade, s.submissioncomment, s.timemodified, s.timemarked, COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status '; $sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'assignment_submissions s ON u.id = s.userid AND s.assignment = ' . $this->assignment->id . ' ' . 'WHERE ' . $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 = get_records_sql($select . $sql . $sort, $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]; /// Calculate user status $auser->status = $auser->timemarked > 0 && $auser->timemarked >= $auser->timemodified; $picture = print_user_picture($auser->id, $course->id, $auser->picture, false, true); 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 . '"> </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 . '">' . $final_grade->str_grade . '</div>'; } else { if ($quickgrade) { $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++); $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 . '"> </div>'; if ($final_grade->locked or $final_grade->overridden) { $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>'; } else { if ($quickgrade) { $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++); $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 . '"> </div>'; $teachermodified = '<div id="tt' . $auser->id . '"> </div>'; $status = '<div id="st' . $auser->id . '"> </div>'; if ($final_grade->locked or $final_grade->overridden) { $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>'; } else { if ($quickgrade) { // allow editing $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++); $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 . '"> </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++; $button = link_to_popup_window($popup_url, 'grade' . $auser->id, $buttontext, 600, 780, $buttontext, 'none', true, 'button' . $auser->id); $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 .= ' '; $outcomes .= choose_from_menu($options, 'outcome_' . $n . '[' . $auser->id . ']', $outcome->grades[$auser->id]->grade, get_string('nooutcome', 'grades'), '', 0, true, false, 0, 'outcome_' . $n . '_' . $auser->id); } $outcomes .= '</div>'; } } $row = array($picture, fullname($auser), $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>'; //echo '<div style="text-align:center"><input type="submit" name="fastg" value="'.get_string('saveallfeedback', 'assignment').'" /></div>'; } $table->print_html(); /// Print the whole table if ($quickgrade) { echo '<div style="text-align:center"><input type="submit" name="fastg" value="' . get_string('saveallfeedback', 'assignment') . '" /></div>'; echo '</form>'; } /// End of fast grading form /// Mini form for setting user preference echo '<br />'; echo '<form id="options" action="submissions.php?id=' . $this->cm->id . '" method="post">'; echo '<div>'; echo '<input type="hidden" id="updatepref" name="updatepref" value="1" />'; echo '<table id="optiontable" align="right">'; echo '<tr align="right"><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 . '" />'; helpbutton('pagesize', get_string('pagesize', 'assignment'), 'assignment'); echo '</td></tr>'; echo '<tr align="right">'; echo '<td>'; print_string('quickgrade', 'assignment'); echo ':</td>'; echo '<td>'; if ($quickgrade) { echo '<input type="checkbox" name="quickgrade" value="1" checked="checked" />'; } else { echo '<input type="checkbox" name="quickgrade" value="1" />'; } helpbutton('quickgrade', get_string('quickgrade', 'assignment'), 'assignment') . '</p></div>'; echo '</td></tr>'; echo '<tr>'; echo '<td colspan="2" align="right">'; echo '<input type="submit" value="' . get_string('savepreferences') . '" />'; echo '</td></tr></table>'; echo '</div>'; echo '</form>'; ///End of mini form print_footer($this->course); }
$weights[] = $brainstorm->feedbackweight; $gradeparts[] = $gradeset->feedback; } else { $feedbackgrade = ''; } } else { $feedbackgrade = "<img src=\"{$CFG->wwwroot}/mod/brainstorm/teachhat.jpg\" width=\"30\" />"; } // calculates final $weighting = array_sum($weights); $finalgrade = 0; for ($i = 0; $i < count($gradeparts); $i++) { $finalgrade += $gradeparts[$i] * $weights[$i]; } $finalgrade = sprintf("%0.2f", $finalgrade / $weighting); $picture = print_user_picture($student->id, $course->id, $student->picture, false, true, true); $studentname = fullname($student); $updatelink = "<a href=\"view.php?id={$cm->id}&gradefor={$student->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\"></a><br/>"; $deletelink = "<a href=\"view.php?id={$cm->id}&what=deletegrade&for={$student->id}\"><img src=\"{$CFG->pixpath}/t/delete.gif\"></a><br/>"; $table->data[] = array($picture, $studentname, $participategrade, $preparinggrade, $organizegrade, $feedbackgrade, "<b>{$finalgrade}</b>", $updatelink . ' ' . $deletelink); } print_table($table); } } ?> </td> </tr> </table> <?php } else { // grading a user
$country = '(' . $user->country . ') ' . $countries[$user->country]; } else { $country = $countries[$user->country]; } } if (!isset($user->context)) { $usercontext = get_context_instance(CONTEXT_USER, $user->id); } else { $usercontext = $user->context; } if ($piclink = $USER->id == $user->id || has_capability('moodle/user:viewdetails', $context) || has_capability('moodle/user:viewdetails', $usercontext)) { $profilelink = '<strong><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id . '">' . fullname($user) . '</a></strong>'; } else { $profilelink = '<strong>' . fullname($user) . '</strong>'; } $data = array(print_user_picture($user, $course->id, $user->picture, false, true, $piclink), $profilelink . $hidden); if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) { $data[] = $user->city; } if ($mode === MODE_BRIEF && !isset($hiddenfields['country'])) { $data[] = $country; } if (!isset($hiddenfields['lastaccess'])) { $data[] = $lastaccess; } if ($course->enrolperiod) { if ($user->timeend) { $data[] = userdate($user->timeend, $timeformat); } else { $data[] = get_string('unlimited'); }
function create_overview_table(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options, &$tables) { global $CFG; $strtimeformat = get_string('strftimedatetime'); $is_html = $options['reportformat'] == 'htm'; $spacer = $is_html ? ' ' : ' '; $br = $is_html ? "<br />\n" : "\n"; // initialize $table unset($table); $table->border = 1; $table->width = 10; $table->head = array(); $table->align = array(); $table->size = array(); $table->wrap = array(); // picture column, if required if ($is_html) { $table->head[] = $spacer; $table->align[] = 'center'; $table->size[] = 10; $table->wrap[] = "nowrap"; } array_push($table->head, get_string("name"), hotpot_grade_heading($hotpot, $options), get_string("attempt", "quiz"), get_string("time", "quiz"), get_string("reportstatus", "hotpot"), get_string("timetaken", "quiz"), get_string("score", "quiz")); array_push($table->align, "left", "center", "center", "left", "center", "center", "center"); array_push($table->wrap, "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap"); array_push($table->size, "*", "*", "*", "*", "*", "*", "*"); $abandoned = 0; foreach ($users as $user) { // shortcut to user info held in first attempt record $u =& $user->attempts[0]; $picture = ''; $name = fullname($u); if ($is_html) { $picture = print_user_picture($u->userid, $course->id, $u->picture, false, true); $name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $u->userid . '&course=' . $course->id . '">' . $name . '</a>'; } $grade = isset($user->grade) && $user->grade != ' ' ? $user->grade : $spacer; $attemptcount = count($user->attempts); if ($attemptcount > 1) { $text = $name; $name = NULL; $name->text = $text; $name->rowspan = $attemptcount; $text = $grade; $grade = NULL; $grade->text = $text; $grade->rowspan = $attemptcount; } $data = array(); if ($is_html) { if ($attemptcount > 1) { $text = $picture; $picture = NULL; $picture->text = $text; $picture->rowspan = $attemptcount; } $data[] = $picture; } array_push($data, $name, $grade); foreach ($user->attempts as $attempt) { // increment count of abandoned attempts // if attempt is marked as finished but has no score if ($attempt->status == HOTPOT_STATUS_ABANDONED) { $abandoned++; } $attemptnumber = $attempt->attempt; $starttime = trim(userdate($attempt->timestart, $strtimeformat)); if ($is_html && isset($attempt->score) && (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review)) { $attemptnumber = '<a href="review.php?hp=' . $hotpot->id . '&attempt=' . $attempt->id . '">' . $attemptnumber . '</a>'; $starttime = '<a href="review.php?hp=' . $hotpot->id . '&attempt=' . $attempt->id . '">' . $starttime . '</a>'; } if ($is_html && has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id))) { $checkbox = '<input type="checkbox" name="box' . $attempt->clickreportid . '" value="' . $attempt->clickreportid . '" />' . $spacer; } else { $checkbox = ''; } $timetaken = empty($attempt->timefinish) ? $spacer : format_time($attempt->timefinish - $attempt->timestart); $score = hotpot_format_score($attempt); if ($is_html && is_numeric($score) && $score == $user->grade) { // best grade $score = '<span class="highlight">' . $score . '</span>'; } array_push($data, $attemptnumber, $checkbox . $starttime, hotpot_format_status($attempt), $timetaken, $score); $table->data[] = $data; $data = array(); } // end foreach $attempt $table->data[] = 'hr'; } // end foreach $user // remove final 'hr' from data rows array_pop($table->data); // add the "delete" form to the table if ($options['reportformat'] == 'htm' && has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id))) { $strdeletecheck = get_string('deleteattemptcheck', 'quiz'); $table->start = $this->deleteform_javascript(); $table->start .= '<form method="post" action="report.php" id="deleteform" onsubmit="' . "return deletecheck('" . $strdeletecheck . "', 'selection')" . '">' . "\n"; $table->start .= '<input type="hidden" name="del" value="selection" />' . "\n"; $table->start .= '<input type="hidden" name="id" value="' . $cm->id . '" />' . "\n"; $table->finish = '<center>' . "\n"; $table->finish .= '<input type="submit" value="' . get_string("deleteselected") . '" /> ' . "\n"; if ($abandoned) { $table->finish .= '<input type="button" value="' . get_string('deleteabandoned', 'hotpot') . '" onClick="if(deletecheck(' . "'" . addslashes_js(get_string('deleteabandonedcheck', 'hotpot', $abandoned)) . "', 'abandoned', true" . ')) document.getElementById(\'deleteform\').submit();" />' . "\n"; } $table->finish .= '<input type="button" value="' . get_string("deleteall") . '" onClick="if(deletecheck(' . "'" . addslashes_js($strdeletecheck) . "', 'all', true" . '))document.getElementById(\'deleteform\').submit();" />' . "\n"; $table->finish .= '</center>' . "\n"; $table->finish .= '</form>' . "\n"; } $tables[] =& $table; }
if (!empty($refresh) and data_submitted()) { $refreshedmessage = $message; } else { if (empty($refresh) and data_submitted() and confirm_sesskey()) { if ($message != '') { message_post_message($USER, $user, $message, $format, 'direct'); } redirect('discussion.php?id=' . $userid . '&start=' . $start . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last); } } $userfullname = fullname($user); $mefullname = fullname($USER); print_header(get_string('discussion', 'message') . ': ' . fullname($user), '', '', 'edit-message'); echo '<div class="message-discussion-noframes">'; echo '<div id="userinfo">'; echo print_user_picture($user->id, SITEID, $user->picture, 48, true, true, 'userwindow'); echo '<div class="name"><h1>' . $userfullname . '</h1></div>'; echo '<div class="commands"><ul>'; if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) { if ($contact->blocked) { echo '<li>'; message_contact_link($user->id, 'add', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true); echo '</li><li>'; message_contact_link($user->id, 'unblock', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true); echo '</li>'; } else { echo '<li>'; message_contact_link($user->id, 'remove', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true); echo '</li><li>'; message_contact_link($user->id, 'block', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true); echo '</li>';
/** * Display the report. */ public function display($game, $cm, $course) { global $CFG, $SESSION, $DB; // Define some strings. $strreallydel = addslashes(get_string('deleteattemptcheck', 'game')); $strtimeformat = get_string('strftimedatetime'); $strreviewquestion = get_string('reviewresponse', 'quiz'); // Only print headers if not asked to download data. if (!($download = optional_param('download', null))) { $this->print_header_and_tabs($cm, $course, $game, $reportmode = "overview"); } // Deal with actions. $action = optional_param('action', '', PARAM_ACTION); switch ($action) { case 'delete': // Some attempts need to be deleted. $attemptids = optional_param('attemptid', array(), PARAM_INT); foreach ($attemptids as $attemptid) { if ($attemptid && ($todelete = get_record('game_attempts', 'id', $attemptid))) { delete_records('game_attempts', 'id', $attemptid); delete_records('game_queries', 'attemptid', $attemptid); // Search game_attempts for other instances by this user. // If none, then delete record for this game, this user from game_grades. // else recalculate best grade. $userid = $todelete->userid; if (!record_exists('game_attempts', 'userid', $userid, 'gameid', $game->id)) { delete_records('game_grades', 'userid', $userid, 'gameid', $game->id); } else { game_save_best_score($game, $userid); } } } break; } // Print information on the number of existing attempts. if (!$download) { // Do not print notices when downloading. if ($attemptnum = count_records('game_attempts', 'gameid', $game->id)) { $a = new stdClass(); $a->attemptnum = $attemptnum; $a->studentnum = count_records_select('game_attempts', "gameid = '{$game->id}' AND preview = '0'", 'COUNT(DISTINCT userid)'); $a->studentstring = $course->students; notify(get_string('numattempts', 'game', $a)); } } $context = get_context_instance(CONTEXT_MODULE, $cm->id); // Find out current groups mode. if ($groupmode = groupmode($course, $cm)) { // Groups are being used. if (!$download) { $currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id={$cm->id}&mode=overview"); } else { $currentgroup = get_and_set_current_group($course, $groupmode); } } else { $currentgroup = get_and_set_current_group($course, $groupmode); } // Set table options. $noattempts = optional_param('noattempts', 0, PARAM_INT); $detailedmarks = optional_param('detailedmarks', 0, PARAM_INT); $pagesize = optional_param('pagesize', 10, PARAM_INT); $hasfeedback = game_has_feedback($game->id) && $game->grade > 1.0E-7; if ($pagesize < 1) { $pagesize = 10; } // Now check if asked download of data. if ($download) { $filename = clean_filename("{$course->shortname} " . format_string($game->name, true)); $sort = ''; } // Define table columns. $tablecolumns = array('checkbox', 'picture', 'fullname', 'timestart', 'timefinish', 'duration'); $tableheaders = array(null, '', get_string('fullname'), get_string('startedon', 'game'), get_string('timecompleted', 'game'), get_string('attemptduration', 'game')); if ($game->grade) { $tablecolumns[] = 'grade'; $tableheaders[] = get_string('grade', 'game') . '/' . $game->grade; } if ($detailedmarks) { // We want to display marks for all questions. // Start by getting all questions. $questionlist = game_questions_in_game($game->questions); $questionids = explode(',', $questionlist); $sql = "SELECT q.*, i.score AS maxgrade, i.id AS instance" . " FROM {question} q," . " {game_queries} i" . " WHERE i.gameid = '{$game->id}' AND q.id = i.questionid" . " AND q.id IN ({$questionlist})"; if (!($questions = get_records_sql($sql))) { print_error('No questions found'); } $number = 1; foreach ($questionids as $key => $id) { if ($questions[$id]->length) { // Only print questions of non-zero length. $tablecolumns[] = '$' . $id; $tableheaders[] = '#' . $number; $questions[$id]->number = $number; $number += $questions[$id]->length; } else { // Get rid of zero length questions. unset($questions[$id]); unset($questionids[$key]); } } } if ($hasfeedback) { $tablecolumns[] = 'feedbacktext'; $tableheaders[] = get_string('feedback', 'game'); } if (!$download) { // Set up the table. $table = new flexible_table('mod-game-report-overview-report'); $table->define_columns($tablecolumns); $table->define_headers($tableheaders); $table->define_baseurl($CFG->wwwroot . '/mod/game/report.php?mode=overview&id=' . $cm->id . '&noattempts=' . $noattempts . '&detailedmarks=' . $detailedmarks . '&pagesize=' . $pagesize); $table->sortable(true); $table->collapsible(true); $table->column_suppress('picture'); $table->column_suppress('fullname'); $table->column_class('picture', 'picture'); $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'attempts'); $table->set_attribute('class', 'generaltable generalbox'); // Start working -- this is necessary as soon as the niceties are over. $table->setup(); } else { if ($download == 'ODS') { require_once "{$CFG->libdir}/odslib.class.php"; $filename .= ".ods"; // Creating a workbook. $workbook = new MoodleODSWorkbook("-"); // Sending HTTP headers. $workbook->send($filename); // Creating the first worksheet. $sheettitle = get_string('reportoverview', 'game'); $myxls =& $workbook->add_worksheet($sheettitle); // Format types. $format =& $workbook->add_format(); $format->set_bold(0); $formatbc =& $workbook->add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); $formatb =& $workbook->add_format(); $formatb->set_bold(1); $formaty =& $workbook->add_format(); $formaty->set_bg_color('yellow'); $formatc =& $workbook->add_format(); $formatc->set_align('center'); $formatr =& $workbook->add_format(); $formatr->set_bold(1); $formatr->set_color('red'); $formatr->set_align('center'); $formatg =& $workbook->add_format(); $formatg->set_bold(1); $formatg->set_color('green'); $formatg->set_align('center'); // Here starts workshhet headers. $headers = array(get_string('fullname'), get_string('startedon', 'game'), get_string('timecompleted', 'game'), get_string('attemptduration', 'game')); if ($game->grade) { $headers[] = get_string('grade', 'game') . '/' . $game->grade; } if ($detailedmarks) { foreach ($questionids as $id) { $headers[] = '#' . $questions[$id]->number; } } if ($hasfeedback) { $headers[] = get_string('feedback', 'game'); } $colnum = 0; foreach ($headers as $item) { $myxls->write(0, $colnum, $item, $formatbc); $colnum++; } $rownum = 1; } else { if ($download == 'Excel') { require_once "{$CFG->libdir}/excellib.class.php"; $filename .= ".xls"; // Creating a workbook. $workbook = new MoodleExcelWorkbook("-"); // Sending HTTP headers. $workbook->send($filename); // Creating the first worksheet. $sheettitle = get_string('reportoverview', 'game'); $myxls =& $workbook->add_worksheet($sheettitle); // Format types. $format =& $workbook->add_format(); $format->set_bold(0); $formatbc =& $workbook->add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); $formatb =& $workbook->add_format(); $formatb->set_bold(1); $formaty =& $workbook->add_format(); $formaty->set_bg_color('yellow'); $formatc =& $workbook->add_format(); $formatc->set_align('center'); $formatr =& $workbook->add_format(); $formatr->set_bold(1); $formatr->set_color('red'); $formatr->set_align('center'); $formatg =& $workbook->add_format(); $formatg->set_bold(1); $formatg->set_color('green'); $formatg->set_align('center'); // Here starts workshhet headers. $headers = array(get_string('fullname'), get_string('startedon', 'game'), get_string('timecompleted', 'game'), get_string('attemptduration', 'game')); if ($game->grade) { $headers[] = get_string('grade', 'game') . '/' . $game->grade; } if ($detailedmarks) { foreach ($questionids as $id) { $headers[] = '#' . $questions[$id]->number; } } if ($hasfeedback) { $headers[] = get_string('feedback', 'game'); } $colnum = 0; foreach ($headers as $item) { $myxls->write(0, $colnum, $item, $formatbc); $colnum++; } $rownum = 1; } else { if ($download == 'CSV') { $filename .= ".txt"; header("Content-Type: application/download\n"); header("Content-Disposition: attachment; filename=\"{$filename}\""); header("Expires: 0"); header("Cache-Control: must-revalidate,post-check=0,pre-check=0"); header("Pragma: public"); $headers = get_string('fullname') . "\t" . get_string('startedon', 'game') . "\t" . get_string('timecompleted', 'game') . "\t" . get_string('attemptduration', 'game'); if ($game->grade) { $headers .= "\t" . get_string('grade', 'game') . "/" . $game->grade; } if ($detailedmarks) { foreach ($questionids as $id) { $headers .= "\t#" . $questions[$id]->number; } } if ($hasfeedback) { $headers .= "\t" . get_string('feedback', 'game'); } echo $headers . " \n"; } } } } $contextlists = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $course->id)); // Construct the SQL. $select = 'SELECT qa.id,' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ' AS uniqueid, ' . 'qa.id as attemptuniqueid, qa.id AS attempt, u.id AS userid, u.firstname, u.lastname, u.picture, ' . 'qa.score, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration '; if ($course->id != SITEID) { // This is too complicated, so just do it for each of the four cases. if (!empty($currentgroup) && empty($noattempts)) { // We want a particular group and we only want to see students WITH attempts. // So join on groups_members and do an inner join on attempts. $from = 'FROM {user} u JOIN {role_assignments} ra ON ra.userid = u.id ' . groups_members_join_sql() . 'JOIN {game_attempts} qa ON u.id = qa.userid AND qa.gameid = ' . $game->id; $where = ' WHERE ra.contextid ' . $contextlists . ' AND ' . groups_members_where_sql($currentgroup) . ' AND qa.preview = 0'; } else { if (!empty($currentgroup) && !empty($noattempts)) { // We want a particular group and we want to do something funky with attempts. // So join on groups_members and left join on attempts... $from = 'FROM {user} u JOIN {role_assignments} ra ON ra.userid = u.id ' . groups_members_join_sql() . 'LEFT JOIN {game_attempts} qa ON u.id = qa.userid AND qa.gameid = ' . $game->id; $where = ' WHERE ra.contextid ' . $contextlists . ' AND ' . groups_members_where_sql($currentgroup); if ($noattempts == 1) { // Noattempts = 1 means only no attempts, so make the left join ask. // For only records where the right is null (no attempts). $where .= ' AND qa.userid IS NULL'; // Show ONLY no attempts. } else { // We are including attempts, so exclude previews. $where .= ' AND qa.preview = 0'; } } else { if (empty($currentgroup)) { // We don't care about group, and we to do something funky with attempts. // So do a left join on attempts. $from = 'FROM {user} u JOIN {role_assignments} ra ON ra.userid = u.id ' . ' LEFT JOIN {game_attempts} qa ON u.id = qa.userid AND qa.gameid = ' . $game->id; $where = " WHERE ra.contextid {$contextlists}"; if (empty($noattempts)) { // Show ONLY students with attempts. $where .= ' AND qa.userid IS NOT NULL AND qa.preview = 0'; } else { if ($noattempts == 1) { // The noattempts = 1 means only no attempts,. // So make the left join ask for only records where the right is null (no attempts). // Show ONLY students without attempts. $where .= ' AND qa.userid IS NULL'; } else { if ($noattempts == 3) { // We want all attempts. $from = 'FROM {user} u JOIN {game_attempts} qa ON u.id = qa.userid '; $where = ' WHERE qa.gameid = ' . $game->id . ' AND qa.preview = 0'; } } } // The noattempts = 2 means we want all students, with or without attempts. } } } $countsql = 'SELECT COUNT(DISTINCT(' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ')) ' . $from . $where; } else { if (empty($noattempts)) { $from = 'FROM {user} u JOIN {game_attempts} qa ON u.id = qa.userid '; $where = ' WHERE qa.gameid = ' . $game->id . ' AND qa.preview = 0'; $countsql = 'SELECT COUNT(DISTINCT(' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ')) ' . $from . $where; } } if (!$download) { // Add extra limits due to initials bar. if ($table->get_sql_where()) { $where .= ' AND ' . $table->get_sql_where(); } // Count the records NOW, before funky question grade sorting messes up $from. if (!empty($countsql)) { $totalinitials = count_records_sql($countsql); if ($table->get_sql_where()) { $countsql .= ' AND ' . $table->get_sql_where(); } $total = count_records_sql($countsql); } // Add extra limits due to sorting by question grade. if ($sort = $table->get_sql_sort()) { $sortparts = explode(',', $sort); $newsort = array(); $questionsort = false; foreach ($sortparts as $sortpart) { $sortpart = trim($sortpart); if (substr($sortpart, 0, 1) == '$') { if (!$questionsort) { $qid = intval(substr($sortpart, 1)); $select .= ', grade '; $from .= ' LEFT JOIN {question_sessions} qns ON qns.attemptid = qa.id ' . 'LEFT JOIN {question_states} qs ON qs.id = qns.newgraded '; $where .= ' AND (' . sql_isnull('qns.questionid') . ' OR qns.questionid = ' . $qid . ')'; $newsort[] = 'grade ' . (strpos($sortpart, 'ASC') ? 'ASC' : 'DESC'); $questionsort = true; } } else { $newsort[] = $sortpart; } } // Reconstruct the sort string. $sort = ' ORDER BY ' . implode(', ', $newsort); } // Fix some wired sorting. if (empty($sort)) { $sort = ' ORDER BY qa.id'; } $table->pagesize($pagesize, $total); } // If there is feedback, include it in the query. if ($hasfeedback) { $select .= ', qf.feedbacktext '; $from .= " JOIN {game_feedback} qf ON " . "qf.gameid = {$game->id} AND qf.mingrade <= qa.score * {$game->grade} AND qa.score * {$game->grade} < qf.maxgrade"; } // Fetch the attempts. if (!empty($from)) { // If we're in the site course and displaying no attempts, it makes no sense to do the query. if (!$download) { $attempts = get_records_sql($select . $from . $where . $sort, $table->get_page_start(), $table->get_page_size()); } else { $attempts = get_records_sql($select . $from . $where . $sort); } } else { $attempts = array(); } // Build table rows. if (!$download) { $table->initialbars($totalinitials > 20); } if (!empty($attempts) || !empty($noattempts)) { if ($attempts) { foreach ($attempts as $attempt) { $picture = print_user_picture($attempt->userid, $course->id, $attempt->picture, false, true); /* Uncomment the commented lines below if you are choosing to show unenrolled users and * have uncommented the corresponding lines earlier in this script * if (in_array($attempt->userid, $unenrolledusers)) { * $userlink = '<a class="dimmed" href="'.$CFG->wwwroot. * '/user/view.php?id='.$attempt->userid.'&course='.$course->id.'">'.fullname($attempt).'</a>'; *} *else { * $userlink = '<a href="'.$CFG->wwwroot.'/user/view.php?id='. * $attempt->userid.'&course='.$course->id.'">'.fullname($attempt).'</a>'; *} */ if (!$download) { $row = array('<input type="checkbox" name="attemptid[]" value="' . $attempt->attempt . '" />', $picture, $userlink, empty($attempt->attempt) ? '-' : '<a href="review.php?q=' . $game->id . '&attempt=' . $attempt->attempt . '">' . userdate($attempt->timestart, $strtimeformat) . '</a>', empty($attempt->timefinish) ? '-' : '<a href="review.php?q=' . $game->id . '&attempt=' . $attempt->attempt . '">' . userdate($attempt->timefinish, $strtimeformat) . '</a>', empty($attempt->attempt) ? '-' : (empty($attempt->timefinish) ? get_string('unfinished', 'game') : format_time($attempt->duration))); } else { $row = array(fullname($attempt), empty($attempt->attempt) ? '-' : userdate($attempt->timestart, $strtimeformat), empty($attempt->timefinish) ? '-' : userdate($attempt->timefinish, $strtimeformat), empty($attempt->attempt) ? '-' : (empty($attempt->timefinish) ? get_string('unfinished', 'game') : format_time($attempt->duration))); } if ($game->grade) { if (!$download) { $row[] = $attempt->score === null ? '-' : '<a href="review.php?q=' . $game->id . '&attempt=' . $attempt->attempt . '">' . round($attempt->score * $game->grade, $game->decimalpoints) . '</a>'; } else { $row[] = $attempt->score === null ? '-' : round($attempt->score * $game->grade, $game->decimalpoints); } } if ($detailedmarks) { if (empty($attempt->attempt)) { foreach ($questionids as $questionid) { $row[] = '-'; } } else { foreach ($questionids as $questionid) { if ($gradedstateid = get_field('question_sessions', 'newgraded', 'attemptid', $attempt->attemptuniqueid, 'questionid', $questionid)) { $grade = round(get_field('question_states', 'grade', 'id', $gradedstateid), $game->decimalpoints); } else { $grade = '--'; } if (!$download) { $row[] = link_to_popup_window('/mod/game/reviewquestion.php?state=' . $gradedstateid . '&number=' . $questions[$questionid]->number, 'reviewquestion', $grade, 450, 650, $strreviewquestion, 'none', true); } else { $row[] = $grade; } } } } if ($hasfeedback) { if ($attempt->timefinish) { $row[] = $attempt->feedbacktext; } else { $row[] = '-'; } } if (!$download) { $table->add_data($row); } else { if ($download == 'Excel' or $download == 'ODS') { $colnum = 0; foreach ($row as $item) { $myxls->write($rownum, $colnum, $item, $format); $colnum++; } $rownum++; } else { if ($download == 'CSV') { $text = implode("\t", $row); echo $text . " \n"; } } } } } if (!$download) { // Start form. echo '<div id="tablecontainer">'; echo '<form id="attemptsform" method="post" action="report.php" ' . 'onsubmit="var menu = document.getElementById(\'menuaction\'); ' . 'return (menu.options[menu.selectedIndex].value == \'delete\' ? confirm(\'' . $strreallydel . '\') : true);">'; echo '<div>'; echo '<input type="hidden" name="id" value="' . $cm->id . '" />'; echo '<input type="hidden" name="mode" value="overview" />'; // Print table. $table->print_html(); // Print "Select all" etc.. if (!empty($attempts)) { echo '<table id="commands">'; echo '<tr><td>'; echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">' . get_string('selectall', 'game') . '</a> / '; echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">' . get_string('selectnone', 'game') . '</a> '; echo ' '; $options = array('delete' => get_string('delete')); echo choose_from_menu($options, 'action', '', get_string('withselected', 'game'), 'if(this.selectedIndex > 0) submitFormById(\'attemptsform\');', '', true); echo '<noscript id="noscriptmenuaction" style="display: inline;"><div>'; echo '<input type="submit" value="' . get_string('go') . '" /></div></noscript>'; echo '<script type="text/javascript">' . "\n<!--\n" . 'document.getElementById("noscriptmenuaction").style.display = "none";' . "\n-->\n" . '</script>'; echo '</td></tr></table>'; } // Close form. echo '</div>'; echo '</form></div>'; if (!empty($attempts)) { echo '<table class="boxaligncenter"><tr>'; $options = array(); $options["id"] = "{$cm->id}"; $options["q"] = "{$game->id}"; $options["mode"] = "overview"; $options['sesskey'] = sesskey(); $options["noheader"] = "yes"; $options['noattempts'] = $noattempts; $options['detailedmarks'] = $detailedmarks; echo '<td>'; $options["download"] = "ODS"; print_single_button("report.php", $options, get_string("downloadods", 'game')); echo "</td>\n"; echo '<td>'; $options["download"] = "Excel"; print_single_button("report.php", $options, get_string("downloadexcel")); echo "</td>\n"; echo '<td>'; $options["download"] = "CSV"; print_single_button('report.php', $options, get_string("downloadtext")); echo "</td>\n"; echo "<td>"; helpbutton('overviewdownload', get_string('overviewdownload', 'quiz'), 'game'); echo "</td>\n"; echo '</tr></table>'; } } else { if ($download == 'Excel' or $download == 'ODS') { $workbook->close(); exit; } else { if ($download == 'CSV') { exit; } } } } else { if (!$download) { $table->print_html(); } } // Print display options. echo '<div class="controls">'; echo '<form id="options" action="report.php" method="get">'; echo '<div>'; echo '<p>' . get_string('displayoptions', 'game') . ': </p>'; echo '<input type="hidden" name="id" value="' . $cm->id . '" />'; echo '<input type="hidden" name="q" value="' . $game->id . '" />'; echo '<input type="hidden" name="mode" value="overview" />'; echo '<input type="hidden" name="noattempts" value="0" />'; echo '<input type="hidden" name="detailedmarks" value="0" />'; echo '<table id="overview-options" class="boxaligncenter">'; echo '<tr align="left">'; echo '<td><label for="pagesize">' . get_string('pagesize', 'game') . '</label></td>'; echo '<td><input type="text" id="pagesize" name="pagesize" size="3" value="' . $pagesize . '" /></td>'; echo '</tr>'; echo '<tr align="left">'; echo '<td colspan="2">'; $options = array(0 => get_string('attemptsonly', 'game', $course->students)); if ($course->id != SITEID) { $options[1] = get_string('noattemptsonly', 'game', $course->students); $options[2] = get_string('allstudents', 'game', $course->students); $options[3] = get_string('allattempts', 'game'); } choose_from_menu($options, 'noattempts', $noattempts, ''); echo '</td></tr>'; echo '<tr align="left">'; echo '<td colspan="2"><input type="checkbox" id="checkdetailedmarks" name="detailedmarks" ' . ($detailedmarks ? 'checked="checked" ' : '') . 'value="1" /> <label for="checkdetailedmarks">' . get_string('showdetailedmarks', 'game') . '</label> '; echo '</td></tr>'; echo '<tr><td colspan="2" align="center">'; echo '<input type="submit" value="' . get_string('go') . '" />'; echo '</td></tr></table>'; echo '</div>'; echo '</form>'; echo '</div>'; echo "\n"; return true; }
echo '<td style="padding-left: 30px;"> ' . get_string('bookmarks', 'block_exabis_eportfolio') . ': ' . $user->detail_count . "</td>"; echo "</tr>"; } echo "</table>"; } // Show Portfolios of users from other courses echo "<div>" . get_string('studentsfromothercourses', 'block_exabis_eportfolio') . "</div><br/>"; if (is_array($all_shared_users)) { echo "<table>"; $newline = 0; foreach ($all_shared_users as $user) { if (in_array($user->id, $studentlist)) { continue; } $newline++; if ($newline % 4 == 0) { echo "<tr>"; } echo "<td><a href=\"{$CFG->wwwroot}/blocks/exabis_eportfolio/" . $detailLink . "?courseid={$courseid}&access=id/{$user->id}\">"; print_user_picture($user->id, $courseid, $user->picture, 0, false, false); echo "</a> </td>"; echo "<td> <a href=\"{$CFG->wwwroot}/blocks/exabis_eportfolio/" . $detailLink . "?courseid={$courseid}&access=id/{$user->id}\">" . fullname($user, $user->id) . "</a></td>"; echo '<td style="padding-left: 30px;"> ' . get_string('bookmarks', 'block_exabis_eportfolio') . ': ' . $user->detail_count . "</td>"; if ($newline % 4 == 0) { echo "</tr>"; } } echo "</table>"; } echo "</div>"; print_footer($course);
/** * This function is in lib and not in BlogInfo because entries being searched * might be found in any number of blogs rather than just one. * * This function builds an array which can be used by the included * template file, making predefined and nicely formatted variables available * to the template. Template creators will not need to become intimate * with the internal objects and vars of moodle blog nor will they need to worry * about properly formatting their data * * @param BlogEntry blogEntry - a hopefully fully populated BlogEntry object * @param string viewtype Default is 'full'. If 'full' then display this blog entry * in its complete form (eg. archive page). If anything other than 'full' * display the entry in its abbreviated format (eg. index page) */ function blog_print_entry($blogEntry, $viewtype = 'full', $filtertype = '', $filterselect = '', $mode = 'loud') { global $USER, $CFG, $COURSE, $ME; $template['body'] = format_text($blogEntry->summary, $blogEntry->format); $template['title'] = '<a id=b"' . s($blogEntry->id) . ' /">'; //enclose the title in nolink tags so that moodle formatting doesn't autolink the text $template['title'] .= '<span class="nolink">' . format_string($blogEntry->subject) . '</span>'; $template['userid'] = $blogEntry->userid; $template['author'] = fullname(get_record('user', 'id', $blogEntry->userid)); $template['created'] = userdate($blogEntry->created); if ($blogEntry->created != $blogEntry->lastmodified) { $template['lastmod'] = userdate($blogEntry->lastmodified); } $template['publishstate'] = $blogEntry->publishstate; /// preventing user to browse blogs that they aren't supposed to see /// This might not be too good since there are multiple calls per page /* if (!blog_user_can_view_user_post($template['userid'])) { error ('you can not view this post'); }*/ $stredit = get_string('edit'); $strdelete = get_string('delete'); $user = get_record('user', 'id', $template['userid']); /// Start printing of the blog echo '<table cellspacing="0" class="forumpost blogpost blog' . $template['publishstate'] . '" width="100%">'; echo '<tr class="header"><td class="picture left">'; print_user_picture($user, SITEID, $user->picture); echo '</td>'; echo '<td class="topic starter"><div class="subject">' . $template['title'] . '</div><div class="author">'; $fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $COURSE->id))); $by = new object(); $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $COURSE->id . '">' . $fullname . '</a>'; $by->date = $template['created']; print_string('bynameondate', 'forum', $by); echo '</div></td></tr>'; echo '<tr><td class="left side">'; /// Actual content echo '</td><td class="content">' . "\n"; if ($blogEntry->attachment) { echo '<div class="attachments">'; $attachedimages = blog_print_attachments($blogEntry); echo '</div>'; } else { $attachedimages = ''; } switch ($template['publishstate']) { case 'draft': $blogtype = get_string('publishtonoone', 'blog'); break; case 'site': $blogtype = get_string('publishtosite', 'blog'); break; case 'public': $blogtype = get_string('publishtoworld', 'blog'); break; default: $blogtype = ''; break; } echo '<div class="audience">' . $blogtype . '</div>'; // Print whole message echo $template['body']; /// Print attachments echo $attachedimages; /// Links to tags if (!empty($CFG->usetags) && ($blogtags = tag_get_tags_csv('post', $blogEntry->id))) { echo '<div class="tags">'; if ($blogtags) { print get_string('tags', 'tag') . ': ' . $blogtags; } echo '</div>'; } /// Commands echo '<div class="commands">'; if (blog_user_can_edit_post($blogEntry)) { echo '<a href="' . $CFG->wwwroot . '/blog/edit.php?action=edit&id=' . $blogEntry->id . '">' . $stredit . '</a>'; echo '| <a href="' . $CFG->wwwroot . '/blog/edit.php?action=delete&id=' . $blogEntry->id . '">' . $strdelete . '</a> | '; } echo '<a href="' . $CFG->wwwroot . '/blog/index.php?postid=' . $blogEntry->id . '">' . get_string('permalink', 'blog') . '</a>'; echo '</div>'; if (isset($template['lastmod'])) { echo '<div style="font-size: 55%;">'; echo ' [ ' . get_string('modified') . ': ' . $template['lastmod'] . ' ]'; echo '</div>'; } echo '</td></tr></table>' . "\n\n"; }
$essayinfo = unserialize($essay->useranswer); // Different colors for all the states of an essay (graded, if sent, not graded) if (!$essayinfo->graded) { $class = ' class="graded"'; } elseif (!$essayinfo->sent) { $class = ' class="sent"'; } else { $class = ' class="ungraded"'; } // link for each essay $essaylinks[] = "<a{$class} href=\"{$CFG->wwwroot}/mod/lesson/essay.php?id={$cm->id}&mode=grade&attemptid={$essay->id}&sesskey=" . sesskey() . '">' . userdate($essay->timeseen, get_string('strftimedatetime')) . ' ' . format_string($pages[$essay->pageid]->title, true) . '</a>'; } } // email link for this user $emaillink = "<a href=\"{$CFG->wwwroot}/mod/lesson/essay.php?id={$cm->id}&mode=email&userid={$userid}&sesskey=" . sesskey() . '">' . get_string('emailgradedessays', 'lesson') . '</a>'; $table->data[] = array(print_user_picture($userid, $course->id, $users[$userid]->picture, 0, true) . $studentname, implode("<br />\n", $essaylinks), $emaillink); } // email link for all users $emailalllink = "<a href=\"{$CFG->wwwroot}/mod/lesson/essay.php?id={$cm->id}&mode=email&sesskey=" . sesskey() . '">' . get_string('emailallgradedessays', 'lesson') . '</a>'; $table->data[] = array(' ', ' ', $emailalllink); print_table($table); break; case 'grade': // Grading form // Expects the following to be set: $attemptid, $answer, $user, $page, $attempt echo '<div class="grade"> <form id="essaygrade" method="post" action="' . $CFG->wwwroot . '/mod/lesson/essay.php"> <input type="hidden" name="id" value="' . $cm->id . '" /> <input type="hidden" name="mode" value="update" /> <input type="hidden" name="attemptid" value="' . $attemptid . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" />';
add_to_log(SITEID, 'message', 'history', 'history.php?user1=' . $userid1 . '&user2=' . $userid2, $userid1); /// Our two users are defined - let's set up the page print_header(get_string('messagehistory', 'message'), '', '', '', '<base target="_blank" />'); /// Print out a heading including the users we are looking at print_simple_box_start('center'); echo '<table align="center" cellpadding="10"><tr>'; echo '<td align="center">'; echo print_user_picture($user1->id, SITEID, $user1->picture, 100, true, true, 'userwindow') . '<br />'; echo fullname($user1); echo '</td>'; echo '<td align="center">'; echo '<img src="' . $CFG->wwwroot . '/pix/t/left.gif" alt="' . get_string('from') . '" />'; echo '<img src="' . $CFG->wwwroot . '/pix/t/right.gif" alt="' . get_string('to') . '" />'; echo '</td>'; echo '<td align="center">'; echo print_user_picture($user2->id, SITEID, $user2->picture, 100, true, true, 'userwindow') . '<br />'; echo fullname($user2); echo '</td>'; echo '</tr></table>'; print_simple_box_end(); /// Get all the messages and print them if ($messages = message_get_history($user1, $user2)) { $current->mday = ''; $current->month = ''; $current->year = ''; $messagedate = get_string('strftimetime'); $blockdate = get_string('strftimedaydate'); foreach ($messages as $message) { $date = usergetdate($message->timecreated); if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) { $current->mday = $date['mday'];
function view_feedback($submission = NULL) { global $USER, $CFG; require_once $CFG->libdir . '/gradelib.php'; if (!$submission) { /// Get submission for this assignment $submission = $this->get_submission($USER->id); } if (empty($submission->timemarked)) { /// Nothing to show, so print nothing if ($this->count_responsefiles($USER->id)) { print_heading(get_string('responsefiles', 'assignment', $this->course->teacher), '', 3); $responsefiles = $this->print_responsefiles($USER->id, true); print_simple_box($responsefiles, 'center'); } return; } $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $USER->id); $item = $grading_info->items[0]; $grade = $item->grades[$USER->id]; if ($grade->hidden or $grade->grade === false) { // hidden or error return; } if ($grade->grade === null and empty($grade->str_feedback)) { /// Nothing to show yet return; } $graded_date = $grade->dategraded; $graded_by = $grade->usermodified; /// We need the teacher info if (!($teacher = get_record('user', 'id', $graded_by))) { error('Could not find the teacher'); } /// Print the feedback print_heading(get_string('submissionfeedback', 'assignment'), '', 3); echo '<table cellspacing="0" class="feedback">'; echo '<tr>'; echo '<td class="left picture">'; print_user_picture($teacher, $this->course->id, $teacher->picture); echo '</td>'; echo '<td class="topic">'; echo '<div class="from">'; echo '<div class="fullname">' . fullname($teacher) . '</div>'; echo '<div class="time">' . userdate($graded_date) . '</div>'; echo '</div>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="left side"> </td>'; echo '<td class="content">'; if ($this->assignment->grade) { echo '<div class="grade">'; echo get_string("grade") . ': ' . $grade->str_long_grade; echo '</div>'; echo '<div class="clearer"></div>'; } echo '<div class="comment">'; echo $grade->str_feedback; echo '</div>'; echo '</tr>'; echo '<tr>'; echo '<td class="left side"> </td>'; echo '<td class="content">'; echo $this->print_responsefiles($USER->id, true); echo '</tr>'; echo '</table>'; }
function ewiki_page_info($id, &$data, $action) { global $ewiki_plugins, $ewiki_config, $ewiki_links; global $CFG, $COURSE, $DB; // MOODLE HACK $pnum = optional_param(EWIKI_UP_PAGENUM, 0); $pend = optional_param(EWIKI_UP_PAGEEND, 0); $o = ewiki_make_title($id, ewiki_t("INFOABOUTPAGE") . " '{$id}'", 2, $action, "", "_MAY_SPLIT=1"); $flagnames = array("TEXT", "BIN", "DISABLED", "HTML", "READONLY", "WRITEABLE", "APPENDONLY", "SYSTEM"); $show = array("version", "author", "userid", "created", "lastmodified", "refs", "flags", "meta", "content"); #-- versions to show $v_start = $data["version"]; if ($pnum && $pnum <= $v_start) { $v_start = $pnum; } $v_end = $v_start - $ewiki_config["list_limit"] + 1; if ($pend && $pend <= $v_start) { $v_end = $pend; } $v_end = max($v_end, 1); #-- go # the very ($first) entry is rendered more verbosely than the others for ($v = $v_start, $first = 1; $v >= $v_end; $v--, $first = 0) { $current = ewiki_database("GET", array("id" => $id, "version" => $v)); if (!strlen(trim($current["id"])) || !$current["version"] || !strlen(trim($current["content"]))) { continue; } $o .= '<table class="version-info" cellpadding="2" cellspacing="1">' . "\n"; #-- additional info-actions $commands = ''; foreach ($ewiki_config["action_links"]["info"] as $thisaction => $title) { if (@$ewiki_plugins["action"][$thisaction] || @$ewiki_plugins["action_always"][$thisaction]) { ##### BEGIN MOODLE ADDITION ##### if ($commands) { $commands .= ' '; } $commands .= '<a href="' . ewiki_script($thisaction, $id, array("version" => $current["version"])) . '">' . get_string($title, "wiki") . '</a>'; ##### END MOODLE ADDITION ##### } } #-- print page database entry foreach ($show as $i) { $value = @$current[$i]; #-- show database {fields} differently if ($i == "meta") { continue; // MOODLE DOESN'T USE IT $str = ""; if ($first && $value) { foreach ($value as $n => $d) { $str .= s("{$n}: {$d}") . "<br />\n"; } } $value = $str; } elseif ($value >= UNIX_MILLENNIUM) { #-- {lastmodified}, {created} #### BEGIN MOODLE CHANGE $value = userdate($value); #$value = strftime("%c", $value); #### END MOODLE CHANGE } elseif ($i == "content") { continue; // MOODLE DOESN'T CARE $value = strlen(trim($value)) . " bytes"; $i = "content size"; } elseif ($first && $i == "refs" && !(EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING >= 2)) { $a = explode("\n", trim($value)); $ewiki_links = ewiki_database("FIND", $a); ewiki_merge_links($ewiki_links); foreach ($a as $n => $link) { $a[$n] = ewiki_link_regex_callback(array("{$link}"), "force_noimg"); } $value = trim(implode(", ", $a)); if (!$value) { continue; } } elseif (strpos($value, "\n") !== false) { #-- also for {refs} $value = str_replace("\n", ", ", trim($value)); if (!$value) { continue; } } elseif ($i == "version") { $value = '<a href="' . ewiki_script("", $id, array("version" => $value)) . '">' . $value . '</a> ' . "({$commands})"; } elseif ($i == "flags") { continue; // MOODLE DOESN'T USE IT $fstr = ""; for ($n = 0; $n < 32; $n++) { if ($value & 1 << $n) { if (!($s = $flagnames[$n])) { $s = "UU{$n}"; } $fstr .= $s . " "; } } $value = $fstr; } elseif ($i == "author") { continue; $ewiki_links = 1; $value = preg_replace_callback("/((\\w+:)?([" . EWIKI_CHARS_U . "]+[" . EWIKI_CHARS_L . "]+){2,}[\\w\\d]*)/", "ewiki_link_regex_callback", $value); } elseif ($i == "userid") { $i = 'author'; if ($user = $DB->get_record('user', array('id' => $value))) { if (!isset($COURSE->id)) { $COURSE->id = SITEID; } $picture = print_user_picture($user->id, $COURSE->id, $user->picture, false, true, true); $value = $picture . " <a href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&course={$COURSE->id}\">" . fullname($user) . "</a>"; } else { continue; //$value = @$current['author']; } } ##### BEGIN MOODLE ADDITION ##### $o .= '<tr class="page-' . $i . '"><td style="vertical-align:top;text-align:right;white-space: nowrap;"><b>' . ewiki_t($i) . ':</b></td>' . '<td>' . $value . "</td></tr>\n"; ##### END MOODLE ADDITION ##### } $o .= "</table><br /><br />\n"; } #-- page result split if ($v >= 1) { $o .= "<br />\n" . get_string('showversions', 'wiki') . ' ' . ewiki_chunked_page($action, $id, -1, $v, 1, 0, 0) . "\n <br />"; } return $o; }
function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames) { global $CFG; echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">'; echo "<tr><td class=\"userpicture\" valign=\"top\">"; print_user_picture($activity->user->userid, $courseid, $activity->user->picture); echo "</td><td>"; if ($detail) { $modname = $modnames[$activity->type]; echo '<div class="title">'; echo "<img src=\"{$CFG->modpixpath}/{$activity->type}/icon.gif\" " . "class=\"icon\" alt=\"{$modname}\" />"; echo "<a href=\"{$CFG->wwwroot}/mod/game/view.php?id={$activity->cmid}\">{$activity->name}</a>"; echo '</div>'; } echo '<div class="grade">'; echo get_string("attempt", "game") . " {$activity->content->attempt}: "; $grades = "({$activity->content->sumgrades} / {$activity->content->maxgrade})"; echo "<a href=\"{$CFG->wwwroot}/mod/game/review.php?attempt={$activity->content->attemptid}\">{$grades}</a>"; echo '</div>'; echo '<div class="user">'; echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$activity->user->userid}&course={$courseid}\">" . "{$activity->user->fullname}</a> - " . userdate($activity->timestamp); echo '</div>'; echo "</td></tr></table>"; return; }
function workshop_print_recent_mod_activity($activity, $course, $detail = false) { global $CFG; echo '<table border="0" cellpadding="3" cellspacing="0">'; if (!empty($activity->content->parent)) { $openformat = "<font size=\"2\"><i>"; $closeformat = "</i></font>"; } else { $openformat = "<b>"; $closeformat = "</b>"; } echo "<tr><td class=\"workshoppostpicture\" width=\"35\" valign=\"top\">"; print_user_picture($activity->user->userid, $course, $activity->user->picture); echo "</td><td>{$openformat}"; if ($detail) { echo "<img src=\"{$CFG->modpixpath}/{$activity->type}/icon.gif\" " . "class=\"icon\" alt=\"" . strip_tags(format_string($activity->name, true)) . "\" /> "; } echo "<a href=\"{$CFG->wwwroot}/mod/workshop/submissions.php?" . "id=" . $activity->cmid . "&action=showsubmission&sid=" . $activity->content->id . "\">" . $activity->content->title; echo "</a>{$closeformat}"; echo "<br /><font size=\"2\">"; echo "<a href=\"{$CFG->wwwroot}/user/view.php?id=" . $activity->user->userid . "&course=" . "{$course}\">" . $activity->user->fullname . "</a>"; echo " - " . userdate($activity->timestamp) . "</font></td></tr>"; echo "</table>"; return; }
/** * Prints a summary of a user in a nice little box. * * @uses $CFG * @uses $USER * @param user $user A {@link $USER} object representing a user * @param course $course A {@link $COURSE} object representing a course */ function print_user($user, $course, $messageselect = false, $return = false) { global $CFG, $USER; $output = ''; static $string; static $datestring; static $countries; $context = get_context_instance(CONTEXT_COURSE, $course->id); if (isset($user->context->id)) { $usercontext = $user->context; } else { $usercontext = get_context_instance(CONTEXT_USER, $user->id); } if (empty($string)) { // Cache all the strings for the rest of the page $string->email = get_string('email'); $string->city = get_string('city'); $string->lastaccess = get_string('lastaccess'); $string->activity = get_string('activity'); $string->unenrol = get_string('unenrol'); $string->loginas = get_string('loginas'); $string->fullprofile = get_string('fullprofile'); $string->role = get_string('role'); $string->name = get_string('name'); $string->never = get_string('never'); $datestring->day = get_string('day'); $datestring->days = get_string('days'); $datestring->hour = get_string('hour'); $datestring->hours = get_string('hours'); $datestring->min = get_string('min'); $datestring->mins = get_string('mins'); $datestring->sec = get_string('sec'); $datestring->secs = get_string('secs'); $datestring->year = get_string('year'); $datestring->years = get_string('years'); $countries = get_list_of_countries(); } /// Get the hidden field list if (has_capability('moodle/course:viewhiddenuserfields', $context)) { $hiddenfields = array(); } else { $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields)); } $output .= '<table class="userinfobox">'; $output .= '<tr>'; $output .= '<td class="left side">'; $output .= print_user_picture($user, $course->id, $user->picture, true, true); $output .= '</td>'; $output .= '<td class="content">'; $output .= '<div class="username">' . fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</div>'; $output .= '<div class="info">'; if (!empty($user->role)) { $output .= $string->role . ': ' . $user->role . '<br />'; } if ($user->maildisplay == 1 or $user->maildisplay == 2 and $course->id != SITEID and !isguest() or has_capability('moodle/course:viewhiddenuserfields', $context)) { $output .= $string->email . ': <a href="mailto:' . $user->email . '">' . $user->email . '</a><br />'; } if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) { $output .= $string->city . ': '; if ($user->city && !isset($hiddenfields['city'])) { $output .= $user->city; } if (!empty($countries[$user->country]) && !isset($hiddenfields['country'])) { if ($user->city && !isset($hiddenfields['city'])) { $output .= ', '; } $output .= $countries[$user->country]; } $output .= '<br />'; } if (!isset($hiddenfields['lastaccess'])) { if ($user->lastaccess) { $output .= $string->lastaccess . ': ' . userdate($user->lastaccess); $output .= ' (' . format_time(time() - $user->lastaccess, $datestring) . ')'; } else { $output .= $string->lastaccess . ': ' . $string->never; } } $output .= '</div></td><td class="links">'; //link to blogs if ($CFG->bloglevel > 0) { $output .= '<a href="' . $CFG->wwwroot . '/blog/index.php?userid=' . $user->id . '">' . get_string('blogs', 'blog') . '</a><br />'; } //link to notes if (!empty($CFG->enablenotes) and has_capability('moodle/notes:manage', $context) || has_capability('moodle/notes:view', $context)) { $output .= '<a href="' . $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&user='******'">' . get_string('notes', 'notes') . '</a><br />'; } if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) { $output .= '<a href="' . $CFG->wwwroot . '/course/user.php?id=' . $course->id . '&user='******'">' . $string->activity . '</a><br />'; } if (has_capability('moodle/role:assign', $context) and get_user_roles($context, $user->id, false)) { // I can unassing and user has some role $output .= '<a href="' . $CFG->wwwroot . '/course/unenrol.php?id=' . $course->id . '&user='******'">' . $string->unenrol . '</a><br />'; } if ($USER->id != $user->id && !session_is_loggedinas() && has_capability('moodle/user:loginas', $context) && !has_capability('moodle/site:doanything', $context, $user->id, false)) { $output .= '<a href="' . $CFG->wwwroot . '/course/loginas.php?id=' . $course->id . '&user='******'&sesskey=' . sesskey() . '">' . $string->loginas . '</a><br />'; } $output .= '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id . '">' . $string->fullprofile . '...</a>'; if (!empty($messageselect)) { $output .= '<br /><input type="checkbox" name="user' . $user->id . '" /> '; } $output .= '</td></tr></table>'; if ($return) { return $output; } else { echo $output; } }
/** * List conversations of either open or closed type for the current user * * Called when a user clicks the "Current Dialogues" or "Closed Dialogues" tabs * rendering those out directly as HTML inside a print_table() showing who the * conversation is with, what the subject is, how many entries there are, * how many are un-read and what the most recent post date is * * @param object $dialogue * @param int $groupid of the group to filter conversations by (default: 0) * @param string $type 'open' (default) or 'closed' * @todo remove the embedded style for 'th', make it a class driven thing in the theme */ function dialogue_list_conversations($dialogue, $groupid = 0, $type = 'open') { global $USER, $CFG; $condition = $type == 'closed' ? " closed='1' " : " closed='0' "; $tabid = $type == 'closed' ? 3 : 1; if (!($course = get_record('course', 'id', $dialogue->course))) { error('Course is misconfigured'); } if (!($cm = get_coursemodule_from_instance('dialogue', $dialogue->id, $course->id))) { error('Course Module ID was incorrect'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); $dialoguemanagers = array_keys(get_users_by_capability($context, 'mod/dialogue:manage')); echo '<style>th.header { text-align: left; }</style>'; require_once $CFG->libdir . '/tablelib.php'; $tablecolumns = array('picture', 'subject', 'fullname', 'total', 'unread', 'lastentry'); $tableheaders = array('', get_string('subject', 'dialogue'), get_string('fullname', ''), get_string('numberofentries', 'dialogue'), get_string('unread', 'dialogue'), get_string('lastentry', 'dialogue')); $table = new flexible_table('mod-dialogue-submissions'); $table->define_columns($tablecolumns); $table->define_headers($tableheaders); $table->define_baseurl($CFG->wwwroot . '/mod/dialogue/view.php?id=' . $cm->id . '&pane=' . $tabid); $table->sortable(true, 'subject'); $table->collapsible(false); //$table->column_suppress('picture'); // supress multiple subsequent row entries //$table->column_suppress('fullname'); $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'dialogue'); $table->set_attribute('class', 'conversations'); $table->set_attribute('width', '100%'); $table->setup(); $order = ''; // so we can filter the get_conversations() call later $namesort = ''; // if we want to sort by other calculated fields, e.g. first/last name if ($sort = $table->get_sql_sort('mod-dialogue-submissions')) { $sortparts = explode(',', $sort); $sqlsort = $sortparts[0]; if (strpos($sqlsort, 'subject') !== false) { $order = $sqlsort; } if (strpos($sqlsort, 'total') !== false) { $order = $sqlsort; } if (strpos($sqlsort, 'lastentry') !== false) { $order = $sqlsort; $order = str_replace('lastentry', 'c.timemodified', $order); } if (strpos($sqlsort, 'firstname') !== false) { $namesort = $sqlsort; } if (strpos($sqlsort, 'lastname') !== false) { $namesort = $sqlsort; } if (strpos($sqlsort, 'unread') !== false) { $namesort = $sqlsort; } } // list the conversations requiring a resonse from this user in full if ($conversations = dialogue_get_conversations($dialogue, $USER, $condition, $order, $groupid)) { foreach ($conversations as $conversation) { if (in_array($USER->id, $dialoguemanagers)) { if (!in_array($conversation->userid, $dialoguemanagers)) { if (!($with = get_record('user', 'id', $conversation->userid))) { error("User's record not found"); } } else { if (!($with = get_record('user', 'id', $conversation->recipientid))) { error("User's record not found"); } } } else { if ($USER->id != $conversation->userid) { if (!($with = get_record('user', 'id', $conversation->userid))) { error("User's record not found"); } } else { if (!($with = get_record('user', 'id', $conversation->recipientid))) { error("User's record not found"); } } } // save sortable field values for each conversation so can sort by them later $names[$conversation->id] = fullname($with); $unread[$conversation->id] = $conversation->total - $conversation->readings; $names_firstlast[$conversation->id] = $with->firstname . ' ' . $with->lastname; $names_lastfirst[$conversation->id] = $with->lastname . ' ' . $with->firstname; $photos[$conversation->id] = print_user_picture($with, $course->id, true, 0, true); $ids[$conversation->id] = $with->id; } // sort an array of conversations based on which field user clicked to sort in the UI $sortedvalues = $names; // default is sort by fullname from above switch ($namesort) { case 'firstname ASC': $sortedvalues = $names_firstlast; natcasesort($sortedvalues); break; case 'firstname DESC': $sortedvalues = $names_firstlast; natcasesort($sortedvalues); $sortedvalues = array_reverse($sortedvalues, true); break; case 'lastname ASC': $sortedvalues = $names_lastfirst; natcasesort($sortedvalues); break; case 'lastname DESC': $sortedvalues = $names_lastfirst; natcasesort($sortedvalues); $sortedvalues = array_reverse($sortedvalues, true); break; case 'unread ASC': $sortedvalues = $unread; asort($sortedvalues); break; case 'unread DESC': $sortedvalues = $unread; arsort($sortedvalues); break; } foreach ($sortedvalues as $cid => $val) { $conversation = $conversations[$cid]; if ($unread[$cid] > 0) { $unreadcount = '<span class="unread">' . $unread[$cid] . '</span>'; } else { $unreadcount = 0; } $profileurl = "{$CFG->wwwroot}/user/view.php?id=" . $ids[$conversation->id] . "&course={$dialogue->course}"; $entryurl = "{$CFG->wwwroot}/mod/dialogue/dialogues.php?id=" . $cm->id . "&action=printdialogue&cid=" . $cid; $row = array($photos[$conversation->id], "<a href='{$entryurl}'>" . $conversation->subject . '</a>', "<a href='{$profileurl}'>" . $names[$conversation->id] . '</a>', $conversation->total, $unreadcount, userdate($conversation->timemodified)); $table->add_data($row); } $table->print_html(); /// Print the whole table } }
error('Could not insert a chat message!'); } set_field('chat_users', 'lastmessageping', time(), 'sid', $chat_sid); add_to_log($course->id, 'chat', 'talk', "view.php?id={$cm->id}", $chat->id, $cm->id); } chat_delete_old_users(); redirect('index.php?id=' . $id . '&newonly=' . $newonly . '&last=' . $last); } } print_header("{$strchat}: {$course->shortname}: " . format_string($chat->name, true) . "{$groupname}", '', '', 'message'); echo '<div id="mod-chat-gui_basic">'; echo '<h1>' . get_string('participants') . '</h1>'; echo '<div id="participants"><ul>'; foreach ($chatusers as $chu) { echo '<li>'; print_user_picture($chu->id, $course->id, $chu->picture, 24, false, false, '', false); echo '<div class="userinfo">'; echo fullname($chu) . ' '; if ($idle = time() - $chu->lastmessageping) { echo '<span class="idle">' . $stridle . ' ' . format_time($idle) . '</span>'; } else { echo '<span class="idle" />'; } echo '</div>'; echo '</li>'; } echo '</ul></div>'; echo '<div id="send">'; echo '<form id="editing" method="post" action="index.php">'; $usehtmleditor = can_use_html_editor(); echo '<h1><label for="message">' . get_string('sendmessage', 'message') . '</label></h1>';
function survey_print_all_responses($cmid, $results, $courseid) { $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(print_user_picture($a->id, $courseid, $a->picture, false, true, false), "<a href=\"report.php?action=student&student={$a->id}&id={$cmid}\">" . fullname($a) . "</a>", userdate($a->time)); } print_table($table); }
/** * Display all the submissions ready for grading */ function display_submissions($message = '') { global $CFG, $db, $USER; 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('problemstatement_perpage', $perpage); set_user_preference('problemstatement_quickgrade', optional_param('quickgrade', 0, PARAM_BOOL)); }*/ /* next we get perpage and quickgrade (allow quick grade) params * from database */ $perpage = get_user_preferences('problemstatement_perpage', 10); $quickgrade = get_user_preferences('problemstatement_quickgrade', 0); $grading_info = grade_get_grades($this->course->id, 'mod', 'problemstatement', $this->problemstatement->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', 'problemstatement'); /// Some shortcuts to make the code read better $course = $this->course; $problemstatement = $this->problemstatement; $cm = $this->cm; $tabindex = 1; //tabindex for quick grading tabbing; Not working for dropdowns yet add_to_log($course->id, 'problemstatement', 'view submission', 'submissions.php?id=' . $this->problemstatement->id, $this->problemstatement->id, $this->cm->id); $navigation = build_navigation($this->strsubmissions, $this->cm); print_header_simple(format_string($this->problemstatement->name, true), "", $navigation, '', '', true, update_module_button($cm->id, $course->id, $this->strproblemstatement), 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 problemstatement /// 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 problemstatements if ($users = get_users_by_capability($context, 'mod/problemstatement: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', 'problemstatement'), get_string('lastmodified') . ' (' . $course->student . ')', get_string('lastmodified') . ' (' . $course->teacher . ')', 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-problemstatement-submissions'); $table->define_columns($tablecolumns); $table->define_headers($tableheaders); $table->define_baseurl($CFG->wwwroot . '/mod/problemstatement/submissions.php?id=' . $this->cm->id . '&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)) { print_heading(get_string('nosubmitusers', 'problemstatement')); 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.processed, s.succeeded '; $sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'problemstatement_submissions s ON u.id = s.userid AND s.problemstatement = ' . $this->problemstatement->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->problemstatement->grade); //echo $select.$sql.$sort; if (($ausers = get_records_sql($select . $sql . $sort, $table->get_page_start(), $table->get_page_size())) !== false) { $grading_info = grade_get_grades($this->course->id, 'mod', 'problemstatement', $this->problemstatement->id, array_keys($ausers)); foreach ($ausers as $auser) { $final_grade = $grading_info->items[0]->grades[$auser->id]; $grademax = $grading_info->items[0]->gradprocess_feedbackemax; $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->status;//($auser->timemarked > 0) && ($auser->timemarked >= $auser->timemodified); $picture = print_user_picture($auser, $course->id, $auser->picture, false, true); 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 problemstatement. ///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 . '"> </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) { $menu = choose_from_menu(make_grades_menu($this->problemstatement->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++); $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 . '"> </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) { $menu = choose_from_menu(make_grades_menu($this->problemstatement->grade), 'menprocess_feedbacku[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++); $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 { $msg = ""; $color = "#000000"; switch ($auser->processed) { case "0": $msg .= "unprocessed"; $color = "#AAAA00"; break; case "1": switch ($auser->succeeded) { case "4": //timeout //timeout case "6": //runtimeerror //runtimeerror case "2": //compilationerror //compilationerror case "5": //memoryout //memoryout case "0": $msg .= "failed"; $color = "#AA0000"; break; case "1": $msg .= "passed"; $color = "#00AA00"; break; case "3": $msg .= "internalerror"; $color = "#0000AA"; break; } break; case "2": $msg .= "waiting"; $color = "#00AAAA"; break; } //$comment='<div id="com'.$auser->id.'">'.shorten_text(strip_tags($auser->submissioncomment),15).'</div>'; $comment = '<div id="com' . $auser->id . '">' . '<div class="files"><font color="' . $color . '"><strong>' . $msg . '</strong></font></div>' . '</div>'; } } } else { $studentmodified = '<div id="ts' . $auser->id . '"> </div>'; $teachermodified = '<div id="tt' . $auser->id . '"> </div>'; $status = '<div id="st' . $auser->id . '"> </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 $menu = choose_from_menu(make_grades_menu($this->problemstatement->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++); $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 . '"> </div>'; } } } if (empty($auser->processed)) { /// Confirm we have exclusively 0 or 1 //$auser->status = 0; } else { //$auser->status = 1; } $buttontext = $auser->processed == 1 ? $strupdate : $strgrade; ///No more buttons, we use popups ;-). $popup_url = '/mod/problemstatement/submissions.php?id=' . $this->cm->id . '&userid=' . $auser->id . '&mode=single' . '&offset=' . $offset++; $button = link_to_popup_window($popup_url, 'grade' . $auser->id, $buttontext, 600, 780, $buttontext, 'none', true, 'button' . $auser->id); $status = '<div id="up' . $auser->id . '" class="s' . $auser->processed . '">' . $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 .= ' '; $outcomes .= choose_from_menu($options, 'outcome_' . $n . '[' . $auser->id . ']', $outcome->grades[$auser->id]->grade, get_string('nooutcome', 'grades'), '', 0, true, false, 0, 'outcome_' . $n . '_' . $auser->id); } $outcomes .= '</div>'; } } $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&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('problemstatement_mailinfo', 1) ? 'checked="checked"' : ''; echo '<div class="fgcontrols">'; echo '<div class="emailnotification">'; echo '<label for="mailinfo">' . get_string('enableemailnotification', 'problemstatement') . '</label>'; echo '<input type="hidden" name="mailinfo" value="0" />'; echo '<input type="checkbox" id="mailinfo" name="mailinfo" value="1" ' . $lastmailinfo . ' />'; helpbutton('emailnotification', get_string('enableemailnotification', 'problemstatement'), 'problemstatement') . '</p></div>'; echo '</div>'; echo '<div class="fastgbutton"><input type="submit" name="fastg" value="' . get_string('saveallfeedback', 'problemstatement') . '" /></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', 'problemstatement') . '</label>'; echo '</td>'; echo '<td>'; echo '<input type="text" id="perpage" name="perpage" size="1" value="' . $perpage . '" />'; helpbutton('pagesize', get_string('pagesize', 'problemstatement'), 'problemstatement'); echo '</td></tr>'; echo '<tr><td>'; echo '<label for="quickgrade">' . get_string('quickgrade', 'problemstatement') . '</label>'; echo '</td>'; echo '<td>'; $checked = $quickgrade ? 'checked="checked"' : ''; echo '<input type="checkbox" id="quickgrade" name="quickgrade" value="1" ' . $checked . ' />'; helpbutton('quickgrade', get_string('quickgrade', 'problemstatement'), 'problemstatement') . '</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 print_footer($this->course); }