• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_current_group函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: webquestscorm

 /**
  * Constructor for the webquestscorm class
  *
  * Constructor for the base assignment class.
  * If cmid is set create the cm, course, assignment objects.
  * If the assignment is hidden and the user is not a teacher then
  * this prints a page header and notice.
  *
  * @param cmid   integer, the current course module id - not set for new assignments
  * @param assignment   object, usually null, but if we have it we pass it to save db access
  * @param cm   object, usually null, but if we have it we pass it to save db access
  * @param course   object, usually null, but if we have it we pass it to save db access
  */
 function webquestscorm($cmid = 0, $webquestscorm = NULL, $cm = NULL, $course = NULL)
 {
     global $CFG;
     if ($cmid) {
         if ($cm) {
             $this->cm = $cm;
         } else {
             if (!($this->cm = get_coursemodule_from_id('webquestscorm', $cmid))) {
                 error('Course Module ID was incorrect');
             }
         }
         $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
         if ($course) {
             $this->course = $course;
         } else {
             if (!($this->course = get_record('course', 'id', $this->cm->course))) {
                 error('Course is misconfigured');
             }
         }
         if ($webquestscorm) {
             $this->webquestscorm = $webquestscorm;
         } else {
             if (!($this->webquestscorm = get_record('webquestscorm', 'id', $this->cm->instance))) {
                 error('webquestscorm ID was incorrect');
             }
         }
         $this->strwebquestscorm = get_string('modulename', 'webquestscorm');
         $this->strwebquestscorms = get_string('modulenameplural', 'webquestscorm');
         $this->strsubmissions = get_string('submissions', 'webquestscorm');
         $this->strlastmodified = get_string('lastmodified');
         if ($this->course->category) {
             $this->navigation = "<a target=\"{$CFG->framename}\" href=\"{$CFG->wwwroot}/course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> -> " . "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">{$this->strwebquestscorms}</a> ->";
         } else {
             $this->navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">{$this->strwebquestscorms}</a> ->";
         }
         $this->pagetitle = strip_tags($this->course->shortname . ': ' . $this->strwebquestscorm . ': ' . format_string($this->webquestscorm->name, true));
         // visibility
         $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
         if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', $this->context)) {
             $this->pagetitle = strip_tags($this->course->shortname . ': ' . $this->strwebquestscorm);
             print_header($this->pagetitle, $this->course->fullname, "{$this->navigation} {$this->strwebquestscorm}", "", "", true, '', navmenu($this->course, $this->cm));
             notice(get_string("activityiscurrentlyhidden"), "{$CFG->wwwroot}/course/view.php?id={$this->course->id}");
         }
         $this->currentgroup = get_current_group($this->course->id);
         $this->path = $CFG->dataroot . '/' . $this->cm->course . '/moddata/webquestscorm' . '/' . $this->cm->id;
     }
     if ($this->usehtmleditor = can_use_html_editor()) {
         $this->defaultformat = FORMAT_HTML;
     } else {
         $this->defaultformat = FORMAT_MOODLE;
     }
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:65,代码来源:webquestscorm.class.php


示例2: journal_user_complete_index

function journal_user_complete_index($course, $user, $journal, $journalopen, $heading)
{
    /// Prints a journal, entry and feedback ... used on the journal index page.
    if (isteacher($course->id)) {
        $entrycount = journal_count_entries($journal, get_current_group($course->id));
        $entryinfo = "&nbsp;(<a href=\"report.php?id={$journal->coursemodule}\">" . get_string("viewallentries", "journal", $entrycount) . "</a>)";
    } else {
        $entryinfo = "";
    }
    $journal->name = "<a href=\"view.php?id={$journal->coursemodule}\">" . format_string($journal->name, true) . "</a>";
    if ($heading) {
        echo "<h3>{$heading} - {$journal->name}{$entryinfo}</h3>";
    } else {
        echo "<h3>{$journal->name}{$entryinfo}</h3>";
    }
    print_simple_box_start("left", "90%");
    echo format_text($journal->intro, $journal->introformat);
    print_simple_box_end();
    echo "<br clear=\"all\" />";
    echo "<br />";
    if (isstudent($course->id) or isteacher($course->id)) {
        print_simple_box_start("right", "90%");
        if ($journalopen) {
            echo "<p align=\"right\"><a href=\"edit.php?id={$journal->coursemodule}\">";
            echo get_string("edit") . "</a></p>";
        } else {
            echo "<p align=\"right\"><a href=\"view.php?id={$journal->coursemodule}\">";
            echo get_string("view") . "</a></p>";
        }
        if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
            if ($entry->modified) {
                echo "<p align=\"center\"><font size=\"1\">" . get_string("lastedited") . ": " . userdate($entry->modified) . "</font></p>";
            }
            if ($entry->text) {
                echo format_text($entry->text, $entry->format);
            }
            if ($entry->teacher) {
                $grades = make_grades_menu($journal->assessed);
                journal_print_feedback($course, $entry, $grades);
            }
        } else {
            print_string("noentry", "journal");
        }
        print_simple_box_end();
        echo "<br clear=\"all\" />";
        echo "<br />";
    }
}
开发者ID:r007,项目名称:PMoodle,代码行数:48,代码来源:lib.php


示例3: choice_show_results

function choice_show_results($choice, $course, $cm, $forcepublish = '')
{
    global $CFG, $COLUMN_HEIGHT, $USER;
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    print_heading(get_string("responses", "choice"));
    if (empty($forcepublish)) {
        //alow the publish setting to be overridden
        $forcepublish = $choice->publish;
    }
    $groupmode = groupmode($course, $cm);
    if ($groupmode > 0) {
        $currentgroup = get_current_group($course->id);
    } else {
        $currentgroup = 0;
    }
    $users = get_users_by_capability($context, 'mod/choice:choose', 'u.id, u.picture, u.firstname, u.lastname, u.idnumber', 'u.firstname ASC', '', '', $currentgroup, '', false, true);
    if (!$users) {
        print_heading(get_string("nousersyet"));
    }
    $answers = array();
    if ($allresponses = get_records("choice_answers", "choiceid", $choice->id)) {
        foreach ($allresponses as $aa) {
            //TODO: rewrite with SQL
            if ($groupmode and $currentgroup) {
                if (ismember($currentgroup, $aa->userid)) {
                    $answers[$aa->userid] = $aa;
                }
            } else {
                $answers[$aa->userid] = $aa;
            }
        }
    }
    $timenow = time();
    foreach ($choice->option as $optionid => $text) {
        $useranswer[$optionid] = array();
    }
    if (!empty($users)) {
        foreach ($users as $user) {
            if (!empty($user->id) and !empty($answers[$user->id])) {
                $answer = $answers[$user->id];
                $useranswer[(int) $answer->optionid][] = $user;
            } else {
                $useranswer[0][] = $user;
            }
        }
    }
    foreach ($choice->option as $optionid => $text) {
        if (!$choice->option[$optionid]) {
            unset($useranswer[$optionid]);
            // Throw away any data that doesn't apply
        }
    }
    ksort($useranswer);
    switch ($forcepublish) {
        case CHOICE_PUBLISH_NAMES:
            $tablewidth = (int) (100.0 / count($useranswer));
            if (has_capability('mod/choice:readresponses', $context)) {
                echo '<div id="tablecontainer">';
                echo '<form id="attemptsform" method="post" action="' . $_SERVER['PHP_SELF'] . '" onsubmit="var menu = document.getElementById(\'menuaction\'); return (menu.options[menu.selectedIndex].value == \'delete\' ? \'' . addslashes(get_string('deleteattemptcheck', 'quiz')) . '\' : true);">';
                echo '<div>';
                echo '<input type="hidden" name="id" value="' . $cm->id . '" />';
                echo '<input type="hidden" name="mode" value="overview" />';
            }
            echo "<table cellpadding=\"5\" cellspacing=\"10\" class=\"results names\">";
            echo "<tr>";
            $count = 0;
            $columncount = array();
            // number of votes in each column
            foreach ($useranswer as $optionid => $userlist) {
                $columncount[$optionid] = 0;
                // init counters
                if ($optionid) {
                    echo "<th class=\"col{$count} header\" style=\"width:{$tablewidth}%\" scope=\"col\">";
                } else {
                    if ($choice->showunanswered) {
                        echo "<th class=\"col{$count} header\" style=\"width:{$tablewidth}%\" scope=\"col\">";
                    } else {
                        continue;
                    }
                }
                echo format_string(choice_get_option_text($choice, $optionid));
                echo "</th>";
                $count++;
            }
            echo "</tr><tr>";
            $count = 0;
            foreach ($useranswer as $optionid => $userlist) {
                if ($optionid) {
                    echo "<td class=\"col{$count} data\" style=\"width:{$tablewidth}%;\">";
                } else {
                    if ($choice->showunanswered) {
                        echo "<td class=\"col{$count} data\" style=\"width:{$tablewidth}%;\">";
                    } else {
                        continue;
                    }
                }
                // added empty row so that when the next iteration is empty,
                // we do not get <table></table> erro from w3c validator
                // MDL-7861
                echo "<table class=\"choiceresponse\"><tr><td></td></tr>";
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:lib.php


示例4: dialogue_get_available_teachers

/**
 * Return a list of teachers that the current user is able to open a dialogue with
 * 
 * Called by dialogue_get_available_users(). The list is used to populate a drop-down
 * list in the UI. The returned array of usernames is filtered to hide teacher names
 * if those teachers have a hidden role assignment, unless the list is being returned
 * for a teacher in which case those hidden teachers are listed
 * @param   object  $dialogue
 * @param   object  $context    for a user in this activity
 * @param   int     $editconversationid
 * @return  array   usernames and ids
 */
function dialogue_get_available_teachers($dialogue, $context, $editconversationid = 0)
{
    global $USER, $CFG;
    $canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
    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');
    }
    // get the list of teachers (actually, those who have dialogue:manage capability)
    $hiddenTeachers = array();
    if ($users = get_users_by_capability($context, 'mod/dialogue:manage', '', null, null, null, null, null, null, true, null)) {
        foreach ($users as $user) {
            $userRoles = get_user_roles($context, $user->id, true);
            foreach ($userRoles as $role) {
                if ($role->hidden == 1) {
                    $hiddenTeachers[$user->id] = 1;
                    break;
                }
            }
        }
        $canSeeHidden = false;
        if (has_capability('moodle/role:viewhiddenassigns', $context)) {
            $canSeeHidden = true;
        }
        $groupid = get_current_group($course->id);
        foreach ($users as $otheruser) {
            // ...exclude self and ...
            if ($USER->id != $otheruser->id) {
                // ...if groupmode is SEPARATEGROUPS then exclude teachers not in student's group
                if ($groupid and groupmode($course, $cm) == SEPARATEGROUPS) {
                    if (!ismember($groupid, $otheruser->id)) {
                        continue;
                    }
                }
                if (!$canSeeHidden && array_key_exists($otheruser->id, $hiddenTeachers) && $hiddenTeachers[$otheruser->id] == 1) {
                    continue;
                }
                // ...any already in open conversations unless multiple conversations allowed
                if ($dialogue->multipleconversations or count_records_select('dialogue_conversations', "dialogueid = {$dialogue->id} AND id != {$editconversationid} AND ((userid = {$USER->id} AND \n                        recipientid = {$otheruser->id}) OR (userid = {$otheruser->id} AND \n                        recipientid = {$USER->id})) AND closed = 0") == 0) {
                    $names[$otheruser->id] = fullname($otheruser);
                }
            }
        }
    }
    if (isset($names)) {
        natcasesort($names);
        return $names;
    }
    return;
}
开发者ID:netspotau,项目名称:moodle-mod_dialogue,代码行数:64,代码来源:locallib.php


示例5: build_logs_array

function build_logs_array($course, $user = 0, $date = 0, $order = "l.time ASC", $limitfrom = '', $limitnum = '', $modname = "", $modid = 0, $modaction = "", $groupid = 0)
{
    // It is assumed that $date is the GMT time of midnight for that day,
    // and so the next 86400 seconds worth of logs are printed.
    /// Setup for group handling.
    /// If the group mode is separate, and this user does not have editing privileges,
    /// then only the user's group can be viewed.
    if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
        $groupid = get_current_group($course->id);
    } else {
        if (!$course->groupmode) {
            $groupid = 0;
        }
    }
    $joins = array();
    if ($course->id != SITEID || $modid != 0) {
        $joins[] = "l.course='{$course->id}'";
    }
    if ($modname) {
        $joins[] = "l.module = '{$modname}'";
    }
    if ('site_errors' === $modid) {
        $joins[] = "( l.action='error' OR l.action='infected' )";
    } else {
        if ($modid) {
            $joins[] = "l.cmid = '{$modid}'";
        }
    }
    if ($modaction) {
        $firstletter = substr($modaction, 0, 1);
        if (preg_match('/[[:alpha:]]/', $firstletter)) {
            $joins[] = "lower(l.action) LIKE '%" . strtolower($modaction) . "%'";
        } else {
            if ($firstletter == '-') {
                $joins[] = "lower(l.action) NOT LIKE '%" . strtolower(substr($modaction, 1)) . "%'";
            }
        }
    }
    /// Getting all members of a group.
    if ($groupid and !$user) {
        if ($gusers = groups_get_members($groupid)) {
            $gusers = array_keys($gusers);
            $joins[] = 'l.userid IN (' . implode(',', $gusers) . ')';
        } else {
            $joins[] = 'l.userid = 0';
            // No users in groups, so we want something that will always be false.
        }
    } else {
        if ($user) {
            $joins[] = "l.userid = '{$user}'";
        }
    }
    if ($date) {
        $enddate = $date + 86400;
        $joins[] = "l.time > '{$date}' AND l.time < '{$enddate}'";
    }
    $selector = implode(' AND ', $joins);
    $totalcount = 0;
    // Initialise
    $result = array();
    $result['logs'] = get_logs($selector, $order, $limitfrom, $limitnum, $totalcount);
    $result['totalcount'] = $totalcount;
    return $result;
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:64,代码来源:lib.php


示例6: get_string

$strweek = get_string('week');
$strtopic = get_string('topic');
$strissued = get_string('issued', 'certificate');
if ($course->format == 'weeks') {
    $table->head = array($strweek, $strname, $strissued);
    $table->align = array('CENTER', 'LEFT');
} else {
    if ($course->format == 'topics') {
        $table->head = array($strtopic, $strname, $strissued);
        $table->align = array('CENTER', 'LEFT', 'LEFT', 'LEFT');
    } else {
        $table->head = array($strname, $strissued);
        $table->align = array('LEFT', 'LEFT', 'LEFT');
    }
}
$currentgroup = get_current_group($course->id);
if ($currentgroup and has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $id))) {
    $group = get_record('groups', 'id', $currentgroup);
    $groupname = " ({$group->name})";
} else {
    $groupname = "";
}
$currentsection = "";
foreach ($certificates as $certificate) {
    if (!$certificate->visible) {
        //Show dimmed if the mod is hidden
        $link = "<a class=\"dimmed\" href=\"view.php?id={$certificate->coursemodule}\">{$certificate->name}</a>";
    } else {
        //Show normal if the mod is visible
        $link = "<a href=\"view.php?id={$certificate->coursemodule}\">{$certificate->name}</a>";
    }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:index.php


示例7: forum_check_text_access

/**
* this function handles the access policy to contents indexed as searchable documents. If this 
* function does not exist, the search engine assumes access is allowed.
* When this point is reached, we already know that : 
* - user is legitimate in the surrounding context
* - user may be guest and guest access is allowed to the module
* - the function may perform local checks within the module information logic
* @param path the access path to the module script code
* @param itemtype the information subclassing (usefull for complex modules, defaults to 'standard')
* @param this_id the item id within the information class denoted by itemtype. In forums, this id 
* points out the individual post.
* @param user the user record denoting the user who searches
* @param group_id the current group used by the user when searching
* @uses CFG, USER
* @return true if access is allowed, false elsewhere
*/
function forum_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id)
{
    global $CFG, $USER;
    include_once "{$CFG->dirroot}/{$path}/lib.php";
    // get the forum post and all related stuff
    $post = get_record('forum_posts', 'id', $this_id);
    $discussion = get_record('forum_discussions', 'id', $post->discussion);
    $context = get_record('context', 'id', $context_id);
    $cm = get_record('course_modules', 'id', $context->instanceid);
    if (empty($cm)) {
        return false;
    }
    // Shirai 20093005 - MDL19342 - course module might have been delete
    if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : hidden forum resource ";
        }
        return false;
    }
    // approval check : entries should be approved for being viewed, or belongs to the user
    if ($post->userid != $USER->id && !$post->mailed && !has_capability('mod/forum:viewhiddentimeposts', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : time hidden forum item";
        }
        return false;
    }
    // group check : entries should be in accessible groups
    $current_group = get_current_group($discussion->course);
    $course = get_record('course', 'id', $discussion->course);
    if ($group_id >= 0 && groupmode($course, $cm) == SEPARATEGROUPS && $group_id != $current_group && !has_capability('mod/forum:viewdiscussionsfromallgroups', $context)) {
        if (!empty($CFG->search_access_debug)) {
            echo "search reject : separated grouped forum item";
        }
        return false;
    }
    return true;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:53,代码来源:forum_document.php


示例8: print_mnet_log_selector_form

function print_mnet_log_selector_form($hostid, $course, $selecteduser = 0, $selecteddate = 'today', $modname = "", $modid = 0, $modaction = '', $selectedgroup = -1, $showcourses = 0, $showusers = 0)
{
    global $USER, $CFG, $SITE;
    require_once $CFG->dirroot . '/mnet/peer.php';
    $mnet_peer = new mnet_peer();
    $mnet_peer->set_id($hostid);
    $sql = "select distinct course, hostid, coursename from {$CFG->prefix}mnet_log";
    $courses = get_records_sql($sql);
    $remotecoursecount = count($courses);
    // first check to see if we can override showcourses and showusers
    $numcourses = $remotecoursecount + count_records_select("course", "", "COUNT(id)");
    if ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && !$showcourses) {
        $showcourses = 1;
    }
    $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
    // Context for remote data is always SITE
    // Groups for remote data are always OFF
    if ($hostid == $CFG->mnet_localhost_id) {
        $context = get_context_instance(CONTEXT_COURSE, $course->id);
        /// Setup for group handling.
        if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
            $selectedgroup = get_current_group($course->id);
            $showgroups = false;
        } else {
            if ($course->groupmode) {
                $selectedgroup = $selectedgroup == -1 ? get_current_group($course->id) : $selectedgroup;
                $showgroups = true;
            } else {
                $selectedgroup = 0;
                $showgroups = false;
            }
        }
    } else {
        $context = $sitecontext;
    }
    // Get all the possible users
    $users = array();
    // If looking at a different host, we're interested in all our site users
    if ($hostid == $CFG->mnet_localhost_id && $course->id != SITEID) {
        if ($selectedgroup) {
            // If using a group, only get users in that group.
            $courseusers = get_group_users($selectedgroup, 'u.lastname ASC', '', 'u.id, u.firstname, u.lastname, u.idnumber');
        } else {
            $courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname, u.idnumber');
        }
    } else {
        $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname, u.idnumber");
    }
    if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
        $showusers = 1;
    }
    if ($showusers) {
        if ($courseusers) {
            foreach ($courseusers as $courseuser) {
                $users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
            }
        }
        if ($guest = get_guest()) {
            $users[$guest->id] = fullname($guest);
        }
    }
    // Get all the hosts that have log records
    $sql = "select distinct\n                h.id,\n                h.name\n            from\n                {$CFG->prefix}mnet_host h,\n                {$CFG->prefix}mnet_log l\n            where\n                h.id = l.hostid\n            order by\n                h.name";
    $hostarray = array();
    $dropdown = array();
    if ($hosts = get_records_sql($sql)) {
        foreach ($hosts as $host) {
            $hostarray[$host->id] = $host->name;
        }
    }
    $hostarray[$CFG->mnet_localhost_id] = $SITE->fullname;
    asort($hostarray);
    // $hostid already exists
    foreach ($hostarray as $hostid_ => $name) {
        $courses = array();
        $sites = array();
        if (has_capability('moodle/site:viewreports', $context) && $showcourses) {
            if ($CFG->mnet_localhost_id == $hostid_) {
                if ($ccc = get_records("course", "", "", "fullname", "id,fullname,category")) {
                    foreach ($ccc as $cc) {
                        if ($cc->id == SITEID) {
                            $sites["{$hostid_}/{$cc->id}"] = format_string($cc->fullname) . ' (' . get_string('site') . ')';
                        } else {
                            $courses["{$hostid_}/{$cc->id}"] = format_string($cc->fullname);
                        }
                    }
                }
            } else {
                $sql = "select distinct course, coursename from mdl_mnet_log where hostid = '{$hostid_}'";
                if ($ccc = get_records_sql($sql)) {
                    foreach ($ccc as $cc) {
                        if (1 == $cc->course) {
                            // TODO: MDL-8187 : this might be wrong - site course may have another id
                            $sites["{$hostid_}/{$cc->course}"] = $cc->coursename . ' (' . get_string('site') . ')';
                        } else {
                            $courses["{$hostid_}/{$cc->course}"] = $cc->coursename;
                        }
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:lib.php


示例9: exercise_print_league_table

function exercise_print_league_table($exercise)
{
    // print an order table of (student) submissions in grade order, only print the student's best submission when
    // there are multiple submissions
    if (!($course = get_record("course", "id", $exercise->course))) {
        error("Print league table: Course is misconfigured");
    }
    $groupid = get_current_group($course->id);
    $nentries = $exercise->showleaguetable;
    if ($nentries == 99) {
        $nentries = 999999;
        // a large number
    }
    if ($exercise->anonymous and isstudent($course->id)) {
        $table->head = array(get_string("title", "exercise"), get_string("grade"));
        $table->align = array("left", "center");
        $table->size = array("*", "*");
    } else {
        // show names
        $table->head = array(get_string("title", "exercise"), get_string("name"), get_string("grade"));
        $table->align = array("left", "left", "center");
        $table->size = array("*", "*", "*");
    }
    $table->cellpadding = 2;
    $table->cellspacing = 0;
    if ($submissions = exercise_get_student_submissions($exercise, "grade", $groupid)) {
        $n = 1;
        foreach ($submissions as $submission) {
            if (empty($done[$submission->userid])) {
                if ($submission->late) {
                    continue;
                }
                if (!($user = get_record("user", "id", $submission->userid))) {
                    error("Print league table: user not found");
                }
                if ($exercise->anonymous and isstudent($course->id)) {
                    $table->data[] = array(exercise_print_submission_title($exercise, $submission), number_format($submission->grade * $exercise->grade / 100.0, 1));
                } else {
                    $table->data[] = array(exercise_print_submission_title($exercise, $submission), fullname($user), number_format($submission->grade * $exercise->grade / 100.0, 1));
                }
                $n++;
                if ($n > $nentries) {
                    break;
                }
                $done[$submission->userid] = 'ok';
            }
        }
        print_heading(get_string("leaguetable", "exercise"));
        print_table($table);
    }
}
开发者ID:r007,项目名称:PMoodle,代码行数:51,代码来源:locallib.php


示例10: grade_download

function grade_download($download, $id)
{
    global $CFG;
    require_login();
    if (!($course = get_record("course", "id", $id))) {
        error("Course ID was incorrect");
    }
    require_capability('moodle/course:viewcoursegrades', get_context_instance(CONTEXT_COURSE, $id));
    $strgrades = get_string("grades");
    $strgrade = get_string("grade");
    $strmax = get_string("maximumshort");
    $stractivityreport = get_string("activityreport");
    /// Check to see if groups are being used in this course
    $currentgroup = get_current_group($course->id);
    if (($currentgroup = get_current_group($course->id)) && groupmode($course) != 0) {
        $students = get_group_students($currentgroup, "u.lastname ASC");
    } else {
        $students = grade_get_course_students($course->id);
    }
    if (!empty($students)) {
        foreach ($students as $student) {
            $grades[$student->id] = array();
            // Collect all grades in this array
            $gradeshtml[$student->id] = array();
            // Collect all grades html formatted in this array
            $totals[$student->id] = array();
            // Collect all totals in this array
        }
    }
    $columns = array();
    // Accumulate column names in this array.
    $columnhtml = array();
    // Accumulate column html in this array.
    /// Collect modules data
    get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
    /// Search through all the modules, pulling out grade data
    $sections = get_all_sections($course->id);
    // Sort everything the same as the course
    for ($i = 0; $i <= $course->numsections; $i++) {
        if (isset($sections[$i])) {
            // should always be true
            $section = $sections[$i];
            if ($section->sequence) {
                $sectionmods = explode(",", $section->sequence);
                foreach ($sectionmods as $sectionmod) {
                    $mod = $mods[$sectionmod];
                    $instance = get_record("{$mod->modname}", "id", "{$mod->instance}");
                    $libfile = "{$CFG->dirroot}/mod/{$mod->modname}/lib.php";
                    if (file_exists($libfile)) {
                        require_once $libfile;
                        $gradefunction = $mod->modname . "_grades";
                        if (function_exists($gradefunction)) {
                            // Skip modules without grade function
                            if ($modgrades = $gradefunction($mod->instance)) {
                                if (!empty($modgrades->maxgrade)) {
                                    if ($mod->visible) {
                                        $maxgrade = "{$strmax}: {$modgrades->maxgrade}";
                                    } else {
                                        $maxgrade = "{$strmax}: {$modgrades->maxgrade}";
                                    }
                                } else {
                                    $maxgrade = "";
                                }
                                $columns[] = "{$mod->modfullname}: " . format_string($instance->name, true) . " - {$maxgrade}";
                                if (!empty($students)) {
                                    foreach ($students as $student) {
                                        if (!empty($modgrades->grades[$student->id])) {
                                            $grades[$student->id][] = $currentstudentgrade = $modgrades->grades[$student->id];
                                        } else {
                                            $grades[$student->id][] = $currentstudentgrade = "";
                                            $gradeshtml[$student->id][] = "";
                                        }
                                        if (!empty($modgrades->maxgrade)) {
                                            $totals[$student->id] = (double) $totals[$student->id] + (double) $currentstudentgrade;
                                        } else {
                                            $totals[$student->id] = (double) $totals[$student->id] + 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // a new Moodle nesting record? ;-)
    /// OK, we have all the data, now present it to the user
    /// OK, we have all the data, now present it to the user
    if ($download == "ods" and confirm_sesskey()) {
        require_once "../lib/odslib.class.php";
        /// Calculate file name
        $downloadfilename = clean_filename("{$course->shortname} {$strgrades}.ods");
        /// Creating a workbook
        $workbook = new MoodleODSWorkbook("-");
        /// Sending HTTP headers
        $workbook->send($downloadfilename);
        /// Adding the worksheet
        $myxls =& $workbook->add_worksheet($strgrades);
        /// Print names of all the fields
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:lib.php


示例11: data_check_text_access

/**
* this function handles the access policy to contents indexed as searchable documents. If this 
* function does not exist, the search engine assumes access is allowed.
* When this point is reached, we already know that : 
* - user is legitimate in the surrounding context
* - user may be guest and guest access is allowed to the module
* - the function may perform local checks within the module information logic
* @param path the access path to the module script code
* @param itemtype the information subclassing (usefull for complex modules, defaults to 'standard')
* @param this_id the item id within the information class denoted by itemtype. In databases, this id 
* points out an indexed data record page.
* @param user the user record denoting the user who searches
* @param group_id the current group used by the user when searching
* @return true if access is allowed, false elsewhere
*/
function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id)
{
    global $CFG;
    // get the database object and all related stuff
    if ($itemtype == 'record') {
        $record = get_record('data_records', 'id', $this_id);
    } elseif ($itemtype == 'comment') {
        $comment = get_record('data_comments', 'id', $this_id);
        $record = get_record('data_records', 'id', $comment->recordid);
    } else {
        // we do not know what type of information is required
        return false;
    }
    $data = get_record('data', 'id', $record->dataid);
    $course = get_record('course', 'id', $data->course);
    $module_context = get_record('context', 'id', $context_id);
    $cm = get_record('course_modules', 'id', $module_context->instanceid);
    if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $module_context)) {
        return false;
    }
    //group consistency check : checks the following situations about groups
    // trap if user is not same group and groups are separated
    $current_group = get_current_group($course->id);
    if (groupmode($course) == SEPARATEGROUPS && !groups_is_member($group_id) && !has_capability('moodle/site:accessallgroups', $module_context)) {
        return false;
    }
    //ownership check : checks the following situations about user
    // trap if user is not owner and has cannot see other's entries
    if ($itemtype == 'record') {
        if ($user->id != $record->userid && !has_capability('mod/data:viewentry', $module_context) && !has_capability('mod/data:manageentries', $module_context)) {
            return false;
        }
    }
    //approval check
    // trap if unapproved and has not approval capabilities
    // TODO : report a potential capability lack of : mod/data:approve
    $approval = get_field('data_records', 'approved', 'id', $record->id);
    if (!$approval && !isteacher($data->course) && !has_capability('mod/data:manageentries', $module_context)) {
        return false;
    }
    //minimum records to view check
    // trap if too few records
    // TODO : report a potential capability lack of : mod/data:viewhiddenentries
    $recordsAmount = count_records('data_records', 'dataid', $data->id);
    if ($data->requiredentriestoview > $recordsAmount && !isteacher($data->course) && !has_capability('mod/data:manageentries', $module_context)) {
        return false;
    }
    //opening periods check
    // trap if user has not capability to see hidden records and date is out of opening range
    // TODO : report a potential capability lack of : mod/data:viewhiddenentries
    $now = usertime(time());
    if ($data->timeviewfrom > 0) {
        if ($now < $data->timeviewfrom && !isteacher($data->course) && !has_capability('mod/data:manageentries', $module_context)) {
            return false;
        }
    }
    if ($data->timeviewto > 0) {
        if ($now > $data->timeviewto && !isteacher($data->course) && !has_capability('mod/data:manageentries', $module_context)) {
            return false;
        }
    }
    return true;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:78,代码来源:data_document.php


示例12: get_questions

function get_questions()
{
    global $conn;
    $sql = 'select * from vcn_data' . (get_current_group() ? ' where group_id="' . get_current_group()->id . '"' : '');
    $rs = mysql_query($sql);
    return $rs;
}
开发者ID:hoangsoft90,项目名称:multichoice-quiz-logic,代码行数:7,代码来源:functions.php


示例13: print_section


//.........这里部分代码省略.........
                if ($ismoving) {
                    if ($mod->id == $USER->activitycopy) {
                        echo "</li>\n";
                        continue;
                    }
                    echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a><br />
                         ';
                }
                $instancename = urldecode($modinfo[$modnumber]->name);
                $instancename = format_string($instancename, true, $course->id);
                if (!empty($modinfo[$modnumber]->extra)) {
                    $extra = urldecode($modinfo[$modnumber]->extra);
                } else {
                    $extra = "";
                }
                if (!empty($modinfo[$modnumber]->icon)) {
                    $icon = "{$CFG->pixpath}/" . urldecode($modinfo[$modnumber]->icon);
                } else {
                    $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif";
                }
                if ($mod->indent) {
                    print_spacer(12, 20 * $mod->indent, false);
                }
                if ($mod->modname == "label") {
                    if (!$mod->visible) {
                        echo "<span class=\"dimmed_text\">";
                    }
                    echo format_text($extra, FORMAT_HTML, $labelformatoptions);
                    if (!$mod->visible) {
                        echo "</span>";
                    }
                } else {
                    // Normal activity
                    //Accessibility: for files get description via icon.
                    $altname = '';
                    if ('resource' == $mod->modname) {
                        if (!empty($modinfo[$modnumber]->icon)) {
                            $possaltname = $modinfo[$modnumber]->icon;
                            $mimetype = mimeinfo_from_icon('type', $possaltname);
                            $altname = get_mimetype_description($mimetype);
                            //get_string($mimetype, 'mimetypes');
                        } else {
                            $altname = $mod->modfullname;
                        }
                    } else {
                        $altname = $mod->modfullname;
                    }
                    // Avoid unnecessary duplication.
                    if (false !== stripos($instancename, $altname)) {
                        $altname = '';
                    }
                    // File type after name, for alphabetic lists.
                    if ($altname) {
                        $altname = get_accesshide(' ' . $altname);
                    }
                    $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
                    echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>';
                }
                if ($usetracking && $mod->modname == 'forum') {
                    $groupmode = groupmode($course, $mod);
                    $groupid = $groupmode == SEPARATEGROUPS && !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id)) ? get_current_group($course->id) : false;
                    if (forum_tp_can_track_forums() && !isset($untracked[$mod->instance])) {
                        $unread = forum_tp_count_forum_unread_posts($USER->id, $mod->instance, $groupid);
                        if ($unread) {
                            echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">';
                            if ($unread == 1) {
                                echo $strunreadpostsone;
                            } else {
                                print_string('unreadpostsnumber', 'forum', $unread);
                            }
                            echo '</a> </span>';
                        }
                    }
                }
                if ($isediting) {
                    // TODO: we must define this as mod property!
                    if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') {
                        if (!($mod->groupmodelink = $groupbuttonslink)) {
                            $mod->groupmode = $course->groupmode;
                        }
                    } else {
                        $mod->groupmode = false;
                    }
                    echo '&nbsp;&nbsp;';
                    echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section);
                }
                echo "</li>\n";
            }
        }
    } elseif ($ismoving) {
        echo "<ul class=\"section\">\n";
    }
    if ($ismoving) {
        echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a></li>
             ';
    }
    if (!empty($section->sequence) || $ismoving) {
        echo "</ul><!--class='section'-->\n\n";
    }
}
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:lib.php


示例14: display_submission

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_current_lang函数代码示例发布时间:2022-05-15
下一篇:
PHP get_current_graph_start函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap