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


PHP get_recordset_select函数代码示例

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


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

示例1: elis_cron

/**
 * Run scheduled tasks according to a cron spec.
 */
function elis_cron()
{
    global $CFG;
    require $CFG->dirroot . '/elis/core/lib/tasklib.php';
    $timenow = time();
    // get all tasks that are (over-)due
    $tasks = get_recordset_select('elis_scheduled_tasks', 'nextruntime <= ' . $timenow, 'nextruntime ASC');
    if (empty($tasks)) {
        return;
    }
    while ($task = rs_fetch_next_record($tasks)) {
        $starttime = microtime();
        mtrace("Running {$task->callfunction}({$task->taskname}) from {$task->plugin}...");
        if ($task->enddate !== null && $task->enddate < $timenow) {
            mtrace('* Cancelling task: past end date');
            delete_records('elis_scheduled_tasks', 'id', $task->id);
            continue;
        }
        // FIXME: check for blocking tasks
        // FIXME: check if task is locked
        // See if some other cron has already run the function while we were
        // doing something else -- if so, skip it.
        $nextrun = get_field('elis_scheduled_tasks', 'nextruntime', 'id', $task->id);
        if ($nextrun > $timenow) {
            mtrace('* Skipped (someone else already ran it)');
            continue;
        }
        // calculate the next run time
        $newtask = new stdClass();
        $newtask->id = $task->id;
        $newtask->lastruntime = time();
        $newtask->nextruntime = cron_next_run_time($newtask->lastruntime, (array) $task);
        // see if we have any runs left
        if ($task->runsremaining !== null) {
            $newtask->runsremaining = $task->runsremaining - 1;
            if ($newtask->runsremaining <= 0) {
                mtrace('* Cancelling task: no runs left');
                delete_records('elis_scheduled_tasks', 'id', $task->id);
            } else {
                update_record('elis_scheduled_tasks', $newtask);
            }
        } else {
            update_record('elis_scheduled_tasks', $newtask);
        }
        // load the file and call the function
        if ($task->callfile) {
            $callfile = $CFG->dirroot . $task->callfile;
            if (!is_readable($callfile)) {
                mtrace('* Skipped (file not found)');
                continue;
            }
            require_once $callfile;
        }
        call_user_func(unserialize($task->callfunction), $task->taskname);
        $difftime = microtime_diff($starttime, microtime());
        mtrace("* {$difftime} seconds");
    }
}
开发者ID:benavidesrobert,项目名称:elis.base,代码行数:61,代码来源:cron.php

示例2: add_selection_all

function add_selection_all($ufiltering)
{
    global $SESSION;
    $guest = get_guest();
    $sqlwhere = $ufiltering->get_sql_filter("id<>{$guest->id} AND deleted <> 1");
    if ($rs = get_recordset_select('user', $sqlwhere, 'fullname', 'id,' . sql_fullname() . ' AS fullname')) {
        while ($user = rs_fetch_next_record($rs)) {
            if (!isset($SESSION->bulk_users[$user->id])) {
                $SESSION->bulk_users[$user->id] = $user->id;
            }
        }
        rs_close($rs);
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:14,代码来源:lib.php

示例3: note_list

/**
 * Retrieves a list of note objects with specific atributes.
 *
 * @param int    $courseid id of the course in which the notes were posted (0 means any)
 * @param int    $userid id of the user to which the notes refer (0 means any)
 * @param string $state state of the notes (i.e. draft, public, site) ('' means any)
 * @param int    $author id of the user who modified the note last time (0 means any)
 * @param string $order an order to sort the results in
 * @param int    $limitfrom number of records to skip (offset)
 * @param int    $limitnum number of records to fetch
 * @return array of note objects
 */
function note_list($courseid = 0, $userid = 0, $state = '', $author = 0, $order = 'lastmodified DESC', $limitfrom = 0, $limitnum = 0)
{
    // setup filters
    $selects = array();
    if ($courseid) {
        $selects[] = 'courseid=' . $courseid;
    }
    if ($userid) {
        $selects[] = 'userid=' . $userid;
    }
    if ($author) {
        $selects[] = 'usermodified=' . $author;
    }
    if ($state) {
        $selects[] = "publishstate='{$state}'";
    }
    $selects[] = "module='notes'";
    $select = implode(' AND ', $selects);
    $fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';
    // retrieve data
    $rs =& get_recordset_select('post', $select, $order, $fields, $limitfrom, $limitnum);
    return recordset_to_array($rs);
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:35,代码来源:lib.php

示例4: bulkexport_submit

function bulkexport_submit(Pieform $form, $values)
{
    global $SESSION;
    $usernames = array();
    // Read in the usernames explicitly specified
    foreach (explode("\n", $values['usernames']) as $username) {
        $username = trim($username);
        if (!empty($username)) {
            $usernames[] = $username;
        }
    }
    if (empty($usernames) and !empty($values['authinstance'])) {
        // Export all users from the selected institution
        $rs = get_recordset_select('usr', 'authinstance = ? AND deleted = 0', array($values['authinstance']), '', 'username');
        while ($record = $rs->FetchRow()) {
            $usernames[] = $record['username'];
        }
    }
    $SESSION->set('exportdata', $usernames);
    $smarty = smarty();
    $smarty->assign('heading', '');
    $smarty->display('admin/users/bulkdownload.tpl');
    exit;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:24,代码来源:bulkexport.php

示例5: required_param

* @param string $folio_control_page_edit_security_custom The custom level of security for the page.
**/
// Note, this is ../ insead of ../../../ because we're called by files in /_folio, and not from the folder that this
//	page is actually residing inside of.
require_once '../includes.php';
$security_ident = -1;
// Load variables
$page_ident = required_param('page_ident', PARAM_INT);
$security_type = optional_param('folio_control_page_edit_security_type', '-1');
$security_parent = optional_param('folio_control_page_edit_security_parent', -1, PARAM_INT);
$security_custom = optional_param('folio_control_page_edit_security_custom', '-1');
// Test to see if we're logged in.
if (!isloggedin()) {
    // Since the user isn't logged in, don't allow them to change the security settings for the page.
    //	Get the previous copy's information.
    $pages = recordset_to_array(get_recordset_select('folio_page', "page_ident = {$page_ident} and newest= 1", null, 'title', '*'));
    if (!$pages[$page_ident]) {
        // Not found.
        error(' Unable to retrieve old record in folio_actions on line 46 for page ' . $page_ident . '.  You may have tried to create a new page without logging in.' . '  Please log in and try again.');
    } else {
        $security_ident = $pages[$page_ident]->security_ident;
    }
} else {
    // Since we're logged in, allow user to set permissions.
    // Check to see if we're inheriting.
    if ($security_type == 'Parent') {
        // Inheriting
        $security_ident = $security_parent;
    } else {
        // Set to a custom security level.  We'll need to insert/update the security record.
        $security_ident = $page_ident;
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:31,代码来源:page_edit_security_post.php

示例6: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuil, empty means all
 * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
 */
function rebuild_course_cache($courseid = 0, $clearonly = false)
{
    global $COURSE;
    if ($clearonly) {
        $courseselect = empty($courseid) ? "" : "id = {$courseid}";
        set_field_select('course', 'modinfo', null, $courseselect);
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id) {
            $COURSE->modinfo = null;
        }
        // reset the fast modinfo cache
        $reset = 'reset';
        get_fast_modinfo($reset);
        return;
    }
    if ($courseid) {
        $select = "id = '{$courseid}'";
    } else {
        $select = "";
        @set_time_limit(0);
        // this could take a while!   MDL-10954
    }
    if ($rs = get_recordset_select("course", $select, '', 'id,fullname')) {
        while ($course = rs_fetch_next_record($rs)) {
            $modinfo = serialize(get_array_of_activities($course->id));
            if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
                notify("Could not cache module information for course '" . format_string($course->fullname) . "'!");
            }
            // update cached global COURSE too ;-)
            if ($course->id == $COURSE->id) {
                $COURSE->modinfo = $modinfo;
            }
        }
        rs_close($rs);
    }
    // reset the fast modinfo cache
    $reset = 'reset';
    get_fast_modinfo($reset);
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:44,代码来源:lib.php

示例7: user_activity_task_process

/**
 * Process a chunk of the task
 *
 * @param array $state the task state
 */
function user_activity_task_process(&$state)
{
    global $CFG;
    $sessiontimeout = $state['sessiontimeout'];
    $sessiontail = $state['sessiontail'];
    $starttime = $state['starttime'];
    // find the record ID corresponding to our start time
    $startrec = get_field_select('log', 'MIN(id)', "time >= {$starttime}");
    $startrec = empty($startrec) ? 0 : $startrec;
    // find the last record that's close to our chunk size, without
    // splitting a second between runs
    $endtime = get_field_select('log', 'MIN(time)', 'id >= ' . ($startrec + USERACT_RECORD_CHUNK));
    if (!$endtime) {
        $endtime = time();
    }
    // Get the logs between the last time we ran, and the current time.  Sort
    // by userid (so all records for a given user are together), and then by
    // time (so that we process a user's logs sequentially).
    $recstarttime = max(0, $starttime - $state['sessiontimeout']);
    $rs = get_recordset_select('log', "time >= {$recstarttime} AND time < {$endtime} AND userid != 0", 'userid, time');
    if ($CFG->debug >= DEBUG_ALL) {
        mtrace("* processing records from time:{$starttime} to time:{$endtime}");
    }
    $curuser = -1;
    $session_start = 0;
    $last_course = -1;
    $module_session_start = 0;
    $last_module = -1;
    $last_time = 0;
    if ($rs) {
        while ($rec = rs_fetch_next_record($rs)) {
            if ($rec->userid != $curuser) {
                // end of user's record
                if ($curuser > 0 && $session_start > 0) {
                    // flush current session data
                    if ($last_time > $endtime - $sessiontimeout) {
                        /* Last record is within the session timeout of our end
                         * time for this run.  Just use our last logged time as
                         * the session end time, and the rest will be picked up
                         * by the next run of the sessionizer. */
                        $session_end = $last_time;
                    } else {
                        /* Last record is not within the session timeout of our
                         * end time for this run, so do our normal session
                         * ending. */
                        $session_end = $last_time + $sessiontail;
                    }
                    user_activity_add_session($curuser, $last_course, $session_start, $session_end);
                    if ($last_module > 0) {
                        user_module_activity_add_session($curuser, $last_course, $last_module, $module_session_start, $session_end);
                    }
                }
                $curuser = $rec->userid;
                $session_start = 0;
                $last_course = -1;
                $module_session_start = 0;
                $last_module = -1;
                $last_time = 0;
            }
            if ($rec->time < $starttime) {
                // Find the last log for the user before our start time, that's
                // within the session timeout, and start the session with that
                // record.
                $session_start = $rec->time;
                $last_time = $rec->time;
                $last_course = $rec->course;
                $module_session_start = $rec->time;
                $last_module = $rec->cmid;
            } elseif ($rec->time > $last_time + $sessiontimeout) {
                if ($last_course >= 0) {
                    // session timed out -- add record
                    if (defined('ETLUA_EXTRA_DEBUG') && $CFG->debug >= DEBUG_DEVELOPER) {
                        mtrace('** session timed out');
                    }
                    $session_end = $last_time + $sessiontail;
                    user_activity_add_session($curuser, $last_course, $session_start, $session_end);
                    if ($last_module > 0) {
                        user_module_activity_add_session($curuser, $last_course, $last_module, $module_session_start, $session_end);
                    }
                }
                // start a new session with the current record
                $session_start = $rec->time;
                $last_course = $rec->course;
                $module_session_start = $rec->time;
                $last_module = $rec->cmid;
            } elseif ($rec->action === 'logout') {
                // user logged out -- add record
                if (defined('ETLUA_EXTRA_DEBUG') && $CFG->debug >= DEBUG_DEVELOPER) {
                    mtrace('** user logged out');
                }
                $session_end = $rec->time;
                user_activity_add_session($curuser, $last_course, $session_start, $session_end);
                if ($last_module > 0) {
                    user_module_activity_add_session($curuser, $last_course, $last_module, $module_session_start, $session_end);
                }
//.........这里部分代码省略.........
开发者ID:remotelearner,项目名称:elis.cm,代码行数:101,代码来源:etl.php

示例8: fetch_all_helper

 /**
  * Factory method - uses the parameters to retrieve all matching instances from the DB.
  * @static final protected
  * @return mixed array of object instances or false if not found
  */
 function fetch_all_helper($table, $classname, $params)
 {
     $instance = new $classname();
     $classvars = (array) $instance;
     $params = (array) $params;
     $wheresql = array();
     // remove incorrect params
     foreach ($params as $var => $value) {
         if (!in_array($var, $instance->required_fields) and !array_key_exists($var, $instance->optional_fields)) {
             continue;
         }
         if (is_null($value)) {
             $wheresql[] = " {$var} IS NULL ";
         } else {
             $value = addslashes($value);
             $wheresql[] = " {$var} = '{$value}' ";
         }
     }
     if (empty($wheresql)) {
         $wheresql = '';
     } else {
         $wheresql = implode("AND", $wheresql);
     }
     if ($rs = get_recordset_select($table, $wheresql, 'id')) {
         $result = array();
         while ($data = rs_fetch_next_record($rs)) {
             $instance = new $classname();
             grade_object::set_properties($instance, $data);
             $result[$instance->id] = $instance;
         }
         rs_close($rs);
         return $result;
     } else {
         return false;
     }
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:41,代码来源:grade_object.php

示例9: get_submission

 function get_submission($userid = 0, $createnew = false, $teachermodified = false)
 {
     global $CFG;
     $submission = parent::get_submission($userid, $createnew, $teachermodified);
     if ($submission) {
         $onlinejudge = get_record('assignment_oj_submissions', 'submission', $submission->id);
         if (empty($onlinejudge) && $createnew) {
             $newsubmission = new Object();
             $newsubmission->submission = $submission->id;
             if (!insert_record("assignment_oj_submissions", $newsubmission)) {
                 error("Could not insert a new empty onlinejudge submission");
             }
             unset($newsubmission);
         }
         $onlinejudge = get_record('assignment_oj_submissions', 'submission', $submission->id);
         if ($onlinejudge) {
             $submission->judged = $onlinejudge->judged;
             $submission->oj_id = $onlinejudge->id;
         } else {
             $submission->judged = 0;
         }
         if ($submission->judged) {
             $results = get_recordset_select('assignment_oj_results', 'submission = ' . $submission->id . ' AND judgetime >= ' . $submission->timemodified, 'judgetime DESC', '*', '', '1');
             $results = recordset_to_array($results);
             if ($results) {
                 $result = array_pop($results);
                 $submission->info = $result->info;
                 $submission->status = $result->status;
                 $submission->judgetime = $result->judgetime;
                 $submission->output = $result->output;
             } else {
                 $submission->judged = 0;
                 //It is been judging
                 $submission->status = 'pending';
             }
         } else {
             if (($files = get_directory_list($CFG->dataroot . '/' . $this->file_area_name($userid))) && count($files) != 0) {
                 // Submitted but unjudged
                 $submission->status = 'pending';
             }
         }
     }
     return $submission;
 }
开发者ID:hit-moodle,项目名称:onlinejudge,代码行数:44,代码来源:assignment.class.php

示例10: regrade_final_grades

 /**
  * Performs the necessary calculations on the grades_final referenced by this grade_item.
  * Also resets the needsupdate flag once successfully performed.
  *
  * This function must be used ONLY from lib/gradeslib.php/grade_regrade_final_grades(),
  * because the regrading must be done in correct order!!
  *
  * @return boolean true if ok, error string otherwise
  */
 function regrade_final_grades($userid = null)
 {
     global $CFG;
     // locked grade items already have correct final grades
     if ($this->is_locked()) {
         return true;
     }
     // calculation produces final value using formula from other final values
     if ($this->is_calculated()) {
         if ($this->compute($userid)) {
             return true;
         } else {
             return "Could not calculate grades for grade item";
             // TODO: improve and localize
         }
         // noncalculated outcomes already have final values - raw grades not used
     } else {
         if ($this->is_outcome_item()) {
             return true;
             // aggregate the category grade
         } else {
             if ($this->is_category_item() or $this->is_course_item()) {
                 // aggregate category grade item
                 $category = $this->get_item_category();
                 $category->grade_item =& $this;
                 if ($category->generate_grades($userid)) {
                     return true;
                 } else {
                     return "Could not aggregate final grades for category:" . $this->id;
                     // TODO: improve and localize
                 }
             } else {
                 if ($this->is_manual_item()) {
                     // manual items track only final grades, no raw grades
                     return true;
                 } else {
                     if (!$this->is_raw_used()) {
                         // hmm - raw grades are not used- nothing to regrade
                         return true;
                     }
                 }
             }
         }
     }
     // normal grade item - just new final grades
     $result = true;
     $grade_inst = new grade_grade();
     $fields = implode(',', $grade_inst->required_fields);
     if ($userid) {
         $rs = get_recordset_select('grade_grades', "itemid={$this->id} AND userid={$userid}", '', $fields);
     } else {
         $rs = get_recordset('grade_grades', 'itemid', $this->id, '', $fields);
     }
     if ($rs) {
         while ($grade_record = rs_fetch_next_record($rs)) {
             $grade = new grade_grade($grade_record, false);
             if (!empty($grade_record->locked) or !empty($grade_record->overridden)) {
                 // this grade is locked - final grade must be ok
                 continue;
             }
             $grade->finalgrade = $this->adjust_raw_grade($grade->rawgrade, $grade->rawgrademin, $grade->rawgrademax);
             if (grade_floats_different($grade_record->finalgrade, $grade->finalgrade)) {
                 if (!$grade->update('system')) {
                     $result = "Internal error updating final grade";
                 }
             }
         }
         rs_close($rs);
     }
     return $result;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:80,代码来源:grade_item.php

示例11: question_make_default_categories

/**
* Gets the default category in the most specific context.
* If no categories exist yet then default ones are created in all contexts.
*
* @param array $contexts  The context objects for this context and all parent contexts.
* @return object The default category - the category in the course context
*/
function question_make_default_categories($contexts)
{
    $toreturn = null;
    // If it already exists, just return it.
    foreach ($contexts as $key => $context) {
        if (!($categoryrs = get_recordset_select("question_categories", "contextid = '{$context->id}'", 'sortorder, name', '*', '', 1))) {
            error('error getting category record');
        } else {
            if (!($category = rs_fetch_record($categoryrs))) {
                // Otherwise, we need to make one
                $category = new stdClass();
                $contextname = print_context_name($context, false, true);
                $category->name = addslashes(get_string('defaultfor', 'question', $contextname));
                $category->info = addslashes(get_string('defaultinfofor', 'question', $contextname));
                $category->contextid = $context->id;
                $category->parent = 0;
                $category->sortorder = 999;
                // By default, all categories get this number, and are sorted alphabetically.
                $category->stamp = make_unique_id_code();
                if (!($category->id = insert_record('question_categories', $category))) {
                    error('Error creating a default category for context ' . print_context_name($context));
                }
            }
        }
        if ($context->contextlevel == CONTEXT_COURSE) {
            $toreturn = clone $category;
        }
    }
    return $toreturn;
}
开发者ID:e-rasvet,项目名称:reader,代码行数:37,代码来源:questionlib.php

示例12: optional_param

$lasttime = optional_param('lasttime', 0, PARAM_INT);
$CFG->limitviewentries = !isset($CFG->limitviewentries) || empty($CFG->limitviewentries) ? 600 : 6 * $CFG->limitviewentries;
//add_to_log(1, 1, "filter: $filter, lasttime: $lasttime", true);  //debug mode
// check for the lastes entries in the log
$where = "id > '{$lasttime}'";
if ($filter != '') {
    $where .= " AND ip = '{$filter}'";
}
if (!($count = count_records_select('log', $where))) {
    $return = '{"response":""}';
    //add_to_log(1, 1, $return, true); //debug mode
    echo $return;
    die;
}
$count = $count > $CFG->limitviewentries ? $count - $CFG->limitviewentries : 0;
if (!($entries = get_recordset_select('log', $where, 'time ASC', '*', $count, $CFG->limitviewentries))) {
    $return = '{"response":"KO"}';
    //add_to_log(1, 1, $return, true); //debug mode
    echo $return;
    die;
}
if (!($entries = recordset_to_array($entries))) {
    $return = '{"response":""}';
    //add_to_log(1, 1, $return, true); //debug mode
    echo $return;
    die;
}
/// set return entries in json format {"response":[{"ip":"","time":"","smarttime":"","category":"","info":""}]}
$return = '{"response":[';
foreach ($entries as $entri) {
    /// search for category names
开发者ID:jperezpamos,项目名称:marsupial-mps,代码行数:31,代码来源:viewer.inc.php

示例13: fm_get_cat_list

/**
* Gets the list of categories for the user or for the group
* @param $groupid Id of the group for which we need the categories'list. If 0 or NULL, then get the list of categories of the user
*/
function fm_get_cat_list($groupid = 0)
{
    global $USER;
    // $cats = array();
    $cats[0] = get_string('btnnoassigncat', 'block_file_manager');
    if ($groupid == 0) {
        $ownertype = OWNERISUSER;
        $rs = get_recordset_select('fmanager_categories', "owner={$USER->id} AND ownertype={$ownertype}", 'name');
        $catsrec = recordset_to_array($rs);
    } else {
        $ownertype = OWNERISGROUP;
        $rs = get_recordset_select('fmanager_categories', "owner={$groupid} AND ownertype={$ownertype}", 'name');
        $catsrec = recordset_to_array($rs);
    }
    if ($catsrec) {
        foreach ($catsrec as $c) {
            $cats[$c->id] = $c->name;
        }
    }
    return $cats;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:25,代码来源:lib.php

示例14: optional_param

* script for bulk user delete operations
*/
require_once '../../config.php';
require_once $CFG->libdir . '/adminlib.php';
$confirm = optional_param('confirm', 0, PARAM_BOOL);
admin_externalpage_setup('userbulk');
require_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM));
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
if (empty($SESSION->bulk_users)) {
    redirect($return);
}
admin_externalpage_print_header();
//TODO: add support for large number of users
if ($confirm and confirm_sesskey()) {
    $in = implode(',', $SESSION->bulk_users);
    if ($rs = get_recordset_select('user', "id IN ({$in})", '', 'id, username, secret, confirmed, auth, firstname, lastname')) {
        while ($user = rs_fetch_next_record($rs)) {
            if ($user->confirmed) {
                continue;
            }
            $auth = get_auth_plugin($user->auth);
            $result = $auth->user_confirm(addslashes($user->username), addslashes($user->secret));
            if ($result != AUTH_CONFIRM_OK && $result != AUTH_CONFIRM_ALREADY) {
                notify(get_string('usernotconfirmed', '', fullname($user, true)));
            }
        }
        rs_close($rs);
    }
    redirect($return, get_string('changessaved'));
} else {
    $in = implode(',', $SESSION->bulk_users);
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:user_bulk_confirm.php

示例15: update_all_class_grades

 /**
  * Update grades for this class
  *
  * @param array The class grades
  */
 function update_all_class_grades($classgrades = array())
 {
     global $CURMAN;
     if (isset($this->course) && get_class($this->course) == 'course') {
         $elements = $this->course->get_completion_elements();
     } else {
         $elements = false;
     }
     $timenow = time();
     if (!empty($elements)) {
         // for each student, find out how many required completion elements are
         // incomplete, and when the last completion element was graded
         $sql = "SELECT s.*, grades.incomplete, grades.maxtime\n                      FROM {$CURMAN->db->prefix_table(STUTABLE)} s\n                      JOIN (SELECT s.userid, COUNT(CASE WHEN grades.id IS NULL AND cc.required = 1 THEN 1\n                                                        ELSE NULL END) AS incomplete,\n                                    MAX(timegraded) AS maxtime\n                              FROM {$CURMAN->db->prefix_table(STUTABLE)} s\n                              JOIN {$CURMAN->db->prefix_table(CRSCOMPTABLE)} cc\n                                   ON cc.courseid = {$this->courseid}\n                         LEFT JOIN {$CURMAN->db->prefix_table(CLSGRTABLE)} grades\n                                   ON grades.userid = s.userid\n                                      AND grades.completionid = cc.id\n                                      AND grades.classid = {$this->id}\n                                      AND grades.grade >= cc.completion_grade\n                             WHERE s.classid = {$this->id} AND s.locked = 0\n                          GROUP BY s.userid\n                           ) grades ON grades.userid = s.userid\n                     WHERE s.classid = {$this->id} AND s.locked = 0";
         $rs = get_recordset_sql($sql);
         if ($rs) {
             while ($rec = rs_fetch_next_record($rs)) {
                 if ($rec->incomplete == 0 && $rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                     $student = new student($rec, $this, null);
                     $student->completestatusid = STUSTATUS_PASSED;
                     $student->completetime = $rec->maxtime;
                     $student->credits = $this->course->credits;
                     $student->locked = 1;
                     $student->complete();
                 }
             }
         }
     } else {
         /// We have no completion elements so just make sure the user's grade is at least the
         /// minimum value required for the course.
         /// Get all unlocked enrolments
         $select = "classid = {$this->id} AND locked = 0";
         $rs = get_recordset_select(STUTABLE, $select, 'userid');
         if ($rs) {
             while ($rec = rs_fetch_next_record($rs)) {
                 if ($rec->grade > 0 && $rec->grade >= $this->course->completion_grade) {
                     $student = new student($rec, $this, null);
                     $student->completestatusid = STUSTATUS_PASSED;
                     $student->completetime = $timenow;
                     $student->credits = $this->course->credits;
                     $student->locked = 1;
                     $student->complete();
                 }
             }
         }
     }
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:51,代码来源:cmclass.class.php


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