当前位置: 首页>>代码示例>>PHP>>正文


PHP get_user_field_name函数代码示例

本文整理汇总了PHP中get_user_field_name函数的典型用法代码示例。如果您正苦于以下问题:PHP get_user_field_name函数的具体用法?PHP get_user_field_name怎么用?PHP get_user_field_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_user_field_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_javascript_init_params

 protected function get_javascript_init_params($course, \cm_info $cm = null, \section_info $section = null)
 {
     // Standard user fields.
     $standardfields = array('firstname' => get_user_field_name('firstname'), 'lastname' => get_user_field_name('lastname'), 'email' => get_user_field_name('email'), 'city' => get_user_field_name('city'), 'country' => get_user_field_name('country'), 'url' => get_user_field_name('url'), 'icq' => get_user_field_name('icq'), 'skype' => get_user_field_name('skype'), 'aim' => get_user_field_name('aim'), 'yahoo' => get_user_field_name('yahoo'), 'msn' => get_user_field_name('msn'), 'idnumber' => get_user_field_name('idnumber'), 'institution' => get_user_field_name('institution'), 'department' => get_user_field_name('department'), 'phone1' => get_user_field_name('phone1'), 'phone2' => get_user_field_name('phone2'), 'address' => get_user_field_name('address'));
     \core_collator::asort($standardfields);
     // Custom fields.
     $customfields = array();
     $options = array('context' => \context_course::instance($course->id));
     foreach (condition::get_custom_profile_fields() as $field) {
         $customfields[$field->shortname] = format_string($field->name, true, $options);
     }
     \core_collator::asort($customfields);
     // Make arrays into JavaScript format (non-associative, ordered) and return.
     return array(self::convert_associative_array_for_js($standardfields, 'field', 'display'), self::convert_associative_array_for_js($customfields, 'field', 'display'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:frontend.php

示例2: render_form_elements

 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     // Get the user profile fields.
     $userfields = array('firstname' => get_user_field_name('firstname'), 'lastname' => get_user_field_name('lastname'), 'email' => get_user_field_name('email'), 'city' => get_user_field_name('city'), 'country' => get_user_field_name('country'), 'url' => get_user_field_name('url'), 'icq' => get_user_field_name('icq'), 'skype' => get_user_field_name('skype'), 'aim' => get_user_field_name('aim'), 'yahoo' => get_user_field_name('yahoo'), 'msn' => get_user_field_name('msn'), 'idnumber' => get_user_field_name('idnumber'), 'institution' => get_user_field_name('institution'), 'department' => get_user_field_name('department'), 'phone1' => get_user_field_name('phone1'), 'phone2' => get_user_field_name('phone2'), 'address' => get_user_field_name('address'));
     // Get the user custom fields.
     $arrcustomfields = \availability_profile\condition::get_custom_profile_fields();
     $customfields = array();
     foreach ($arrcustomfields as $key => $customfield) {
         $customfields[$customfield->id] = $key;
     }
     // Combine the two.
     $fields = $userfields + $customfields;
     core_collator::asort($fields);
     // Create the select box where the user field is selected.
     $mform->addElement('select', 'userfield', get_string('userfield', 'customcertelement_userfield'), $fields);
     $mform->setType('userfield', PARAM_ALPHANUM);
     $mform->addHelpButton('userfield', 'userfield', 'customcertelement_userfield');
     parent::render_form_elements($mform);
 }
开发者ID:rezaies,项目名称:moodle-mod_customcert,代码行数:24,代码来源:lib.php

示例3: add_user_columns

 /**
  * Add all the user-related columns to the $columns and $headers arrays.
  * @param table_sql $table the table being constructed.
  * @param array $columns the list of columns. Added to.
  * @param array $headers the columns headings. Added to.
  */
 protected function add_user_columns($table, &$columns, &$headers)
 {
     global $CFG;
     if (!$table->is_downloading() && $CFG->grade_report_showuserimage) {
         $columns[] = 'picture';
         $headers[] = '';
     }
     if (!$table->is_downloading()) {
         $columns[] = 'fullname';
         $headers[] = get_string('name');
     } else {
         $columns[] = 'lastname';
         $headers[] = get_string('lastname');
         $columns[] = 'firstname';
         $headers[] = get_string('firstname');
     }
     // When downloading, some extra fields are always displayed (because
     // there's no space constraint) so do not include in extra-field list.
     $extrafields = get_extra_user_fields($this->context, $table->is_downloading() ? array('institution', 'department', 'email') : array());
     foreach ($extrafields as $field) {
         $columns[] = $field;
         $headers[] = get_user_field_name($field);
     }
     if ($table->is_downloading()) {
         $columns[] = 'institution';
         $headers[] = get_string('institution');
         $columns[] = 'department';
         $headers[] = get_string('department');
         $columns[] = 'email';
         $headers[] = get_string('email');
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:38,代码来源:attemptsreport.php

示例4: taskchain_navigation_accesscontrol_form


//.........这里部分代码省略.........
                        }
                        $spaces = str_repeat($space, $depth - 1);
                    } else {
                        $spaces = str_repeat($space, $depth);
                    }
                }
                $name = $spaces . get_tree_char($depth, $i, $ids, $items, $categories) . $item->get_name(true);
                $name = block_taskchain_navigation::trim_text($name, $cm_namelength, $cm_headlength + strlen($spaces), $cm_taillength);
                $items[$id] = $name;
            }
            if (count($items)) {
                $conditiongradeitemidmenu = $basemenuitems + $items;
            }
        }
        if ($enablecompletion) {
            $items = array();
            $modinfo = get_fast_modinfo($course);
            foreach ($modinfo->cms as $id => $cm) {
                if ($cm->completion) {
                    $items[$id] = $cm->name;
                }
            }
            if (count($items)) {
                asort($items);
                $conditioncmidmenu = $basemenuitems + $items;
            }
        }
        $conditionfieldnamemenu = array('' => get_string('none', 'moodle'));
        $conditionfieldoperatormenu = array();
        $filepath = $CFG->dirroot . '/availability/condition/profile/classes/frontend.php';
        if (file_exists($filepath)) {
            // Moodle >= 2.7
            $contents = file_get_contents($filepath);
            $search = "/'([a-zA-Z0-9]+)' => get_user_field_name\\('\\1'\\)/";
            if (preg_match_all($search, $contents, $items)) {
                foreach ($items[1] as $item) {
                    $conditionfieldnamemenu[$item] = get_user_field_name($item);
                }
            }
            $search = "/(?<=')op_([a-zA-Z0-9]+)(?=')/";
            if (preg_match_all($search, $contents, $items)) {
                foreach ($items[1] as $i => $item) {
                    $conditionfieldoperatormenu[$item] = get_string($items[0][$i], 'availability_profile');
                }
            }
            require_once $CFG->dirroot . '/user/profile/lib.php';
            if ($items = profile_get_custom_fields(true)) {
                foreach ($items as $item) {
                    $conditionfieldnamemenu[$item->shortname] = $item->name;
                }
            }
        } else {
            if (method_exists('condition_info', 'get_condition_user_fields')) {
                // Moodle >= 2.4
                if ($items = condition_info::get_condition_user_fields(array('context' => $course->context))) {
                    $conditionfieldnamemenu += $items;
                }
                $conditionfieldoperatormenu = condition_info::get_condition_user_field_operators();
            } else {
                // Moodle <= 2.3 doesn't have conditional user fields
                $conditionfieldnamemenu = array();
            }
        }
        if ($dbman->field_exists('course_modules', 'availability')) {
            // Moodle >= 2.7
            if ($items = groups_get_all_groups($course->id)) {
开发者ID:gbateson,项目名称:moodle-block_taskchain_navigation,代码行数:67,代码来源:accesscontrol.php

示例5: __construct


//.........这里部分代码省略.........
                 if (array_key_exists($workflowfilter, $workflowstates)) {
                     $where .= ' AND uf.workflowstate = :workflowstate';
                     $params['workflowstate'] = $workflowfilter;
                 }
             }
         }
     }
     $this->set_sql($fields, $from, $where, $params);
     if ($downloadfilename) {
         $this->is_downloading('csv', $downloadfilename);
     }
     $columns = array();
     $headers = array();
     // Select.
     if (!$this->is_downloading() && $this->hasgrade) {
         $columns[] = 'select';
         $headers[] = get_string('select') . '<div class="selectall"><label class="accesshide" for="selectall">' . get_string('selectall') . '</label>
                 <input type="checkbox" id="selectall" name="selectall" title="' . get_string('selectall') . '"/></div>';
     }
     // User picture.
     if ($this->hasviewblind || !$this->assignment->is_blind_marking()) {
         if (!$this->is_downloading()) {
             $columns[] = 'picture';
             $headers[] = get_string('pictureofuser');
         } else {
             $columns[] = 'recordid';
             $headers[] = get_string('recordid', 'assign');
         }
         // Fullname.
         $columns[] = 'fullname';
         $headers[] = get_string('fullname');
         foreach ($extrauserfields as $extrafield) {
             $columns[] = $extrafield;
             $headers[] = get_user_field_name($extrafield);
         }
     } else {
         // Record ID.
         $columns[] = 'recordid';
         $headers[] = get_string('recordid', 'assign');
     }
     // Submission status.
     $columns[] = 'status';
     $headers[] = get_string('status', 'assign');
     // Team submission columns.
     if ($assignment->get_instance()->teamsubmission) {
         $columns[] = 'team';
         $headers[] = get_string('submissionteam', 'assign');
     }
     // Allocated marker.
     if ($this->assignment->get_instance()->markingworkflow && $this->assignment->get_instance()->markingallocation && has_capability('mod/assign:manageallocations', $this->assignment->get_context())) {
         // Add a column for the allocated marker.
         $columns[] = 'allocatedmarker';
         $headers[] = get_string('marker', 'assign');
     }
     // Grade.
     $columns[] = 'grade';
     $headers[] = get_string('grade');
     if ($this->is_downloading()) {
         if ($this->assignment->get_instance()->grade >= 0) {
             $columns[] = 'grademax';
             $headers[] = get_string('maxgrade', 'assign');
         } else {
             // This is a custom scale.
             $columns[] = 'scale';
             $headers[] = get_string('scale', 'assign');
         }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:67,代码来源:gradingtable.php

示例6: get_string

            get_string('lastname').'</a>';
    } else {
        print "<a href=\"./?course={$course->id}&amp;sort=firstname{$sistring}\">".
            get_string('firstname').'</a> / '.
            get_string('lastname');
    }
    print '</th>';

    // Print user identity columns
    foreach ($extrafields as $field) {
        echo '<th scope="col" class="completion-identifyfield">' .
                get_user_field_name($field) . '</th>';
    }
} else {
    foreach ($extrafields as $field) {
        echo $sep . csv_quote(get_user_field_name($field));
    }
}

// Activities
foreach($activities as $activity) {
    $activity->datepassed = $activity->completionexpected && $activity->completionexpected <= time();
    $activity->datepassedclass=$activity->datepassed ? 'completion-expired' : '';

    if ($activity->completionexpected) {
        $datetext=userdate($activity->completionexpected,get_string('strftimedate','langconfig'));
    } else {
        $datetext='';
    }

    // Some names (labels) come URL-encoded and can be very long, so shorten them
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:index.php

示例7: get_string

 if (!empty($user->role)) {
     $row->cells[1]->text .= get_string('role').get_string('labelsep', 'langconfig').$user->role.'<br />';
 }
 if ($user->maildisplay == 1 or ($user->maildisplay == 2 and ($course->id != SITEID) and !isguestuser()) or
             has_capability('moodle/course:viewhiddenuserfields', $context) or
             in_array('email', $extrafields)) {
     $row->cells[1]->text .= get_string('email').get_string('labelsep', 'langconfig').html_writer::link("mailto:$user->email", $user->email) . '<br />';
 }
 foreach ($extrafields as $field) {
     if ($field === 'email') {
         // Skip email because it was displayed with different
         // logic above (because this page is intended for
         // students too)
         continue;
     }
     $row->cells[1]->text .= get_user_field_name($field) .
             get_string('labelsep', 'langconfig') . s($user->{$field}) . '<br />';
 }
 if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
     $row->cells[1]->text .= get_string('city').get_string('labelsep', 'langconfig');
     if ($user->city && !isset($hiddenfields['city'])) {
         $row->cells[1]->text .= $user->city;
     }
     if (!empty($countries[$user->country]) && !isset($hiddenfields['country'])) {
         if ($user->city && !isset($hiddenfields['city'])) {
             $row->cells[1]->text .= ', ';
         }
         $row->cells[1]->text .= $countries[$user->country];
     }
     $row->cells[1]->text .= '<br />';
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:31,代码来源:index.php

示例8: display

 /**
  * displays the full report
  * @param \stdClass $scorm full SCORM object
  * @param \stdClass $cm - full course_module object
  * @param \stdClass $course - full course object
  * @param string $download - type of download being requested
  */
 public function display($scorm, $cm, $course, $download)
 {
     global $CFG, $DB, $OUTPUT, $PAGE;
     $contextmodule = \context_module::instance($cm->id);
     $action = optional_param('action', '', PARAM_ALPHA);
     $attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
     $attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
     $PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
     if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
         if (scorm_delete_responses($attemptids, $scorm)) {
             // Delete responses.
             echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
         }
     }
     // Find out current groups mode.
     $currentgroup = groups_get_activity_group($cm, true);
     // Detailed report.
     $mform = new \mod_scorm_report_objectives_settings($PAGE->url, compact('currentgroup'));
     if ($fromform = $mform->get_data()) {
         $pagesize = $fromform->pagesize;
         $showobjectivescore = $fromform->objectivescore;
         set_user_preference('scorm_report_pagesize', $pagesize);
         set_user_preference('scorm_report_objectives_score', $showobjectivescore);
     } else {
         $pagesize = get_user_preferences('scorm_report_pagesize', 0);
         $showobjectivescore = get_user_preferences('scorm_report_objectives_score', 0);
     }
     if ($pagesize < 1) {
         $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
     }
     // Select group menu.
     $displayoptions = array();
     $displayoptions['attemptsmode'] = $attemptsmode;
     $displayoptions['objectivescore'] = $showobjectivescore;
     $mform->set_data($displayoptions + array('pagesize' => $pagesize));
     if ($groupmode = groups_get_activity_groupmode($cm)) {
         // Groups are being used.
         if (!$download) {
             groups_print_activity_menu($cm, new \moodle_url($PAGE->url, $displayoptions));
         }
     }
     $formattextoptions = array('context' => \context_course::instance($course->id));
     // We only want to show the checkbox to delete attempts
     // if the user has permissions and if the report mode is showing attempts.
     $candelete = has_capability('mod/scorm:deleteresponses', $contextmodule) && $attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO;
     // Select the students.
     $nostudents = false;
     if (empty($currentgroup)) {
         // All users who can attempt scoes.
         if (!($students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', '', '', false))) {
             echo $OUTPUT->notification(get_string('nostudentsyet'));
             $nostudents = true;
             $allowedlist = '';
         } else {
             $allowedlist = array_keys($students);
         }
         unset($students);
     } else {
         // All users who can attempt scoes and who are in the currently selected group.
         $groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', $currentgroup, '', false);
         if (!$groupstudents) {
             echo $OUTPUT->notification(get_string('nostudentsingroup'));
             $nostudents = true;
             $groupstudents = array();
         }
         $allowedlist = array_keys($groupstudents);
         unset($groupstudents);
     }
     if (!$nostudents) {
         // Now check if asked download of data.
         $coursecontext = \context_course::instance($course->id);
         if ($download) {
             $filename = clean_filename("{$course->shortname} " . format_string($scorm->name, true, $formattextoptions));
         }
         // Define table columns.
         $columns = array();
         $headers = array();
         if (!$download && $candelete) {
             $columns[] = 'checkbox';
             $headers[] = null;
         }
         if (!$download && $CFG->grade_report_showuserimage) {
             $columns[] = 'picture';
             $headers[] = '';
         }
         $columns[] = 'fullname';
         $headers[] = get_string('name');
         $extrafields = get_extra_user_fields($coursecontext);
         foreach ($extrafields as $field) {
             $columns[] = $field;
             $headers[] = get_user_field_name($field);
         }
         $columns[] = 'attempt';
//.........这里部分代码省略.........
开发者ID:lucaboesch,项目名称:moodle,代码行数:101,代码来源:report.php

示例9: is_available


//.........这里部分代码省略.........
         }
     }
     // Check each grade condition
     if (count($this->item->conditionsgrade) > 0) {
         foreach ($this->item->conditionsgrade as $gradeitemid => $minmax) {
             $score = $this->get_cached_grade_score($gradeitemid, $grabthelot, $userid);
             if ($score === false || !is_null($minmax->min) && $score < $minmax->min || !is_null($minmax->max) && $score >= $minmax->max) {
                 // Grade fail
                 $available = false;
                 // String depends on type of requirement. We are coy about
                 // the actual numbers, in case grades aren't released to
                 // students.
                 if (is_null($minmax->min) && is_null($minmax->max)) {
                     $string = 'any';
                 } else {
                     if (is_null($minmax->max)) {
                         $string = 'min';
                     } else {
                         if (is_null($minmax->min)) {
                             $string = 'max';
                         } else {
                             $string = 'range';
                         }
                     }
                 }
                 $information .= html_writer::start_tag('li');
                 $information .= get_string('requires_grade_' . $string, 'condition', $minmax->name) . ' ';
                 $information .= html_writer::end_tag('li');
             }
         }
     }
     // Check if user field condition
     if (count($this->item->conditionsfield) > 0) {
         $context = $this->get_context();
         foreach ($this->item->conditionsfield as $field => $details) {
             $uservalue = $this->get_cached_user_profile_field($userid, $field);
             if (!$this->is_field_condition_met($details->operator, $uservalue, $details->value)) {
                 // Set available to false
                 $available = false;
                 // Display the fieldname into current lang.
                 if (is_numeric($field)) {
                     // Is a custom profile field (will use multilang).
                     $translatedfieldname = $details->fieldname;
                 } else {
                     $translatedfieldname = get_user_field_name($details->fieldname);
                 }
                 $a = new stdClass();
                 $a->field = format_string($translatedfieldname, true, array('context' => $context));
                 $a->value = s($details->value);
                 $information .= html_writer::start_tag('li');
                 $information .= get_string('requires_user_field_' . $details->operator, 'condition', $a) . ' ';
                 $information .= html_writer::end_tag('li');
             }
         }
     }
     // Test dates
     if ($this->item->availablefrom) {
         if (time() < $this->item->availablefrom) {
             $available = false;
             $information .= html_writer::start_tag('li');
             $information .= get_string('requires_date', 'condition', self::show_time($this->item->availablefrom, self::is_midnight($this->item->availablefrom)));
             $information .= html_writer::end_tag('li');
         }
     }
     if ($this->item->availableuntil) {
         if (time() >= $this->item->availableuntil) {
             $available = false;
             // But we don't display any information about this case. This is
             // because the only reason to set a 'disappear' date is usually
             // to get rid of outdated information/clutter in which case there
             // is no point in showing it...
             // Note it would be nice if we could make it so that the 'until'
             // date appears below the item while the item is still accessible,
             // unfortunately this is not possible in the current system. Maybe
             // later, or if somebody else wants to add it.
         }
     }
     // If the item is marked as 'not visible' then we don't change the available
     // flag (visible/available are treated distinctly), but we remove any
     // availability info. If the item is hidden with the eye icon, it doesn't
     // make sense to show 'Available from <date>' or similar, because even
     // when that date arrives it will still not be available unless somebody
     // toggles the eye icon.
     if (!$this->item->visible) {
         $information = '';
     }
     // The information is in <li> tags, but to avoid taking up more space
     // if there is only a single item, we strip out the list tags so that it
     // is plain text in that case.
     if (!empty($information)) {
         $li = strpos($information, '<li>', 4);
         if ($li === false) {
             $information = preg_replace('~^\\s*<li>(.*)</li>\\s*$~s', '$1', $information);
         } else {
             $information = html_writer::tag('ul', $information);
         }
         $information = trim($information);
     }
     return $available;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:101,代码来源:conditionlib.php

示例10: userlist_fill_workbook

 /**
  * fills workbook (either XLSX or ODS) with data
  *
  * @param MoodleExcelWorkbook $workbook workbook to put data into
  * @param stdClass[] $data userdata with headline at index 0
  * @param stdClass[] $orderby current sort-array
  * @param string[] $collapsed current collapsed columns
  */
 private function userlist_fill_workbook(&$workbook, $data = array(), $orderby = array(), $collapsed = array())
 {
     global $SESSION, $CFG;
     $orientation = optional_param('orientation', 0, PARAM_BOOL);
     if (count($data) > 0) {
         if (count($data) > 1) {
             // General information? unused at the moment!
             $worksheet = $workbook->add_worksheet(get_string('all'));
             if (is_a($worksheet, 'Moodle_Excel_Worksheet')) {
                 if ($orientation) {
                     $worksheet->pear_excel_worksheet->setLandscape();
                 } else {
                     $worksheet->pear_excel_worksheet->setPortrait();
                 }
             }
         }
         // Prepare formats!
         $headlineprop = array('size' => 12, 'bold' => 1, 'HAlign' => 'center', 'bottom' => 2, 'VAlign' => 'vcenter');
         $headlineformat = $workbook->add_format($headlineprop);
         $headlineformat->set_right(1);
         $headlineformat->set_align('center');
         $headlineformat->set_align('vcenter');
         $headlinelast = $workbook->add_format($headlineprop);
         $headlinelast->set_align('center');
         $headlinelast->set_align('vcenter');
         $headlinelast->set_left(1);
         $headlinenb = $workbook->add_format($headlineprop);
         $headlinenb->set_align('center');
         $headlinenb->set_align('vcenter');
         unset($headlineprop['bottom']);
         $headlinenbb = $workbook->add_format($headlineprop);
         $headlinenbb->set_align('center');
         $headlinenbb->set_align('vcenter');
         $regentryprop = array('size' => 10, 'align' => 'left');
         $queueentryprop = $regentryprop;
         $queueentryprop['italic'] = true;
         $queueentryprop['color'] = 'grey';
         $regentryformat = $workbook->add_format($regentryprop);
         $regentryformat->set_right(1);
         $regentryformat->set_align('vcenter');
         $regentrylast = $workbook->add_format($regentryprop);
         $regentrylast->set_align('vcenter');
         $noregentriesformat = $workbook->add_format($regentryprop);
         $noregentriesformat->set_align('center');
         $noregentriesformat->set_align('vcenter');
         $noregentriesformat->set_right(1);
         $queueentryformat = $workbook->add_format($queueentryprop);
         $queueentryformat->set_right(1);
         $queueentryformat->set_align('vcenter');
         $queueentrylast = $workbook->add_format($queueentryprop);
         $queueentrylast->set_align('vcenter');
         $noqueueentriesformat = $workbook->add_format($queueentryprop);
         $noqueueentriesformat->set_align('center');
         $noqueueentriesformat->set_align('vcenter');
         // Start row for groups general sheet!
         $j = 0;
         // We create a dummy user-object to get the fullname-format!
         $dummy = new stdClass();
         $namefields = get_all_user_name_fields();
         foreach ($namefields as $namefield) {
             $dummy->{$namefield} = $namefield;
         }
         $fullnameformat = fullname($dummy);
         // Now get the ones used in fullname in the correct order!
         $namefields = order_in_string($namefields, $fullnameformat);
         $columnwidth = array(0 => 26, 'fullname' => 26, 'firstname' => 20, 'surname' => 20, 'email' => 35, 'registrations' => 47, 'queues_rank' => 7.5, 'queues_grp' => 47);
         // Unit: mm!
         foreach ($data as $key => $user) {
             if ($key == 0) {
                 // Headline!
                 $k = 0;
                 // First we output every namefield from used by fullname in exact the defined order!
                 foreach ($namefields as $namefield) {
                     $worksheet->write_string($j, $k, get_user_field_name($namefield), $headlineformat);
                     $worksheet->write_blank($j + 1, $k, $headlineformat);
                     $worksheet->merge_cells($j, $k, $j + 1, $k);
                     $hidden = in_array($namefield, $collapsed) ? true : false;
                     $columnwidth[$namefield] = empty($columnwidth[$namefield]) ? $columnwidth[0] : $columnwidth[$namefield];
                     $worksheet->set_column($k, $k, $columnwidth[$namefield], null, $hidden);
                     $k++;
                 }
                 // ...k = n!
                 if (!empty($CFG->showuseridentity)) {
                     $fields = explode(',', $CFG->showuseridentity);
                     foreach ($fields as $field) {
                         $worksheet->write_string($j, $k, get_user_field_name($field), $headlineformat);
                         $worksheet->write_blank($j + 1, $k, $headlineformat);
                         $hidden = in_array($field, $collapsed) ? true : false;
                         $columnwidth[$field] = empty($columnwidth[$field]) ? $columnwidth[0] : $columnwidth[$field];
                         $worksheet->set_column($k, $k, $columnwidth[$field], null, $hidden);
                         $worksheet->merge_cells($j, $k, $j + 1, $k);
                         $k++;
//.........这里部分代码省略.........
开发者ID:rimacher,项目名称:moodle-mod_grouptool,代码行数:101,代码来源:locallib.php

示例11: __construct

    /**
     * overridden constructor keeps a reference to the assignment class that is displaying this table
     *
     * @param assign $assignment The assignment class
     * @param int $perpage how many per page
     * @param string $filter The current filter
     * @param int $rowoffset For showing a subsequent page of results
     * @param bool $quickgrading Is this table wrapped in a quickgrading form?
     */
    function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading) {
        global $CFG, $PAGE, $DB;
        parent::__construct('mod_assign_grading');
        $this->assignment = $assignment;
        $this->perpage = $perpage;
        $this->quickgrading = $quickgrading;
        $this->output = $PAGE->get_renderer('mod_assign');

        $this->define_baseurl(new moodle_url($CFG->wwwroot . '/mod/assign/view.php', array('action'=>'grading', 'id'=>$assignment->get_course_module()->id)));

        // do some business - then set the sql

        $currentgroup = groups_get_activity_group($assignment->get_course_module(), true);

        if ($rowoffset) {
            $this->rownum = $rowoffset - 1;
        }

        $users = array_keys( $assignment->list_participants($currentgroup, true));
        if (count($users) == 0) {
            // insert a record that will never match to the sql is still valid.
            $users[] = -1;
        }

        $params = array();
        $params['assignmentid1'] = (int)$this->assignment->get_instance()->id;
        $params['assignmentid2'] = (int)$this->assignment->get_instance()->id;

        $extrauserfields = get_extra_user_fields($this->assignment->get_context());

        $fields = user_picture::fields('u', $extrauserfields) . ', u.id as userid, ';
        $fields .= 's.status as status, s.id as submissionid, s.timecreated as firstsubmission, s.timemodified as timesubmitted, ';
        $fields .= 'g.id as gradeid, g.grade as grade, g.timemodified as timemarked, g.timecreated as firstmarked, g.mailed as mailed, g.locked as locked';
        $from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1' .
                        ' LEFT JOIN {assign_grades} g ON u.id = g.userid AND g.assignment = :assignmentid2';

        $userparams = array();
        $userindex = 0;

        list($userwhere, $userparams) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED, 'user');
        $where = 'u.id ' . $userwhere;
        $params = array_merge($params, $userparams);

        // The filters do not make sense when there are no submissions, so do not apply them.
        if ($this->assignment->is_any_submission_plugin_enabled()) {
            if ($filter == ASSIGN_FILTER_SUBMITTED) {
                $where .= ' AND (s.timemodified IS NOT NULL AND
                                 s.status = :submitted) ';
                $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED;

            } else if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) {
                $where .= ' AND (s.timemodified IS NOT NULL AND
                                 s.status = :submitted AND
                                 (s.timemodified > g.timemodified OR g.timemodified IS NULL))';
                $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED;

            } else if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) {
                $userfilter = (int) array_pop(explode('=', $filter));
                $where .= ' AND (u.id = :userid)';
                $params['userid'] = $userfilter;
            }
        }
        $this->set_sql($fields, $from, $where, $params);

        $columns = array();
        $headers = array();

        // Select
        if (!$this->is_downloading()) {
            $columns[] = 'select';
            $headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>';
        }

        // User picture
        $columns[] = 'picture';
        $headers[] = get_string('pictureofuser');

        // Fullname
        $columns[] = 'fullname';
        $headers[] = get_string('fullname');
        foreach ($extrauserfields as $extrafield) {
            $columns[] = $extrafield;
            $headers[] = get_user_field_name($extrafield);
        }

        // Submission status
        if ($assignment->is_any_submission_plugin_enabled()) {
            $columns[] = 'status';
            $headers[] = get_string('status');
        }

//.........这里部分代码省略.........
开发者ID:ncsu-delta,项目名称:moodle,代码行数:101,代码来源:gradingtable.php

示例12: geogebra_view_results

function geogebra_view_results($geogebra, $context, $cm, $course, $action)
{
    global $CFG, $DB, $OUTPUT, $PAGE, $USER;
    if ($action == 'submitgrade') {
        // Upgrade submitted grade
        $grade = optional_param('grade', '', PARAM_INT);
        $gradecomment = optional_param_array('comment_editor', '', PARAM_RAW);
        $attemptid = optional_param('attemptid', '', PARAM_INT);
        $attempt = geogebra_get_attempt($attemptid);
        parse_str($attempt->vars, $parsedvars);
        $parsedvars['grade'] = $grade;
        $attempt->vars = http_build_query($parsedvars, '', '&');
        geogebra_update_attempt($attemptid, $attempt->vars, GEOGEBRA_UPDATE_TEACHER, $gradecomment['text']);
    }
    // Show students list with their results
    require_once $CFG->libdir . '/gradelib.php';
    $perpage = optional_param('perpage', 10, PARAM_INT);
    $perpage = $perpage <= 0 ? 10 : $perpage;
    $page = optional_param('page', 0, PARAM_INT);
    // Find out current groups mode
    $groupmode = groups_get_activity_groupmode($cm);
    $currentgroup = groups_get_activity_group($cm, true);
    // Get all ppl that are allowed to submit geogebra
    list($esql, $params) = get_enrolled_sql($context, 'mod/geogebra:submit', $currentgroup);
    $sql = "SELECT u.id FROM {user} u " . "LEFT JOIN ({$esql}) eu ON eu.id=u.id " . "WHERE u.deleted = 0 AND eu.id=u.id ";
    $users = $DB->get_records_sql($sql, $params);
    if (!empty($users)) {
        $users = array_keys($users);
    }
    // If groupmembersonly used, remove users who are not in any group
    if ($users and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
        if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
            $users = array_intersect($users, array_keys($groupingusers));
        }
    }
    // TODO: Review to show all users information
    if (!empty($users)) {
        // Create results table
        $extrafields = get_extra_user_fields($context);
        $tablecolumns = array_merge(array('picture', 'fullname'), $extrafields, array('attempts', 'duration', 'grade', 'comment', 'datestudent', 'dateteacher', 'status'));
        $extrafieldnames = array();
        foreach ($extrafields as $field) {
            $extrafieldnames[] = get_user_field_name($field);
        }
        $tableheaders = array_merge(array('', get_string('fullnameuser')), $extrafieldnames, array(get_string('attempts', 'geogebra'), get_string('duration', 'geogebra'), get_string('grade'), get_string('comment', 'geogebra'), get_string('lastmodifiedsubmission', 'geogebra'), get_string('lastmodifiedgrade', 'geogebra'), get_string('status', 'geogebra')));
        require_once $CFG->libdir . '/tablelib.php';
        $table = new flexible_table('mod-geogebra-results');
        $table->define_columns($tablecolumns);
        $table->define_headers($tableheaders);
        $table->define_baseurl($CFG->wwwroot . '/mod/geogebra/report.php?id=' . $cm->id . '&amp;currentgroup=' . $currentgroup);
        $table->sortable(true, 'lastname');
        // Sorted by lastname by default
        $table->collapsible(true);
        $table->initialbars(true);
        $table->column_suppress('picture');
        $table->column_suppress('fullname');
        $table->column_class('picture', 'picture');
        $table->column_class('fullname', 'fullname');
        foreach ($extrafields as $field) {
            $table->column_class($field, $field);
        }
        $table->set_attribute('cellspacing', '0');
        $table->set_attribute('id', 'attempts');
        $table->set_attribute('class', 'results generaltable generalbox');
        $table->set_attribute('width', '100%');
        $table->no_sorting('attempts');
        $table->no_sorting('duration');
        $table->no_sorting('grade');
        $table->no_sorting('comment');
        $table->no_sorting('datestudent');
        $table->no_sorting('dateteacher');
        $table->no_sorting('status');
        // Start working -- this is necessary as soon as the niceties are over
        $table->setup();
        // Construct the SQL
        list($where, $params) = $table->get_sql_where();
        if ($where) {
            $where .= ' AND ';
        }
        if ($sort = $table->get_sql_sort()) {
            $sort = ' ORDER BY ' . $sort;
        }
        $ufields = user_picture::fields('u', $extrafields);
        $select = "SELECT {$ufields} ";
        $sql = 'FROM {user} u WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
        $ausers = $DB->get_records_sql($select . $sql . $sort, $params, $table->get_page_start(), $table->get_page_size());
        $table->pagesize($perpage, count($users));
        $offset = $page * $perpage;
        // Offset used to calculate index of student in that particular query, needed for the pop up to know who's next
        if ($ausers !== false) {
            // $grading_info = grade_get_grades($course->id, 'mod', 'geogebra', $geogebra->id, array_keys($ausers));
            foreach ($ausers as $auser) {
                $picture = $OUTPUT->user_picture($auser);
                $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&amp;course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $context)) . '</a>';
                $row = array($picture, $userlink);
                $extradata = array();
                foreach ($extrafields as $field) {
                    $extradata[] = $auser->{$field};
                }
                $row += $extradata;
//.........这里部分代码省略.........
开发者ID:ninelanterns,项目名称:moodle-mod_geogebra,代码行数:101,代码来源:locallib.php

示例13: get_details

 /**
  * Get criteria details for displaying to users
  *
  * @return string
  */
 public function get_details($short = '')
 {
     global $DB, $OUTPUT;
     $output = array();
     foreach ($this->params as $p) {
         if (is_numeric($p['field'])) {
             $str = $DB->get_field('user_info_field', 'name', array('id' => $p['field']));
         } else {
             $str = get_user_field_name($p['field']);
         }
         if (!$str) {
             $output[] = $OUTPUT->error_text(get_string('error:nosuchfield', 'badges'));
         } else {
             $output[] = $str;
         }
     }
     if ($short) {
         return implode(', ', $output);
     } else {
         return html_writer::alist($output, array(), 'ul');
     }
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:27,代码来源:award_criteria_profile.php

示例14: get_sort_arrows

 /**
  * Refactored function for generating HTML of sorting links with matching arrows.
  * Returns an array with 'studentname' and 'idnumber' as keys, with HTML ready
  * to inject into a table header cell.
  * @param array $extrafields Array of extra fields being displayed, such as
  *   user idnumber
  * @return array An associative array of HTML sorting links+arrows
  */
 public function get_sort_arrows(array $extrafields = array())
 {
     global $OUTPUT;
     $arrows = array();
     $strsortasc = $this->get_lang_string('sortasc', 'grades');
     $strsortdesc = $this->get_lang_string('sortdesc', 'grades');
     $strfirstname = $this->get_lang_string('firstname');
     $strlastname = $this->get_lang_string('lastname');
     $iconasc = $OUTPUT->pix_icon('t/sort_asc', $strsortasc, '', array('class' => 'iconsmall sorticon'));
     $icondesc = $OUTPUT->pix_icon('t/sort_desc', $strsortdesc, '', array('class' => 'iconsmall sorticon'));
     $firstlink = html_writer::link(new moodle_url($this->baseurl, array('sortitemid' => 'firstname')), $strfirstname);
     $lastlink = html_writer::link(new moodle_url($this->baseurl, array('sortitemid' => 'lastname')), $strlastname);
     $arrows['studentname'] = $lastlink;
     if ($this->sortitemid === 'lastname') {
         if ($this->sortorder == 'ASC') {
             $arrows['studentname'] .= $iconasc;
         } else {
             $arrows['studentname'] .= $icondesc;
         }
     }
     $arrows['studentname'] .= ' ' . $firstlink;
     if ($this->sortitemid === 'firstname') {
         if ($this->sortorder == 'ASC') {
             $arrows['studentname'] .= $iconasc;
         } else {
             $arrows['studentname'] .= $icondesc;
         }
     }
     foreach ($extrafields as $field) {
         $fieldlink = html_writer::link(new moodle_url($this->baseurl, array('sortitemid' => $field)), get_user_field_name($field));
         $arrows[$field] = $fieldlink;
         if ($field == $this->sortitemid) {
             if ($this->sortorder == 'ASC') {
                 $arrows[$field] .= $iconasc;
             } else {
                 $arrows[$field] .= $icondesc;
             }
         }
     }
     return $arrows;
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:49,代码来源:lib.php

示例15: certificate_get_grade

            echo certificate_get_grade($certificate, $course, $user->id) . "\t";
            echo $user->code . "\n";
            $row++;
        }
    }
    exit;
}
$usercount = count(certificate_get_issues($certificate->id, $DB->sql_fullname(), $groupmode, $cm));
// Create the table for the users
$table = new html_table();
$table->width = "95%";
$table->tablealign = "center";
$table->head = array($strto);
$table->align = array('left');
foreach ($extrafields as $field) {
    $table->head[] = get_user_field_name($field);
    $table->align[] = 'left';
}
$table->head = array_merge($table->head, array($strdate, $strgrade, $strcode));
$table->align = array_merge($table->align, array('left', 'center', 'center'));
foreach ($users as $user) {
    $name = $OUTPUT->user_picture($user) . fullname($user);
    $date = userdate($user->timecreated) . certificate_print_user_files($certificate, $user->id, $context->id);
    $code = $user->code;
    $data = array();
    $data[] = $name;
    foreach ($extrafields as $field) {
        $data[] = $user->{$field};
    }
    $data = array_merge($data, array($date, certificate_get_grade($certificate, $course, $user->id), $code));
    $table->data[] = $data;
开发者ID:ccle,项目名称:moodle-mod_certificate,代码行数:31,代码来源:report.php


注:本文中的get_user_field_name函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。