예제 #1
0
 /**
  * Test for the forum email renderable postdate.
  *
  * @dataProvider postdate_provider
  *
  * @param array  $globalconfig      The configuration to set on $CFG
  * @param array  $forumconfig       The configuration for this forum
  * @param array  $postconfig        The configuration for this post
  * @param array  $discussionconfig  The configuration for this discussion
  * @param string $expectation       The expected date
  */
 public function test_postdate($globalconfig, $forumconfig, $postconfig, $discussionconfig, $expectation)
 {
     global $CFG, $DB;
     $this->resetAfterTest(true);
     // Apply the global configuration.
     foreach ($globalconfig as $key => $value) {
         $CFG->{$key} = $value;
     }
     // Create the fixture.
     $user = $this->getDataGenerator()->create_user();
     $course = $this->getDataGenerator()->create_course();
     $forum = $this->getDataGenerator()->create_module('forum', (object) array('course' => $course->id));
     $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
     $this->getDataGenerator()->enrol_user($user->id, $course->id);
     // Create a new discussion.
     $discussion = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion((object) array_merge($discussionconfig, array('course' => $course->id, 'forum' => $forum->id, 'userid' => $user->id)));
     // Apply the discussion configuration.
     // Some settings are ignored by the generator and must be set manually.
     $discussion = $DB->get_record('forum_discussions', array('id' => $discussion->id));
     foreach ($discussionconfig as $key => $value) {
         $discussion->{$key} = $value;
     }
     $DB->update_record('forum_discussions', $discussion);
     // Apply the post configuration.
     // Some settings are ignored by the generator and must be set manually.
     $post = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
     foreach ($postconfig as $key => $value) {
         $post->{$key} = $value;
     }
     $DB->update_record('forum_posts', $post);
     // Create the renderable.
     $renderable = new mod_forum\output\forum_post_email($course, $cm, $forum, $discussion, $post, $user, $user, true);
     // Check the postdate matches our expectations.
     $this->assertEquals(userdate($expectation, "", \core_date::get_user_timezone($user)), $renderable->get_postdate());
 }
예제 #2
0
 /**
  * Return comments by pages
  * @param int $page
  * @return mixed
  */
 function get_comments($page)
 {
     global $DB, $CFG, $USER;
     $params = array();
     if ($page == 0) {
         $start = 0;
     } else {
         $start = $page * $this->perpage;
     }
     $sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated\n            FROM {comments} c, {user} u\n            WHERE u.id=c.userid ORDER BY c.timecreated ASC";
     $comments = array();
     $formatoptions = array('overflowdiv' => true);
     if ($records = $DB->get_records_sql($sql, array(), $start, $this->perpage)) {
         foreach ($records as $item) {
             $item->fullname = fullname($item);
             $item->time = userdate($item->timecreated);
             $item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
             $comments[] = $item;
             unset($item->firstname);
             unset($item->lastname);
             unset($item->timecreated);
         }
     }
     return $comments;
 }
 protected function readquestions($lines)
 {
     // For this class the method has been simplified as
     // there can never be more than one question for a
     // multianswer import
     $questions = array();
     $questiontext = array();
     $questiontext['text'] = implode('', $lines);
     $questiontext['format'] = 0;
     $questiontext['itemid'] = '';
     $question = qtype_multianswer_extract_question($questiontext);
     $question->questiontext = $question->questiontext['text'];
     $question->questiontextformat = 0;
     $question->qtype = MULTIANSWER;
     $question->generalfeedback = '';
     $question->course = $this->course;
     if (!empty($question)) {
         $name = html_to_text(implode(' ', $lines));
         $name = preg_replace('/{[^}]*}/', '', $name);
         $name = trim($name);
         if ($name) {
             $question->name = shorten_text($name, 45);
         } else {
             // We need some name, so use the current time, since that will be
             // reasonably unique.
             $question->name = userdate(time());
         }
         $questions[] = $question;
     }
     return $questions;
 }
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";
    }
}
 public function definition()
 {
     global $CFG, $USER;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $attforsession = $this->_customdata['session'];
     $attblock = $this->_customdata['attendance'];
     $statuses = $attblock->get_statuses();
     $mform->addElement('hidden', 'sessid', null);
     $mform->setType('sessid', PARAM_INT);
     $mform->setConstant('sessid', $attforsession->id);
     $mform->addElement('hidden', 'sesskey', null);
     $mform->setType('sesskey', PARAM_INT);
     $mform->setConstant('sesskey', sesskey());
     // Set a title as the date and time of the session.
     $sesstiontitle = userdate($attforsession->sessdate, get_string('strftimedate')) . ' ' . userdate($attforsession->sessdate, get_string('strftimehm', 'mod_attendance'));
     $mform->addElement('header', 'session', $sesstiontitle);
     // If a session description is set display it.
     if (!empty($attforsession->description)) {
         $mform->addElement('html', $attforsession->description);
     }
     // Create radio buttons for setting the attendance status.
     $radioarray = array();
     foreach ($statuses as $status) {
         $radioarray[] =& $mform->createElement('radio', 'status', '', $status->description, $status->id, array());
     }
     // Add the radio buttons as a control with the user's name in front.
     $mform->addGroup($radioarray, 'statusarray', $USER->firstname . ' ' . $USER->lastname . ':', array(''), false);
     $mform->addRule('statusarray', get_string('attendancenotset', 'attendance'), 'required', '', 'client', false, false);
     $this->add_action_buttons();
 }
예제 #6
0
 function _createElements()
 {
     $this->_elements = array();
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = $i;
     }
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
     }
     for ($i = $this->_options['startyear']; $i <= $this->_options['stopyear']; $i++) {
         $years[$i] = $i;
     }
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true);
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true);
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true);
     // If optional we add a checkbox which the user can use to turn if on
     if ($this->_options['optional']) {
         $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true);
     }
     foreach ($this->_elements as $element) {
         if (method_exists($element, 'setHiddenLabel')) {
             $element->setHiddenLabel(true);
         }
     }
 }
예제 #7
0
 function execute($data, $row, $user, $courseid, $starttime = 0, $endtime = 0)
 {
     global $DB, $CFG;
     if ($cm = $DB->get_record('course_modules', array('id' => $data->cmid))) {
         $mod = $DB->get_record('modules', array('id' => $cm->module));
         if ($instance = $DB->get_record("{$mod->name}", array('id' => $cm->instance))) {
             $libfile = "{$CFG->dirroot}/mod/{$mod->name}/lib.php";
             if (file_exists($libfile)) {
                 require_once $libfile;
                 $user_outline = $mod->name . "_user_outline";
                 if (function_exists($user_outline)) {
                     if ($course = $DB->get_record('course', array('id' => $this->report->courseid))) {
                         $result = $user_outline($course, $row, $mod, $instance);
                         if ($result) {
                             $returndata = '';
                             if (isset($result->info)) {
                                 $returndata .= $result->info . ' ';
                             }
                             if ((!isset($data->donotshowtime) || !$data->donotshowtime) && !empty($result->time)) {
                                 $returndata .= userdate($result->time);
                             }
                             return $returndata;
                         }
                     }
                 }
             }
         }
     }
     return '';
 }
예제 #8
0
    public function get_cells() {
        $this->init_cells();
        foreach ($this->reportdata->sessions as $sess) {
            if (array_key_exists($sess->id, $this->reportdata->sessionslog[$this->user->id])) {
                $statusid = $this->reportdata->sessionslog[$this->user->id][$sess->id]->statusid;
                if (array_key_exists($statusid, $this->reportdata->statuses)) {
                    $this->construct_existing_status_cell($this->reportdata->statuses[$statusid]->acronym);
                } else {
                    $this->construct_hidden_status_cell($this->reportdata->allstatuses[$statusid]->acronym);
                }
            } else {
                if ($this->user->enrolmentstart > $sess->sessdate) {
                    $starttext = get_string('enrolmentstart', 'local_attendance', userdate($this->user->enrolmentstart, '%d.%m.%Y'));
                    $this->construct_enrolments_info_cell($starttext);
                } else if ($this->user->enrolmentend and $this->user->enrolmentend < $sess->sessdate) {
                    $endtext = get_string('enrolmentend', 'local_attendance', userdate($this->user->enrolmentend, '%d.%m.%Y'));
                    $this->construct_enrolments_info_cell($endtext);
                } else if (!$this->user->enrolmentend and $this->user->enrolmentstatus == ENROL_USER_SUSPENDED) {
                    // No enrolmentend and ENROL_USER_SUSPENDED.
                    $suspendext = get_string('enrolmentsuspended', 'local_attendance', userdate($this->user->enrolmentend, '%d.%m.%Y'));
                    $this->construct_enrolments_info_cell($suspendext);
                } else {
                    if ($sess->groupid == 0 or array_key_exists($sess->groupid, $this->reportdata->usersgroups[$this->user->id])) {
                        $this->construct_not_taken_cell('?');
                    } else {
                        $this->construct_not_existing_for_user_session_cell('');
                    }
                }
            }
        }
        $this->finalize_cells();

        return $this->cells;
    }
 public function definition()
 {
     $mform =& $this->_form;
     $mform->addElement('header', 'addactivity', get_string('addactivity', 'report_cpd'));
     $mform->addElement('hidden', 'cpdyearid', $this->_customdata['cpdyearid']);
     $mform->addElement('hidden', 'process', '1');
     if ($this->_customdata['cpdid']) {
         // This updates a CPD Report
         $mform->addElement('hidden', 'id', $this->_customdata['cpdid']);
     }
     $mform->addElement('textarea', 'objective', get_string('objective', 'report_cpd'), array('rows' => '2', 'cols' => '40'));
     $mform->addElement('textarea', 'development_need', get_string('developmentneed', 'report_cpd'), array('rows' => '2', 'cols' => '40'));
     if ($this->_customdata['activity_types']) {
         $mform->addElement('select', 'activitytypeid', get_string('activitytype', 'report_cpd'), $this->_customdata['activity_types']);
     }
     $mform->addElement('textarea', 'activity', get_string('activityplanned', 'report_cpd'), array('rows' => '2', 'cols' => '40'));
     // Get CPD start and end years
     $startyear = date('Y') - 5;
     $endyear = date('Y') + 5;
     if ($this->_customdata['cpdyear']) {
         $startyear = date('Y', $this->_customdata['cpdyear']->startdate);
         $endyear = date('Y', $this->_customdata['cpdyear']->enddate);
     }
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = $i;
     }
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
     }
     for ($i = $startyear; $i <= $endyear; $i++) {
         $years[$i] = $i;
     }
     $startdate[] = $mform->createElement('select', 'startdate[d]', '', $days);
     $startdate[] = $mform->createElement('select', 'startdate[m]', '', $months);
     $startdate[] = $mform->createElement('select', 'startdate[Y]', '', $years);
     $mform->addGroup($startdate, 'startdate', get_string('datestart', 'report_cpd'), array(' '), false);
     $duedate[] = $mform->createElement('select', 'duedate[d]', '', $days);
     $duedate[] = $mform->createElement('select', 'duedate[m]', '', $months);
     $duedate[] = $mform->createElement('select', 'duedate[Y]', '', $years);
     $mform->addGroup($duedate, 'duedate', get_string('dateend', 'report_cpd'), array(' '), false);
     if ($this->_customdata['statuses']) {
         $mform->addElement('select', 'statusid', get_string('status', 'report_cpd'), $this->_customdata['statuses']);
     }
     $hours = null;
     $minutes = null;
     for ($i = 1; $i <= 20; $i++) {
         $hours[$i] = $i;
     }
     for ($i = 15; $i <= 45; $i += 15) {
         $minutes[$i] = $i;
     }
     $timetaken[] = $mform->createElement('select', 'timetaken[hours]', '', array('' => '--') + $hours);
     $timetaken[] = $mform->createElement('select', 'timetaken[minutes]', '', array('' => '--') + $minutes);
     $mform->addGroup($timetaken, 'timetaken', get_string('timetaken', 'report_cpd'), ':', false);
     $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('update'));
     $buttonarray[] = $mform->createElement('reset', '', get_string('clear', 'report_cpd'));
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     $mform->closeHeaderBefore('buttonar');
     //$mform->addRule('objective', 'Please enter an objective.', 'required', null, 'client');
 }
예제 #10
0
파일: locallib.php 프로젝트: nmicha/moodle
 /**
  * Return comments by pages
  *
  * @global moodle_database $DB
  * @param int $page
  * @return array An array of comments
  */
 function get_comments($page)
 {
     global $DB;
     if ($page == 0) {
         $start = 0;
     } else {
         $start = $page * $this->perpage;
     }
     $comments = array();
     $sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated\n                  FROM {comments} c\n                  JOIN {user} u\n                       ON u.id=c.userid\n              ORDER BY c.timecreated ASC";
     $rs = $DB->get_recordset_sql($sql, null, $start, $this->perpage);
     $formatoptions = array('overflowdiv' => true);
     foreach ($rs as $item) {
         // Set calculated fields
         $item->fullname = fullname($item);
         $item->time = userdate($item->timecreated);
         $item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
         // Unset fields not related to the comment
         unset($item->firstname);
         unset($item->lastname);
         unset($item->timecreated);
         // Record the comment
         $comments[] = $item;
     }
     $rs->close();
     return $comments;
 }
예제 #11
0
 function display_browse_field($recordid, $template)
 {
     global $CFG;
     if ($content = get_field('data_content', 'content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
         return userdate($content, get_string('strftimedate'), 0);
     }
 }
예제 #12
0
function block_campusclash_print_page($campusclash, $return = false)
{
    //Add Page Title
    global $OUTPUT, $COURSE;
    $display = $OUTPUT->heading($campusclash->pagetitle);
    //Open a box
    $display .= $OUTPUT->box_start();
    //Display the Date
    if ($campusclash->displaydate) {
        $display .= html_writer::start_tag('div', array('class' => 'displaydate'));
        $display .= userdate($campusclash->displaydate);
        $display .= html_writer::end_tag('div');
    }
    //Display Text
    $display .= clean_text($campusclash->displaytext);
    //close the box
    $display .= $OUTPUT->box_end();
    //Display the Picture
    if ($campusclash->displaypicture) {
        $display .= $OUTPUT->box_start();
        $images = block_campusclash_images();
        $display .= $images[$campusclash->picture];
        $display .= html_writer::start_tag('p');
        $display .= clean_text($campusclash->description);
        $display .= html_writer::end_tag('p');
        $display .= $OUTPUT->box_end();
    }
    //Check to ensure that it was set before trying to output it
    if ($return) {
        return $display;
    } else {
        echo $display;
    }
}
 /**
  * This function is called for each data row to allow processing of the
  * username value.
  *
  * @param object $values Contains object with all the values of record.
  * @return $string Return username with link to profile or username only
  *     when downloading.
  */
 function col_timecreated($values)
 {
     if ($values->timecreated > 0) {
         return userdate($values->timecreated);
     }
     return '';
 }
예제 #14
0
function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode = "", $hook = "", $printicons = 1, $aliases = true)
{
    global $USER;
    if ($entry) {
        echo '<table class="glossarypost faq" cellspacing="0">';
        echo '<tr valign="top">';
        echo '<th class="entryheader">';
        $entry->course = $course->id;
        echo '<div class="concept">' . get_string('question', 'glossary') . ': ';
        glossary_print_entry_concept($entry);
        echo '</div>';
        echo '<span class="time">(' . get_string('lastedited') . ': ' . userdate($entry->timemodified) . ')</span>';
        echo '</th>';
        echo '<td class="entryattachment">';
        glossary_print_entry_approval($cm, $entry, $mode);
        echo '</td>';
        echo '</tr>';
        echo "\n<tr>";
        echo '<td colspan="2" class="entry">';
        echo '<b>' . get_string('answer', 'glossary') . ':</b> ';
        glossary_print_entry_definition($entry, $glossary, $cm);
        glossary_print_entry_attachment($entry, $cm, 'html');
        echo '</td></tr>';
        echo '<tr valign="top"><td colspan="3" class="entrylowersection">';
        glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $aliases);
        echo '</td></tr></table>';
    } else {
        echo '<div style="text-align:center">';
        print_string('noentry', 'glossary');
        echo '</div>';
    }
}
 public function definition()
 {
     global $CFG, $OUTPUT, $DB, $USER;
     $publication =& $this->_customdata['publication'];
     $this->instance = $publication->get_instance();
     $userids =& $this->_customdata['userids'];
     $mform = $this->_form;
     if ($publication->get_instance()->allowsubmissionsfromdate) {
         $mform->addElement('static', 'fromdate', get_string('allowsubmissionsfromdate', 'publication'), userdate($publication->get_instance()->allowsubmissionsfromdate));
     }
     if ($publication->get_instance()->duedate) {
         $mform->addElement('static', 'duedate', get_string('duedate', 'publication'), userdate($publication->get_instance()->duedate));
         $finaldate = $publication->get_instance()->duedate;
     }
     $mform->addElement('date_time_selector', 'extensionduedate', get_string('extensionduedate', 'publication'), array('optional' => true));
     $mform->setDefault('extensionduedate', $finaldate);
     if (count($userids) == 1) {
         $extensionduedate = $publication->user_extensionduedate($userids[0]);
         if ($extensionduedate) {
             $mform->setDefault('extensionduedate', $extensionduedate);
         }
     }
     $mform->addElement('hidden', 'id', $publication->get_coursemodule()->id);
     $mform->setType('id', PARAM_INT);
     foreach ($userids as $idx => $userid) {
         $mform->addElement('hidden', 'userids[' . $idx . ']', $userid);
         $mform->setType('userids[' . $idx . ']', PARAM_INT);
     }
     $this->add_action_buttons(true, get_string('save_changes', 'publication'));
 }
 /**
  * Defines the elements of the form used to mark a quiz submission.
  */
 public function definition()
 {
     global $OUTPUT;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'attemptid');
     $mform->setType('attemptid', PARAM_INT);
     $mform->addElement('hidden', 'questionid');
     $mform->setType('questionid', PARAM_INT);
     $mform->addElement('hidden', 'sesskey', sesskey());
     $mform->setType('sesskey', PARAM_ALPHANUM);
     $mform->addElement('static', 'picture', $OUTPUT->user_picture($this->_customdata->user), fullname($this->_customdata->user, true) . '<br/>' . userdate($this->_customdata->submission->timemodified) . $this->_customdata->lateness);
     // Now come multiple (possibly) question comment fields.
     // Use $attemptobj->get_questions($arrayofquestionis) for this.
     foreach ($this->_customdata->questions as $questionid => $question) {
         $mform->addElement('header', 'question' . $questionid, get_string('question', 'modulename'));
         // Display question text.
         // Display user's answer.
         // Display comment form.
         $mform->addElement('editor', 'comment[' . $questionid . ']', get_string('comment', 'quiz') . ':', null, $this->get_editor_options());
         // Display grade selector.
         $grademenu = make_grades_menu($question->grade);
         $grademenu['-1'] = get_string('nograde');
         // TODO broken!
         $attributes = array();
         $mform->addElement('select', 'grade[' . $questionid . ']', get_string('grade') . ':', $grademenu, $attributes);
         // TODO set default to existing grade?
         $mform->setDefault('grade[' . $questionid . ']', -1);
     }
 }
 /**
  * This function writes out the message div so the message can be viewed.
  *
  * @param object $record This is the DB record for the message to write out
  * @param string $outputbuffer The output html code will be written here.
  *
  */
 private function write_message_div($record, &$outputbuffer)
 {
     global $DB, $USER;
     $timesent = $record->timesent;
     $time = userdate($timesent, '%H:%M');
     $dates = usergetdate($timesent);
     $userfrom = block_course_message_map_ids_to_names($record->useridfrom, 'inbox');
     $userto = block_course_message_map_ids_to_names($record->recipients, 'sent');
     $outputbuffer .= "<div class='message_div_bar'><div class='message_bar_to'><span class='label'>To:</span>\n                          <span class='field'> {$userto}</span></div>";
     if ($record->carboncopy !== null) {
         $carboncopy = block_course_message_map_ids_to_names($record->carboncopy, 'sent');
         $outputbuffer .= "<div class='message_bar_to'><span class='label'>CC:</span>\n                              <span class='field'> {$carboncopy}</span></div>";
     }
     $outputbuffer .= "<div class='message_bar_from'><span class='label'>From:</span><span class='field'> {$userfrom}</span>\n                          </div><div class='message_bar_time'>{$time} {$dates['month']} {$dates['mday']}</div>";
     $outputbuffer .= "<div class='clear'></div></div>";
     $outputbuffer .= "<div class='message_container";
     if ($USER->id == $record->useridfrom) {
         $outputbuffer .= " usersent'>";
     } else {
         $outputbuffer .= " userrecieved'>";
     }
     // Message has already been cleaned when sent.
     $outputbuffer .= "<div class='message_div_body'>{$record->message}</div>";
     $this->process_attachment($record, $outputbuffer);
     // Close the message container div.
     $outputbuffer .= "</div>";
 }
예제 #18
0
 protected function get_other_values(renderer_base $output)
 {
     $other = array();
     if (!empty($this->related['actionuser'])) {
         $exporter = new user_summary_exporter($this->related['actionuser']);
         $actionuser = $exporter->export($output);
         $other['actionuser'] = $actionuser;
     }
     $other['description'] = $this->persistent->get_description();
     $other['userdate'] = userdate($this->persistent->get_timecreated());
     if ($this->persistent->get_grade() === null) {
         $gradename = '-';
     } else {
         $gradename = $this->related['scale']->scale_items[$this->persistent->get_grade() - 1];
     }
     $other['gradename'] = $gradename;
     // Try to guess the user from the user competency.
     $userid = null;
     if ($this->related['usercompetency']) {
         $userid = $this->related['usercompetency']->get_userid();
     } else {
         if ($this->related['usercompetencyplan']) {
             $userid = $this->related['usercompetencyplan']->get_userid();
         } else {
             $uc = user_competency::get_record(['id' => $this->persistent->get_usercompetencyid()]);
             $userid = $uc->get_userid();
         }
     }
     $other['candelete'] = evidence::can_delete_user($userid);
     return $other;
 }
예제 #19
0
 public function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG, $PAGE;
     $d = $discussion->get_id();
     $forum = $discussion->get_forum();
     $PAGE->set_pagelayout('embedded');
     $out = mod_forumng_utils::get_renderer();
     print $out->header();
     $backlink = new moodle_url('/mod/forumng/discuss.php', $discussion->get_link_params_array());
     print html_writer::start_tag('div', array('class' => 'forumng-printable-header'));
     print html_writer::tag('div', link_arrow_left($discussion->get_subject(), $backlink), array('class' => 'forumng-printable-backlink'));
     print html_writer::tag('div', get_string('printedat', 'forumngfeature_print', userdate(time())), array('class' => 'forumng-printable-date'));
     print html_writer::tag('div', '', array('class' => 'clearer'));
     print "\n";
     print $out->box(get_string('back', 'forumngfeature_print', $backlink->out()), 'generalbox forumng-donotprint');
     print html_writer::start_tag('div', array('class' => 'forumng-showprintable'));
     if ($all) {
         print $out->render_discussion($discussion, array(mod_forumng_post::OPTION_NO_COMMANDS => true, mod_forumng_post::OPTION_CHILDREN_EXPANDED => true, mod_forumng_post::OPTION_PRINTABLE_VERSION => true));
     } else {
         $allhtml = '';
         $alltext = '';
         $discussion->build_selected_posts_email($selected, $alltext, $allhtml, array(mod_forumng_post::OPTION_PRINTABLE_VERSION));
         print $allhtml;
     }
     print html_writer::end_tag('div');
     $forum->print_js(0, false);
     print $out->footer();
 }
 public function definition()
 {
     global $OUTPUT;
     $mform = $this->_form;
     $user = $this->_customdata['user'];
     $lastupdate = $this->_customdata['lastupdate'];
     $dategraded = $this->_customdata['dategraded'];
     // Hidden params.
     $mform->addElement('hidden', 'userid', 0);
     $mform->setType('userid', PARAM_INT);
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('static', 'picture', $OUTPUT->user_picture($user), fullname($user, true) . '<br/>' . get_string('lastupdated', 'mod_giportfolio') . date('l jS \\of F Y ', $lastupdate));
     $this->add_grades_section();
     $mform->addElement('header', 'Feed Back', get_string('feedback', 'grades'));
     $mform->addElement('textarea', 'feedback', get_string('feedback', 'grades'), 'wrap="virtual" rows="10" cols="50"');
     if ($dategraded) {
         $datestring = userdate($dategraded) . "&nbsp; (" . format_time(time() - $dategraded) . ")";
         $mform->addElement('header', 'Last Grade', get_string('lastgrade', 'assignment'));
         $mform->addElement('static', 'lastgrade', get_string('lastgrade', 'mod_giportfolio') . ':', $datestring);
     }
     // Buttons.
     $this->add_action_buttons();
     $mform->setDisableShortforms(true);
 }
예제 #21
0
 /**
  * Called to define this moodle form
  *
  * @return void
  */
 public function definition()
 {
     global $DB;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $sessionid = $this->_customdata['sessionid'];
     if (!($sess = $DB->get_record('attcontrol_sessions', array('id' => $sessionid)))) {
         error('No such session in this course');
     }
     $dhours = floor($sess->duration / HOURSECS);
     $dmins = floor(($sess->duration - $dhours * HOURSECS) / MINSECS);
     $defopts = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext);
     $data = array('sessiondate' => $sess->sessdate, 'durtime' => array('hours' => $dhours, 'minutes' => $dmins), 'description' => $sess->description);
     $mform->addElement('header', 'general', get_string('changesession', 'attcontrol'));
     $mform->addElement('static', 'olddate', get_string('olddate', 'attcontrol'), userdate($sess->sessdate, get_string('strftimedmyhm', 'attcontrol')));
     $mform->addElement('date_time_selector', 'sessiondate', get_string('newdate', 'attcontrol'));
     for ($i = 0; $i <= 23; $i++) {
         $hours[$i] = sprintf("%02d", $i);
     }
     for ($i = 0; $i < 60; $i += 5) {
         $minutes[$i] = sprintf("%02d", $i);
     }
     $durselect[] =& $mform->createElement('select', 'hours', '', $hours);
     $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true);
     $mform->addGroup($durselect, 'durtime', get_string('duration', 'attcontrol'), array(' '), true);
     $mform->addElement('textarea', 'description', get_string("description", "attcontrol"), 'wrap="virtual" rows="10" cols="100"');
     $mform->setDefaults($data);
     $submit_string = get_string('update', 'attcontrol');
     $this->add_action_buttons(true, $submit_string);
 }
예제 #22
0
function block_advance_print_page($advance, $return = false)
{
    //add page title
    global $OUTPUT, $COURSE;
    $display = $OUTPUT->heading($advance->pagetitle);
    $display .= $OUTPUT->box_start();
    //date display
    if ($advance->displaydate) {
        $display .= html_writer::start_tag('div', array('class' => 'advance displaydate'));
        $display .= userdate($advance->displaydate);
        $display .= html_writer::end_tag('div');
    }
    //display text
    $display .= clean_text($advance->displaytext);
    //close the box
    $display .= $OUTPUT->box_end();
    //display picture
    if ($advance->displaypicture) {
        $display .= $OUTPUT->box_start();
        $images = block_advance_images();
        $display .= $images[$advance->picture];
        $display .= html_writer::start_tag('p');
        $display .= clean_text($advance->description);
        $display .= html_writer::end_tag('p');
        $display .= $OUTPUT->box_end();
    }
    //display it
    if ($return) {
        return $display;
    } else {
        echo $display;
    }
}
예제 #23
0
 public function get_listing($path = '', $page = '')
 {
     global $CFG, $OUTPUT;
     $list = array();
     $list['list'] = array();
     // the management interface url
     $list['manage'] = false;
     // dynamically loading
     $list['dynload'] = true;
     // the current path of this list.
     // set to true, the login link will be removed
     $list['nologin'] = true;
     // set to true, the search button will be removed
     $list['nosearch'] = true;
     $tree = array();
     if (empty($path)) {
         $buckets = $this->s->listBuckets();
         foreach ($buckets as $bucket) {
             $folder = array('title' => $bucket, 'children' => array(), 'thumbnail' => $OUTPUT->old_icon_url('f/folder-32'), 'path' => $bucket);
             $tree[] = $folder;
         }
     } else {
         $contents = $this->s->getBucket($path);
         foreach ($contents as $file) {
             $info = $this->s->getObjectInfo($path, baseName($file['name']));
             $tree[] = array('title' => $file['name'], 'size' => $file['size'], 'date' => userdate($file['time']), 'source' => $path . '/' . $file['name'], 'thumbnail' => $OUTPUT->old_icon_url(file_extension_icon($file['name'], 32)));
         }
     }
     $list['list'] = $tree;
     return $list;
 }
예제 #24
0
    public function test_cannot_review_message() {
        $quiz = new stdClass();
        $quiz->reviewattempt = 0x10010;
        $quiz->timeclose = 0;
        $quiz->attempts = 0;
        $quiz->questions = '1,2,0,3,4,0';

        $cm = new stdClass();
        $cm->id = 123;

        $quizobj = new quiz($quiz, $cm, new stdClass(), false);

        $this->assertEqual('',
                $quizobj->cannot_review_message(mod_quiz_display_options::DURING));
        $this->assertEqual('',
                $quizobj->cannot_review_message(mod_quiz_display_options::IMMEDIATELY_AFTER));
        $this->assertEqual(get_string('noreview', 'quiz'),
                $quizobj->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN));
        $this->assertEqual(get_string('noreview', 'quiz'),
                $quizobj->cannot_review_message(mod_quiz_display_options::AFTER_CLOSE));

        $closetime = time() + 10000;
        $quiz->timeclose = $closetime;
        $quizobj = new quiz($quiz, $cm, new stdClass(), false);

        $this->assertEqual(get_string('noreviewuntil', 'quiz', userdate($closetime)),
                $quizobj->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN));
    }
 /**
  * Get criteria details for displaying to users
  *
  * @return string
  */
 public function get_details($short = '')
 {
     global $DB, $OUTPUT;
     $output = array();
     foreach ($this->params as $p) {
         $coursename = $DB->get_field('course', 'fullname', array('id' => $p['course']));
         if (!$coursename) {
             $str = $OUTPUT->error_text(get_string('error:nosuchcourse', 'badges'));
         } else {
             $str = html_writer::tag('b', '"' . $coursename . '"');
             if (isset($p['bydate'])) {
                 $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig')));
             }
             if (isset($p['grade'])) {
                 $str .= get_string('criteria_descr_grade', 'badges', $p['grade']);
             }
         }
         $output[] = $str;
     }
     if ($short) {
         return implode(', ', $output);
     } else {
         return html_writer::alist($output, array(), 'ul');
     }
 }
예제 #26
0
 /**
  * Do the job.
  * Throw exceptions on errors (the job will be retried).
  */
 public function execute()
 {
     global $CFG;
     $timenow = time();
     // Run stats as at the end because they are known to take very long time on large sites.
     if (!empty($CFG->enablestats) and empty($CFG->disablestatsprocessing)) {
         require_once $CFG->dirroot . '/lib/statslib.php';
         // Check we're not before our runtime.
         $timetocheck = stats_get_base_daily() + $CFG->statsruntimestarthour * 60 * 60 + $CFG->statsruntimestartminute * 60;
         if ($timenow > $timetocheck) {
             // Process configured number of days as max (defaulting to 31).
             $maxdays = empty($CFG->statsruntimedays) ? 31 : abs($CFG->statsruntimedays);
             if (stats_cron_daily($maxdays)) {
                 if (stats_cron_weekly()) {
                     if (stats_cron_monthly()) {
                         stats_clean_old();
                     }
                 }
             }
             \core_php_time_limit::raise();
         } else {
             mtrace('Next stats run after:' . userdate($timetocheck));
         }
     }
 }
function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode = "", $hook = "", $printicons = 1, $ratings = NULL, $aliases = true)
{
    global $CFG, $USER;
    $return = false;
    if ($entry) {
        echo '<table class="glossarypost fullwithoutauthor" cellspacing="0">';
        echo '<tr valign="top">';
        echo '<th class="entryheader">';
        echo '<div class="concept">';
        glossary_print_entry_concept($entry);
        echo '</div>';
        echo '<span class="time">(' . get_string('lastedited') . ': ' . userdate($entry->timemodified) . ')</span>';
        echo '</th>';
        echo '<td class="entryattachment">';
        glossary_print_entry_approval($cm, $entry, $mode);
        glossary_print_entry_attachment($entry, $cm, 'html', 'right');
        echo '</td>';
        echo '</tr>';
        echo '<tr valign="top">';
        echo '<td width="100%" colspan="2" class="entry">';
        glossary_print_entry_definition($entry, $glossary, $cm);
        echo '</td></tr>';
        echo '<tr valign="top"><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 '<center>';
        print_string('noentry', 'glossary');
        echo '</center>';
    }
    return $return;
}
예제 #28
0
 /**
  * Returns a list of all the names of the months.
  *
  * @return array the month names
  */
 public function get_months()
 {
     $months = array();
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), '%B');
     }
     return $months;
 }
예제 #29
0
 /**
  * Format date
  */
 public function format($value)
 {
     if (empty($value)) {
         return $this->ifempty;
     } else {
         return userdate($value, $this->format);
     }
 }
 function execute($data, $row, $user, $courseid, $starttime = 0, $endtime = 0)
 {
     $date = $data->date == 'starttime' ? $row->starttime : $row->endtime;
     $format = isset($data->dateformat) ? $data->dateformat : '';
     $format = $data->dateformat == 'custom' ? $data->customdateformat : $format;
     $format = preg_replace('/[^a-zA-Z%]/i', '', $format);
     return userdate($date, $format);
 }