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


PHP isteacherinanycourse函数代码示例

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


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

示例1: create_session_and_responses

 function create_session_and_responses(&$question, &$state, $cmoptions, $attempt)
 {
     // Choose a random shortanswer question from the category:
     // We need to make sure that no question is used more than once in the
     // quiz. Therfore the following need to be excluded:
     // 1. All questions that are explicitly assigned to the quiz
     // 2. All random questions
     // 3. All questions that are already chosen by an other random question
     global $QTYPES;
     if (!isset($cmoptions->questionsinuse)) {
         $cmoptions->questionsinuse = $cmoptions->questions;
     }
     if ($question->options->subcats) {
         // recurse into subcategories
         $categorylist = question_categorylist($question->category);
     } else {
         $categorylist = $question->category;
     }
     $saquestions = $this->get_sa_candidates($categorylist, $cmoptions->questionsinuse);
     $count = count($saquestions);
     $wanted = $question->options->choose;
     $errorstr = '';
     if ($count < $wanted && isteacherinanycourse()) {
         if ($count >= 2) {
             $errorstr = "Error: could not get enough Short-Answer questions!\n                 Got {$count} Short-Answer questions, but wanted {$wanted}.\n                 Reducing number to choose from to {$count}!";
             $wanted = $question->options->choose = $count;
         } else {
             $errorstr = "Error: could not get enough Short-Answer questions!\n                 This can happen if all available Short-Answer questions are already\n                 taken up by other Random questions or Random Short-Answer question.\n                 Another possible cause for this error is that Short-Answer\n                 questions were deleted after this Random Short-Answer question was\n                 created.";
         }
         notify($errorstr);
         $errorstr = '<span class="notifyproblem">' . $errorstr . '</span>';
     }
     if ($count < $wanted) {
         $question->questiontext = "{$errorstr}<br /><br />Insufficient selection options are\n             available for this question, therefore it is not available in  this\n             quiz. Please inform your teacher.";
         // Treat this as a description from this point on
         $question->qtype = DESCRIPTION;
         return true;
     }
     $saquestions = draw_rand_array($saquestions, $question->options->choose);
     // from bug 1889
     foreach ($saquestions as $key => $wrappedquestion) {
         if (!$QTYPES[$wrappedquestion->qtype]->get_question_options($wrappedquestion)) {
             return false;
         }
         // Now we overwrite the $question->options->answers field to only
         // *one* (the first) correct answer. This loop can be deleted to
         // take all answers into account (i.e. put them all into the
         // drop-down menu.
         $foundcorrect = false;
         foreach ($wrappedquestion->options->answers as $answer) {
             if ($foundcorrect || $answer->fraction != 1.0) {
                 unset($wrappedquestion->options->answers[$answer->id]);
             } else {
                 if (!$foundcorrect) {
                     $foundcorrect = true;
                 }
             }
         }
         if (!$QTYPES[$wrappedquestion->qtype]->create_session_and_responses($wrappedquestion, $state, $cmoptions, $attempt)) {
             return false;
         }
         $wrappedquestion->name_prefix = $question->name_prefix;
         $wrappedquestion->maxgrade = $question->maxgrade;
         $cmoptions->questionsinuse .= ",{$wrappedquestion->id}";
         $state->options->subquestions[$key] = clone $wrappedquestion;
     }
     // Shuffle the answers (Do this always because this is a random question type)
     $subquestionids = array_values(array_map(create_function('$val', 'return $val->id;'), $state->options->subquestions));
     $subquestionids = swapshuffle($subquestionids);
     // Create empty responses
     foreach ($subquestionids as $val) {
         $state->responses[$val] = '';
     }
     return true;
 }
开发者ID:veritech,项目名称:pare-project,代码行数:75,代码来源:questiontype.php

示例2: redirect

        redirect("{$CFG->wwwroot}/login/index.php");
    }
}
$strpersonalprofile = get_string('personalprofile');
$strparticipants = get_string("participants");
$struser = get_string("user");
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $coursecontext));
$navlinks = array();
if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) {
    $navlinks[] = array('name' => $strparticipants, 'link' => "index.php?id={$course->id}", 'type' => 'misc');
}
/// If the user being shown is not ourselves, then make sure we are allowed to see them!
if (!$currentuser) {
    if ($course->id == SITEID) {
        // Reduce possibility of "browsing" userbase at site level
        if ($CFG->forceloginforprofiles and !isteacherinanycourse() and !isteacherinanycourse($user->id) and !has_capability('moodle/user:viewdetails', $usercontext)) {
            // Teachers can browse and be browsed at site level. If not forceloginforprofiles, allow access (bug #4366)
            $navlinks[] = array('name' => $struser, 'link' => null, 'type' => 'misc');
            $navigation = build_navigation($navlinks);
            print_header("{$strpersonalprofile}: ", "{$strpersonalprofile}: ", $navigation, "", "", true, "&nbsp;", navmenu($course));
            print_heading(get_string('usernotavailable', 'error'));
            print_footer($course);
            exit;
        }
    } else {
        // Normal course
        // check capabilities
        if (!has_capability('moodle/user:viewdetails', $coursecontext) && !has_capability('moodle/user:viewdetails', $usercontext)) {
            print_error('cannotviewprofile');
        }
        if (!has_capability('moodle/course:view', $coursecontext, $user->id, false)) {
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:view.php

示例3: count_login_failures

/**
 * Returns an object with counts of failed login attempts
 *
 * Returns information about failed login attempts.  If the current user is
 * an admin, then two numbers are returned:  the number of attempts and the
 * number of accounts.  For non-admins, only the attempts on the given user
 * are shown.
 *
 * @param string $mode Either 'admin', 'teacher' or 'everybody'
 * @param string $username The username we are searching for
 * @param string $lastlogin The date from which we are searching
 * @return int
 */
function count_login_failures($mode, $username, $lastlogin)
{
    global $DB;
    $params = array('mode' => $mode, 'username' => $username, 'lastlogin' => $lastlogin);
    $select = "module='login' AND action='error' AND time > :lastlogin";
    $count = new object();
    if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
        // Return information about all accounts
        if ($count->attempts = $DB->count_records_select('log', $select, $params)) {
            $count->accounts = $DB->count_records_select('log', $select, $params, 'COUNT(DISTINCT info)');
            return $count;
        }
    } else {
        if ($mode == 'everybody' or $mode == 'teacher' and isteacherinanycourse()) {
            if ($count->attempts = $DB->count_records_select('log', "{$select} AND info = :username", $params)) {
                return $count;
            }
        }
    }
    return NULL;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:34,代码来源:datalib.php

示例4: fm_print_share_course_members

function fm_print_share_course_members($id, $linkid = NULL, $type = 0, $groupid = 0)
{
    global $CFG, $USER;
    $fmdir = fm_get_root_dir();
    $table->align = array("center", "left", "left", "center");
    $table->width = "60%";
    $table->size = array("15%", "35%", "35%", "20%");
    $table->wrap = array(NULL, 'no', 'no', 'no');
    $table->data = array();
    $strcbx = "<input type=\"checkbox\" name=\"cbu[]\" value=\"0\" onClick=\"selectboxes(this, 1)\">&nbsp;" . get_string("selectall", 'block_file_manager');
    $strlastname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/sharing.php?id={$id}&linkid={$linkid}&tsort=sortlast\">" . get_string("userlastname", 'block_file_manager') . "</a>";
    $strfirstname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/sharing.php?id={$id}&linkid={$linkid}&tsort=sortfirst\">" . get_string("userfirstname", 'block_file_manager') . "</a>";
    $struserrole = "<a href=\"{$CFG->wwwroot}/{$fmdir}/sharing.php?id={$id}&linkid={$linkid}&tsort=sortrole\">" . get_string("userrole", 'block_file_manager') . "</a>";
    $table->head = array($strcbx, $strlastname, $strfirstname, $struserrole);
    if ($id == 1) {
        //adding this block to a site frontpage has been disabled - it's really bad performance wise!
        if (!($allusers = get_records_select("user", 'deleted=0', 'lastname', 'lastname, firstname, id'))) {
            $table->data[] = array("", "<center><i><b>" . get_string("msgnocourseusers", 'block_file_manager') . "</b></i></center>");
        } else {
            //echo "please choose a course, from which, to share resources";
            echo get_string('cannotsharefromsitelevel', 'block_file_manager');
            continue;
            // nadavkav . too much load on the server :-(
            // Prints all roles of user throughout site
            foreach ($allusers as $key => $au) {
                $allusers[$key]->role = NULL;
                if (has_capability('moodle/legacy:admin', get_context_instance(CONTEXT_SYSTEM), $au->id, false)) {
                    $allusers[$key]->role = "Admin ";
                    $allusers[$key]->userid = $au->id;
                }
                if (isteacherinanycourse($au->id, false)) {
                    if ($allusers[$key]->role) {
                        $slash = "/";
                    }
                    $allusers[$key]->role .= "{$slash} Teacher ";
                    $allusers[$key]->userid = $au->id;
                }
                if (record_exists('role_assignments', 'userid', $au->id)) {
                    $slash = "";
                    if ($allusers[$key]->role) {
                        $slash = "/";
                    }
                    $allusers[$key]->role .= "{$slash} Student ";
                    $allusers[$key]->userid = $au->id;
                }
            }
        }
    } else {
        // We try to select any user who is in this course, his name and his role
        // deprecated
        //       $sqltoexecute = "SELECT {$CFG->prefix}user.id, {$CFG->prefix}user.firstname, {$CFG->prefix}user.lastname, {$CFG->prefix}role.name
        //                         FROM {$CFG->prefix}user, {$CFG->prefix}course_display, {$CFG->prefix}role_assignments, {$CFG->prefix}role
        //                         WHERE (course = $id AND {$CFG->prefix}course_display.userid = {$CFG->prefix}user.id
        //                           AND {$CFG->prefix}user.id = {$CFG->prefix}role_assignments.userid
        //                           AND {$CFG->prefix}role_assignments.roleid = {$CFG->prefix}role.id)";
        //  a better way to get roles of users in a course , for Moodle v1.9.x (nadavkav patch)
        $sqltoexecute = "SELECT u.id, u.firstname, u.lastname, r.name\n                        FROM {$CFG->prefix}user u\n                        JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id\n                        JOIN {$CFG->prefix}role r ON ra.roleid = r.id\n                        JOIN {$CFG->prefix}context con ON ra.contextid = con.id\n                        JOIN {$CFG->prefix}course c ON c.id = con.instanceid AND con.contextlevel = 50\n                        WHERE (r.shortname = 'student' OR r.shortname = 'teacher' OR r.shortname = 'editingteacher') AND c.id = {$id}";
        //echo $sqltoexecute;
        // If there is nobody in this course, then print the message "no users in this course"
        if (!($allpersons = get_records_sql($sqltoexecute))) {
            $table->data[] = array("", "<center><i><b>" . get_string("msgnocourseusers", "block_file_manager") . "</b></i></center>");
        } else {
            // Gives all users their role in the course
            $allusers = array();
            if ($allpersons) {
                foreach ($allpersons as $key => $au) {
                    //$tmp = get_record("user", "id", $au->userid);
                    $allusers[$au->id]->role = $au->name;
                    $allusers[$au->id]->lastname = $au->lastname;
                    $allusers[$au->id]->firstname = $au->firstname;
                    $allusers[$au->id]->userid = $au->id;
                }
            }
        }
    }
    if ($allusers) {
        $sharetoall = false;
        // checks if file is shared to all
        if (count_records_sql("SELECT * FROM {$CFG->prefix}fmanager_shared WHERE owner = '{$USER->id}' AND course = '{$id}' AND userid = '0' AND sharedlink = '{$linkid}' AND type = '{$type}'")) {
            $sharetoall = true;
        }
        foreach ($allusers as $au) {
            if ($au->userid != $USER->id) {
                // Cant share to yourself
                if ($linkid != NULL) {
                    $thecount = 0;
                    if ($sharetoall) {
                        $thecount = 1;
                    } else {
                        if ($groupid != 0) {
                            $mysql = "SELECT * FROM {$CFG->prefix}fmanager_shared WHERE owner = '{$groupid}' AND course = '{$id}' AND userid = '{$au->userid}' AND sharedlink = '{$linkid}' AND type = '{$type}'";
                        } else {
                            $mysql = "SELECT * FROM {$CFG->prefix}fmanager_shared WHERE owner = '{$USER->id}' AND course = '{$id}' AND userid = '{$au->userid}' AND sharedlink = '{$linkid}' AND type = '{$type}'";
                        }
                        $thecount = count_records_sql($mysql);
                    }
                    if ($thecount > 0) {
                        $cbx = "<input type=\"checkbox\" name=\"cbu[]\" value=\"{$au->userid}\" checked>";
                    } else {
                        $cbx = "<input type=\"checkbox\" name=\"cbu[]\" value=\"{$au->userid}\">";
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:print_lib.php

示例5: count_login_failures

/**
 * Returns an object with counts of failed login attempts
 *
 * Returns information about failed login attempts.  If the current user is
 * an admin, then two numbers are returned:  the number of attempts and the
 * number of accounts.  For non-admins, only the attempts on the given user
 * are shown.
 *
 * @param string $mode Either 'admin', 'teacher' or 'everybody'
 * @param string $username The username we are searching for
 * @param string $lastlogin The date from which we are searching
 * @return int
 */
function count_login_failures($mode, $username, $lastlogin)
{
    $select = 'module=\'login\' AND action=\'error\' AND time > ' . $lastlogin;
    if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
        // Return information about all accounts
        if ($count->attempts = count_records_select('log', $select)) {
            $count->accounts = count_records_select('log', $select, 'COUNT(DISTINCT info)');
            return $count;
        }
    } else {
        if ($mode == 'everybody' or $mode == 'teacher' and isteacherinanycourse()) {
            if ($count->attempts = count_records_select('log', $select . ' AND info = \'' . $username . '\'')) {
                return $count;
            }
        }
    }
    return NULL;
}
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:datalib.php

示例6: tag_print_user_box

/**
 * Prints an individual user box
 *
 * @param $user user object (contains the following fields: id, firstname, lastname and picture)
 * @param $return if true return html string
 */
function tag_print_user_box($user, $return = false)
{
    global $CFG;
    $textlib = textlib_get_instance();
    $usercontext = get_context_instance(CONTEXT_USER, $user->id);
    $profilelink = '';
    if (has_capability('moodle/user:viewdetails', $usercontext) || isteacherinanycourse($user->id)) {
        $profilelink = $CFG->wwwroot . '/user/view.php?id=' . $user->id;
    }
    $output = print_box_start('user-box', 'user' . $user->id, true);
    $fullname = fullname($user);
    $alt = '';
    if (!empty($profilelink)) {
        $output .= '<a href="' . $profilelink . '">';
        $alt = $fullname;
    }
    //print user image - if image is only content of link it needs ALT text!
    if ($user->picture) {
        $output .= '<img alt="' . $alt . '" class="user-image" src="' . $CFG->wwwroot . '/user/pix.php/' . $user->id . '/f1.jpg" />';
    } else {
        $output .= '<img alt="' . $alt . '" class="user-image" src="' . $CFG->wwwroot . '/pix/u/f1.png" />';
    }
    $output .= '<br />';
    if (!empty($profilelink)) {
        $output .= '</a>';
    }
    //truncate name if it's too big
    if ($textlib->strlen($fullname) > 26) {
        $fullname = $textlib->substr($fullname, 0, 26) . '...';
    }
    $output .= '<strong>' . $fullname . '</strong>';
    $output .= print_box_end(true);
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:44,代码来源:locallib.php

示例7: elluminate_recent_recordings

/**
 * Get a list of recent recorded meetings based upon the user's system authority:
 *  - admins can see all recent meeting recordings
 *  - teachers see recent recordings in their courses
 *  - students see recent recordings they participated in
 *
 * The return array is of the format where each entry is an object that consists
 * of the following information:
 *
 *  $entry->name        = meeting name
 *  $entry->recordingid = recording ID
 *
 * @uses $USER
 * @param none
 * @return array An array of recorded meeting information.
 */
function elluminate_recent_recordings()
{
    global $USER;
    /*
        if (!$elmuser = get_record('elluminate_users', 'userid', $USER->id)) {
            return NULL;
        }
    */
    /// Get the five most recent recordings.
    if (!($recordings = get_records('elluminate_recordings', '', '', 'created DESC', '*', '', 5))) {
        return NULL;
    }
    $return = array();
    $type = 'student';
    if (isadmin($USER->id)) {
        $type = 'admin';
    } else {
        if (isteacherinanycourse($USER->id, false)) {
            $type = 'teacher';
        }
    }
    $rids = array();
    foreach ($recordings as $recording) {
        $meeting = get_record('elluminate', 'meetingid', $recording->meetingid);
        $meeting->name = stripslashes($meeting->name);
        if (in_array($meeting->id, $rids)) {
            continue;
        }
        if ($meeting->private == false) {
            $return[] = createRecordingEntry($meeting, $recording);
        } else {
            // ## REFACTOR THIS MESS!!!!
            switch ($type) {
                case 'admin':
                    $return[] = createRecordingEntry($meeting, $recording);
                    break;
                case 'teacher':
                    if (isteacher($meeting->course, $USER->id, false)) {
                        $return[] = createRecordingEntry($meeting, $recording);
                    }
                    break;
                case 'student':
                    if (elluminate_is_participant($recording->meetingid, $USER->id)) {
                        $return[] = createRecordingEntry($meeting, $recording);
                    }
                    break;
                default:
                    break;
            }
        }
    }
    return $return;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:69,代码来源:lib.php

示例8: array_shift

$questionid = (int) array_shift($args);
$relativepath = implode('/', $args);
if (!($question = get_record('question', 'id', $questionid))) {
    error('No valid arguments supplied');
}
if (!($questioncategory = get_record('question_categories', 'id', $question->category))) {
    error('No valid arguments supplied');
}
/////////////////////////////////////
// Check access
/////////////////////////////////////
if ($quizid == 0) {
    // teacher doing preview during quiz creation
    if ($questioncategory->publish) {
        require_login();
        if (!isteacherinanycourse()) {
            error('No valid arguments supplied');
        }
    } else {
        require_login($questioncategory->course);
        $cm = get_coursemodule_from_instance('quiz', $quizid);
        require_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id));
    }
} else {
    if (!($quiz = get_record('quiz', 'id', $quizid))) {
        error('No valid arguments supplied');
    }
    if (!($course = get_record('course', 'id', $quiz->course))) {
        error('No valid arguments supplied');
    }
    require_login($course->id);
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:quizfile.php

示例9: view_dates

 function view_dates()
 {
     global $CFG, $USER;
     $rday = optional_param('rday', NULL, PARAM_INT);
     $rslot = optional_param('rslot', NULL, PARAM_INT);
     $delete = optional_param('delete', NULL, PARAM_INT);
     $resid = optional_param('resid', NULL, PARAM_INT);
     $uid = optional_param('uid', NULL, PARAM_INT);
     require_once "../../config.php";
     $cmid = $this->cm->id;
     if (!($course = get_record('course', 'id', $this->cm->course))) {
         error('Course is misconfigured');
     }
     $itemid = $this->bookings->itemid;
     $username = $USER->username;
     $UID = $USER->id;
     $firstname = $USER->firstname;
     $lastname = $USER->lastname;
     if ($firstname == '' or $lastname == '') {
         return "";
     }
     $html .= '<form name=myform id=myform method=post action="view.php?id=' . $cmid . '">';
     $proplist = bookings_item_properties($itemid);
     $days = explode(',', 'A,B,C,D,E,F');
     $daylimits = array();
     if (isset($proplist['days']) and $proplist['days'] != '') {
         $days = explode(',', $proplist['days']);
         $dag = 0;
         foreach ($days as $day) {
             list($dy, $lim) = explode(':', $day);
             // pick out optional size limit
             $days[$dag] = $dy;
             $daylimits[$dag] = (int) $lim;
             $dag++;
         }
     }
     $widthprcent = (int) (95 / count($days));
     // default width
     $slots = explode(',', '1,2,3,4,5,6');
     $slotlimits = array();
     if (isset($proplist['slots']) and $proplist['slots'] != '') {
         $slots = explode(',', $proplist['slots']);
         $slt = 0;
         foreach ($slots as $slot) {
             list($sl, $lim) = explode(':', $slot);
             // pick out optional size limit
             $slots[$slt] = $sl;
             $slotlimits[$slt] = (int) $lim;
             $slt++;
         }
     }
     $multiple = 0;
     if (isset($proplist['multiple'])) {
         $multiple = (int) $proplist['multiple'];
     }
     $exclusive = 'non';
     // many entries pr user
     if (isset($proplist['exclusive'])) {
         $exclusive = $proplist['exclusive'];
     }
     $can_edit = 1;
     // any user can make a booking
     if (isset($proplist['edit_group'])) {
         $can_edit = isadmin() ? 1 : 0;
         if ($proplist['edit_group'] == 'teachers' and isteacherinanycourse($USER->id)) {
             $can_edit = 1;
         } else {
             if ($proplist['edit_group'] == 'students') {
                 $can_edit = 1;
             } else {
                 $can_edit = isteacherinanycourse($USER->id) ? 1 : 0;
                 // default is teachers can make a booking
             }
         }
     }
     $privilege = isteacherinanycourse($USER->id) ? isadmin() ? 2 : 1 : 0;
     /// here we fetch out all reservations
     $sql = 'SELECT * FROM ' . $CFG->prefix . 'bookings_calendar 
             WHERE eventtype="reservation" 
             AND bookingid=' . $this->bookings->id;
     $reservation = array();
     $daycount = array();
     // count of reservations pr day (colcount)
     $slotcount = array();
     // count of reservations pr slot (rowcount)
     $total = 0;
     if ($res = get_records_sql($sql)) {
         foreach ($res as $re) {
             $reservation[$re->day][$re->slot][] = $re;
             $reservation[$re->day][$re->slot]->res = $re;
             $daycount[$re->day] += 1;
             $slotcount[$re->slot] += 1;
             $total++;
         }
     }
     /// this is where we make the reservation or delete reservations
     if ((isset($resid) and isset($uid) or isset($rday) and isset($rslot)) and $can_edit) {
         if (!isteacherinanycourse($USER->id) and !isadmin() and isset($reservation[$rday][$rslot])) {
             if ($uid != $UID) {
                 // return;  // assume an attempt to phreak the system with params
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:bookings.class.php

示例10: error

if (!($questions = get_records('question', 'id', $id))) {
    error('Could not load question');
}
if ($maxgrade = get_field('quiz_question_instances', 'grade', 'quiz', $quiz->id, 'question', $id)) {
    $questions[$id]->maxgrade = $maxgrade;
} else {
    $questions[$id]->maxgrade = $questions[$id]->defaultgrade;
}
$quiz->id = 0;
// just for safety
$quiz->questions = $id;
if (!($category = get_record("question_categories", "id", $questions[$id]->category))) {
    error("This question doesn't belong to a valid category!");
}
$quiz->course = $category->course;
if (!(has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $category->course)) || $category->publish && isteacherinanycourse())) {
    error("You can't preview these questions!");
}
// Load the question type specific information
if (!get_question_options($questions)) {
    error(get_string('newattemptfail', 'quiz'));
}
// Create a dummy quiz attempt
// TODO: find out what of the following we really need. What is $attempt
//       really used for?
$timenow = time();
$attempt->quiz = $quiz->id;
$attempt->userid = $USER->id;
$attempt->attempt = 0;
$attempt->sumgrades = 0;
$attempt->timestart = $timenow;
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:preview.php

示例11: send_file_not_found

         send_file_not_found();
     }
     session_get_instance()->write_close();
     // unlock session during fileserving
     send_stored_file($file, 60 * 60, 0, false);
     // TODO: change timeout?
 } else {
     if ($filearea === 'user_profile') {
         $userid = (int) array_shift($args);
         $usercontext = get_context_instance(CONTEXT_USER, $userid);
         if (!empty($CFG->forceloginforprofiles)) {
             require_login();
             if (isguestuser()) {
                 print_error('noguest');
             }
             if (!isteacherinanycourse() and !isteacherinanycourse($userid) and !has_capability('moodle/user:viewdetails', $usercontext)) {
                 print_error('usernotavailable');
             }
             if (!has_capability('moodle/user:viewdetails', $context) && !has_capability('moodle/user:viewdetails', $usercontext)) {
                 print_error('cannotviewprofile');
             }
             if (!has_capability('moodle/course:view', $context, $userid, false)) {
                 print_error('notenrolledprofile');
             }
             if (groups_get_course_groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
                 print_error('groupnotamember');
             }
         }
         $relativepath = '/' . implode('/', $args);
         $fullpath = $usercontext->id . 'user_profile0' . $relativepath;
         if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:pluginfile.php

示例12: error

<?php

// $Id: export.php,v 1.11 2009/08/29 05:24:22 bdaloukas Exp $
/**
 * This page edits the bottom text of a game
 * 
 * @author  bdaloukas
 * @version $Id: export.php,v 1.11 2009/08/29 05:24:22 bdaloukas Exp $
 * @package game
 **/
require_once "../../config.php";
require_once "lib.php";
require_once "locallib.php";
require_once "exportjavame.php";
require_once "exporthtml.php";
if (!isteacherinanycourse($USER->id)) {
    error(get_string('only_teachers', 'game'));
}
if (array_key_exists('action', $_POST)) {
    $update = (int) $_POST['update'];
    $gameid = get_field_select("course_modules", "instance", "id={$update}");
    game_OnExport($gameid);
    die;
}
$update = (int) $_GET['update'];
$gameid = get_field_select("course_modules", "instance", "id={$update}");
$_GET['id'] = $update;
require_once "header.php";
echo '<form name="form" method="post" action="export.php">';
$game = get_record_select('game', "id={$gameid}", 'id,name,gamekind');
switch ($_GET['target']) {
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:export.php

示例13: specialization

 /**
  * Standard block API function for initializing/preparing/changing block settings/variables
  * See block_course_summary.php for a good example
  *
  * @uses $COURSE
  * @uses $SITE
  * @return void
  */
 function specialization()
 {
     //At this point, $this->instance and $this->config are available
     //for use. We can now change the title, etc. to whatever we want. E.g.
     //$this->title = $this->config->variable_holding_the_title
     global $COURSE, $SITE;
     //Cr: $course replaced with $COURSE
     /// Need the bigger course object.
     if ($this->instance->pageid == SITEID) {
         //Cr: if this block appears on the front page which is course id # 1
         //and category # 0 in the course table,
         $this->course = $SITE;
         //start with $SITE which is initialized by get_site() in lib/setup.php
         //which normally returns 1
     } else {
         //Cr: else block appears on a course page, so start with this course
         $this->course = $COURSE;
         //Cr: $course replaced with $COURSE
         //Cr: According to MoodleDocs:Development:Blocks you could also use
         //$this->course = get_record('course', 'id', $this->instance->pageid);
     }
     $this->admin = false;
     //Cr: initialize local variables
     $this->teacher = false;
     $this->mycact = false;
     //Cr: do not show active courses, only for admins
     $this->mycinact = false;
     //Cr: do not show inactive courses, only for admins and teachers
     $this->mycmyc = true;
     //Cr: show myCourses, only for teachers and students
     if (isadmin()) {
         //Cr: admins see ALL courses and may choose to show/hide in the header of the block
         $this->set_admin_options();
         //Cr: to show/hide given courses for admins
         $this->admin = true;
     }
     if (isteacherinanycourse()) {
         //Cr: teachers see ONLY courses they teach in and may choose to show/hide in the header of the block
         $this->set_teacher_options();
         //Cr: to show/hide given courses for teachers
         $this->teacher = true;
         //Cr: changed name of member variable $this->marker to $this->teacher
         //to better reflect admin and teacher options
     }
     //Cr: we no longer use the next line because it is recommended to use only one title for the block.
     //We load it already in the init() function. If you need a more dynamic title it could be set here.
     //$this->title = get_string('displaytitle', 'block_myCourses');
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:56,代码来源:block_myCourses.php

示例14: fm_get_user_int_type

function fm_get_user_int_type()
{
    $systemcontext = get_context_instance(CONTEXT_SYSTEM, 0);
    if (has_capability('moodle/site:doanything', $systemcontext)) {
        $usertype = 0;
    } else {
        if (isteacherinanycourse('0', false)) {
            $usertype = 1;
        } else {
            $usertype = 2;
        }
    }
    return $usertype;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:14,代码来源:lib.php

示例15: redirect

<?php

// $Id: enrol.php,v 1.50.2.1 2008/03/03 05:27:36 moodler Exp $
// Depending on the current enrolment method, this page
// presents the user with whatever they need to know when
// they try to enrol in a course.
require_once "../config.php";
require_once "lib.php";
require_once "{$CFG->dirroot}/enrol/enrol.class.php";
if (isloggedin() and !isguest()) {
    if (!iscreator() and !isteacherinanycourse()) {
        redirect($CFG->wwwroot . '/index.php');
    }
} else {
    redirect($CFG->wwwroot . '/index.php');
}
$id = required_param('id', PARAM_INT);
// Masoud Sadjadi: PARAM_ALPHANUM changed to PARAM_RAW to support emails being passed as user names.
// $username     = required_param('username', PARAM_ALPHANUM);
$username = required_param('username', PARAM_RAW);
$loginasguest = optional_param('loginasguest', 0, PARAM_BOOL);
// hmm, is this still needed?
if (!isloggedin()) {
    // do not use require_login here because we are usually comming from it
    redirect(get_login_url());
}
if (!($course = get_record('course', 'id', $id))) {
    print_error("That's an invalid course id");
}
if (!($context = get_context_instance(CONTEXT_COURSE, $course->id))) {
    print_error("That's an invalid course id");
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:auto_enrol.php


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