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


PHP get_array_of_activities函数代码示例

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


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

示例1: main_upgrade

function main_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($oldversion < 2003010101) {
        delete_records("log_display", "module", "user");
        $new->module = "user";
        $new->action = "view";
        $new->mtable = "user";
        $new->field = "CONCAT(firstname,\" \",lastname)";
        insert_record("log_display", $new);
        delete_records("log_display", "module", "course");
        $new->module = "course";
        $new->action = "view";
        $new->mtable = "course";
        $new->field = "fullname";
        insert_record("log_display", $new);
        $new->action = "update";
        insert_record("log_display", $new);
        $new->action = "enrol";
        insert_record("log_display", $new);
    }
    //support user based course creating
    if ($oldversion < 2003032400) {
        execute_sql("CREATE TABLE {$CFG->prefix}user_coursecreators (\n                                  id int8 SERIAL PRIMARY KEY,\n                                  userid int8  NOT NULL default '0'\n                                  )");
    }
    if ($oldversion < 2003041400) {
        table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
    }
    if ($oldversion < 2003042104) {
        // Try to update permissions of all files
        if ($files = get_directory_list($CFG->dataroot)) {
            echo "Attempting to update permissions for all files... ignore any errors.";
            foreach ($files as $file) {
                echo "{$CFG->dataroot}/{$file}<br />";
                @chmod("{$CFG->dataroot}/{$file}", $CFG->directorypermissions);
            }
        }
    }
    if ($oldversion < 2003042400) {
        // Rebuild all course caches, because of changes to do with visible variable
        if ($courses = get_records_sql("SELECT * FROM {$CFG->prefix}course")) {
            require_once "{$CFG->dirroot}/course/lib.php";
            foreach ($courses as $course) {
                $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) . "'!");
                }
            }
        }
    }
    if ($oldversion < 2003042500) {
        //  Convert all usernames to lowercase.
        $users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user");
        $cerrors = "";
        $rarray = array();
        foreach ($users as $user) {
            // Check for possible conflicts
            $lcname = trim(moodle_strtolower($user->username));
            if (in_array($lcname, $rarray)) {
                $cerrors .= $user->id . "->" . $lcname . '<br/>';
            } else {
                array_push($rarray, $lcname);
            }
        }
        if ($cerrors != '') {
            notify("Error: Cannot convert usernames to lowercase. \n                    Following usernames would overlap (id->username):<br/> {$cerrors} . \n                    Please resolve overlapping errors.");
            $result = false;
        }
        $cerrors = "";
        echo "Checking userdatabase:<br />";
        foreach ($users as $user) {
            $lcname = trim(moodle_strtolower($user->username));
            if ($lcname != $user->username) {
                $convert = set_field("user", "username", $lcname, "id", $user->id);
                if (!$convert) {
                    if ($cerrors) {
                        $cerrors .= ", ";
                    }
                    $cerrors .= $item;
                } else {
                    echo ".";
                }
            }
        }
        if ($cerrors != '') {
            notify("There were errors when converting following usernames to lowercase. \n                   '{$cerrors}' . Sorry, but you will need to fix your database by hand.");
            $result = false;
        }
    }
    if ($oldversion < 2003042700) {
        /// Changing to multiple indexes
        execute_sql(" CREATE INDEX {$CFG->prefix}log_coursemoduleaction_idx ON {$CFG->prefix}log (course,module,action) ");
        execute_sql(" CREATE INDEX {$CFG->prefix}log_courseuserid_idx ON {$CFG->prefix}log (course,userid) ");
    }
    if ($oldversion < 2003042801) {
        execute_sql("CREATE TABLE {$CFG->prefix}course_display (\n                         id SERIAL PRIMARY KEY,\n                         course integer NOT NULL default '0',\n                         userid integer NOT NULL default '0',\n                         display integer NOT NULL default '0'\n                      )");
        execute_sql("CREATE INDEX {$CFG->prefix}course_display_courseuserid_idx ON {$CFG->prefix}course_display (course,userid)");
    }
    if ($oldversion < 2003050400) {
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:postgres7.php

示例2: build_course_cache

 /**
  * Builds and stores in MUC object containing information about course
  * modules and sections together with cached fields from table course.
  *
  * @param stdClass $course object from DB table course. Must have property 'id'
  *     but preferably should have all cached fields.
  * @return stdClass object with all cached keys of the course plus fields modinfo and sectioncache.
  *     The same object is stored in MUC
  * @throws moodle_exception if course is not found (if $course object misses some of the
  *     necessary fields it is re-requested from database)
  */
 public static function build_course_cache($course) {
     global $DB, $CFG;
     require_once("$CFG->dirroot/course/lib.php");
     if (empty($course->id)) {
         throw new coding_exception('Object $course is missing required property \id\'');
     }
     // Ensure object has all necessary fields.
     foreach (self::$cachedfields as $key) {
         if (!isset($course->$key)) {
             $course = $DB->get_record('course', array('id' => $course->id),
                     implode(',', array_merge(array('id'), self::$cachedfields)), MUST_EXIST);
             break;
         }
     }
     // Retrieve all information about activities and sections.
     // This may take time on large courses and it is possible that another user modifies the same course during this process.
     // Field cacherev stored in both DB and cache will ensure that cached data matches the current course state.
     $coursemodinfo = new stdClass();
     $coursemodinfo->modinfo = get_array_of_activities($course->id);
     $coursemodinfo->sectioncache = self::build_course_section_cache($course);
     foreach (self::$cachedfields as $key) {
         $coursemodinfo->$key = $course->$key;
     }
     // Set the accumulated activities and sections information in cache, together with cacherev.
     $cachecoursemodinfo = cache::make('core', 'coursemodinfo');
     $cachecoursemodinfo->set($course->id, $coursemodinfo);
     return $coursemodinfo;
 }
开发者ID:rwijaya,项目名称:moodle,代码行数:39,代码来源:modinfolib.php

示例3: main_upgrade


//.........这里部分代码省略.........
                        return false;
                    }
                    if (!set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
                        notify("Could not update the course module with the correct section");
                        return false;
                    }
                }
                if ($social = forum_get_course_forum($course->id, "social")) {
                    $mod->course = $course->id;
                    $mod->module = $module->id;
                    $mod->instance = $social->id;
                    $mod->section = 0;
                    if (!($mod->coursemodule = add_course_module($mod))) {
                        notify("Could not add a new course module to the course '" . format_string($course->fullname) . "'");
                        return false;
                    }
                    if (!($sectionid = add_mod_to_section($mod))) {
                        notify("Could not add the new course module to that section");
                        return false;
                    }
                    if (!set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
                        notify("Could not update the course module with the correct section");
                        return false;
                    }
                }
            }
        }
    }
    if ($oldversion < 2002111003) {
        execute_sql(" ALTER TABLE `course` ADD `modinfo` TEXT NOT NULL AFTER `format` ");
        if ($courses = get_records_sql("SELECT * FROM course")) {
            require_once "{$CFG->dirroot}/course/lib.php";
            foreach ($courses as $course) {
                $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) . "'!");
                }
            }
        }
    }
    if ($oldversion < 2002111100) {
        print_simple_box_start("CENTER", "", "#FFCCCC");
        echo "<FONT SIZE=+1>";
        echo "<P>Changes have been made to all built-in themes, to add the new popup navigation menu.";
        echo "<P>If you have customised themes, you will need to edit theme/xxxx/header.html as follows:";
        echo "<UL><LI>Change anywhere it says <B>\$" . "button</B> to say <B>\$" . "menu</B>";
        echo "<LI>Add <B>\$" . "button</B> elsewhere (eg at the end of the navigation bar)</UL>";
        echo "<P>See the standard themes for examples, eg: theme/standard/header.html";
        print_simple_box_end();
    }
    if ($oldversion < 2002111200) {
        execute_sql(" ALTER TABLE `course` ADD `showrecent` TINYINT(5) UNSIGNED DEFAULT '1' NOT NULL AFTER `numsections` ");
    }
    if ($oldversion < 2002111400) {
        // Rebuild all course caches, because some may not be done in new installs (eg site page)
        if ($courses = get_records_sql("SELECT * FROM course")) {
            require_once "{$CFG->dirroot}/course/lib.php";
            foreach ($courses as $course) {
                $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) . "'!");
                }
            }
        }
    }
    if ($oldversion < 2002112000) {
开发者ID:veritech,项目名称:pare-project,代码行数:67,代码来源:mysql.php

示例4: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuild, 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, $DB, $CFG;
    // Destroy navigation caches
    navigation_cache::destroy_volatile_caches();
    if ($clearonly) {
        if (empty($courseid)) {
            $courseselect = array();
        } else {
            $courseselect = array('id' => $courseid);
        }
        $DB->set_field('course', 'modinfo', null, $courseselect);
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id or empty($courseid)) {
            $COURSE->modinfo = null;
        }
        // reset the fast modinfo cache
        $reset = 'reset';
        get_fast_modinfo($reset);
        return;
    }
    require_once "{$CFG->dirroot}/course/lib.php";
    if ($courseid) {
        $select = array('id' => $courseid);
    } else {
        $select = array();
        @set_time_limit(0);
        // this could take a while!   MDL-10954
    }
    $rs = $DB->get_recordset("course", $select, '', 'id,fullname');
    foreach ($rs as $course) {
        $modinfo = serialize(get_array_of_activities($course->id));
        $DB->set_field("course", "modinfo", $modinfo, array("id" => $course->id));
        // update cached global COURSE too ;-)
        if ($course->id == $COURSE->id) {
            $COURSE->modinfo = $modinfo;
        }
    }
    $rs->close();
    // reset the fast modinfo cache
    $reset = 'reset';
    get_fast_modinfo($reset);
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:48,代码来源:modinfolib.php

示例5: foreach

    //var_dump($USER);

}


foreach($studentenrolledcourses as $courseid => $coursename)
{
    $html.=html_writer::start_tag('tr');
    $html.=html_writer::start_tag('td',array('align'=>'left'));
    $html.=$coursename;
    $html.=html_writer::end_tag('td');
    $html.=html_writer::start_tag('td',array('align'=>'center'));
    //
    $countlabs=0;
    $countquiz=0;
    $activities=get_array_of_activities($courseid) ;
    //var_dump($activities);
    foreach($activities as $key1 => $value1){
        if(is_object($value1)){
            if($value1->visible==true){
                if (($value1->mod == 'vpl') || ($value1->mod == 'quiz')){
                $act[$value1->name]=array($value1->mod => $coursename);
                $desc[$value1->name]=array($value1->mod => $value1->cm);
                }
            }


        }
    }
    //var_dump($act);
开发者ID:kmahesh541,项目名称:mitclone,代码行数:30,代码来源:getactivetests-old.php

示例6: print_metadatadcs

function print_metadatadcs($metadatadcs)
{
    global $CFG;
    $timenow = time();
    $strcourse = get_string("course");
    $strname = get_string("names", "metadatadc");
    $strresource = get_string("resources", "metadatadc");
    $strdescription = get_string("description");
    $table->head = array($strcourse, $strname, $strresource, $strdescription);
    $table->align = array("left", "left", "left", "left");
    foreach ($metadatadcs as $metadatadc) {
        //$lines = get_array_of_activities($course->id);
        $lines = get_array_of_activities($metadatadc->course);
        foreach ($lines as $key => $line) {
            $cmlo[$key] = $line->cm;
            //LO course module id
            $modlo[$key] = $line->mod;
            //LO module name
            $namelo[$key] = trim(strip_tags(urldecode($line->name)));
            //LO name	(instance name)
        }
        $cmdc = get_coursemodule_from_instance('metadatadc', $metadatadc->id, $metadatadc->course);
        // not working - fix it
        /*        if (!$metadatadc->visible) {
                    //Show dimmed if the mod is hidden
        			$link = get_field('course', 'fullname', 'id', $metadatadc->course);
        			$link0 = "<a class=\"dimmed\" href=\"$CFG->wwwroot/course/view.php?id=$metadatadc->course\">$link</a>";			
                    $link1 = "<a class=\"dimmed\" href=\"$CFG->wwwroot/mod/metadatadc/view.php?id=$cmdc->id\">$metadatadc->name</a>";		
                    $link2 = "<a class=\"dimmed\" href=\"$CFG->wwwroot/mod/".$modlo[$metadatadc->resource]."/view.php?id=".$metadatadc->resource."\">".$namelo[$metadatadc->resource]."  (".$modlo[$metadatadc->resource].")</a>";					
                    $link3 = $metadatadc->description;
        	
                } else {*/
        //Show normal if the mod is visible
        $link = get_field('course', 'fullname', 'id', $metadatadc->course);
        $link0 = "<a href=\"{$CFG->wwwroot}/course/view.php?id={$metadatadc->course}\">{$link}</a>";
        $link1 = "<a href=\"{$CFG->wwwroot}/mod/metadatadc/view.php?id={$cmdc->id}\">{$metadatadc->name}</a>";
        $link2 = "<a href=\"{$CFG->wwwroot}/mod/" . $modlo[$metadatadc->resource] . "/view.php?id=" . $metadatadc->resource . "\">" . $namelo[$metadatadc->resource] . "  (" . $modlo[$metadatadc->resource] . ")</a>";
        $link3 = $metadatadc->description;
        //         }
        $table->data[] = array($link0, $link1, $link2, $link3);
    }
    echo "<br />";
    print_heading(get_string("modulenameplural", "metadatadc"));
    print_table($table);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:45,代码来源:search_allmetadata.php

示例7: 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

示例8: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuild, 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, $SITE, $DB, $CFG;
    // Destroy navigation caches
    navigation_cache::destroy_volatile_caches();
    if (class_exists('format_base')) {
        // if file containing class is not loaded, there is no cache there anyway
        format_base::reset_course_cache($courseid);
    }
    if ($clearonly) {
        if (empty($courseid)) {
            $DB->set_field('course', 'modinfo', null);
            $DB->set_field('course', 'sectioncache', null);
        } else {
            // Clear both fields in one update
            $resetobj = (object) array('id' => $courseid, 'modinfo' => null, 'sectioncache' => null);
            $DB->update_record('course', $resetobj);
        }
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id or empty($courseid)) {
            $COURSE->modinfo = null;
            $COURSE->sectioncache = null;
        }
        if ($courseid == $SITE->id) {
            $SITE->modinfo = null;
            $SITE->sectioncache = null;
        }
        // reset the fast modinfo cache
        get_fast_modinfo($courseid, 0, true);
        return;
    }
    require_once "{$CFG->dirroot}/course/lib.php";
    if ($courseid) {
        $select = array('id' => $courseid);
    } else {
        $select = array();
        @set_time_limit(0);
        // this could take a while!   MDL-10954
    }
    $rs = $DB->get_recordset("course", $select, '', 'id,fullname');
    foreach ($rs as $course) {
        $modinfo = serialize(get_array_of_activities($course->id));
        $sectioncache = serialize(course_modinfo::build_section_cache($course->id));
        $updateobj = (object) array('id' => $course->id, 'modinfo' => $modinfo, 'sectioncache' => $sectioncache);
        $DB->update_record("course", $updateobj);
        // update cached global COURSE too ;-)
        if ($course->id == $COURSE->id) {
            $COURSE->modinfo = $modinfo;
            $COURSE->sectioncache = $sectioncache;
        }
        if ($course->id == $SITE->id) {
            $SITE->modinfo = $modinfo;
            $SITE->sectioncache = $sectioncache;
        }
    }
    $rs->close();
    // reset the fast modinfo cache
    get_fast_modinfo($courseid, 0, true);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:64,代码来源:modinfolib.php

示例9: array

    $table->align = array("center", "left", "center", "center", "center");
} else {
    if ($course->format == "topics") {
        $table->head = array($strtopic, $strnames, $strresource, " ", "IEEE - Learning Object Metadata", " ");
        $table->align = array("center", "left", "left", "center", "center", "center");
    } else {
        $table->head = array($strnames, $strresource, " ", "IEEE - Learning Object Metadata", " ");
        $table->align = array("left", "left", "center", "center", "center");
    }
}
if (isteacheredit($course->id)) {
    array_push($table->head, $strupdate);
    array_push($table->align, "center");
}
foreach ($metadataloms as $metadatalom) {
    $lines = get_array_of_activities($course->id);
    foreach ($lines as $key => $line) {
        $cmlo[$key] = $line->cm;
        //LO course module id
        $modlo[$key] = $line->mod;
        //LO module name
        $namelo[$key] = trim(strip_tags(urldecode($line->name)));
        //LO name	(instance name)
    }
    //get_field($table, $return, $field1, $value1, $field2='', $value2='', $field3='', $value3='')
    //$resource_name = get_field("resource", "name", "id", $metadatalom->resource, "course", $course->id);
    //$cmr = get_cm_from_instance('resource', $metadatalom->resource, $resource->course);
    if ($CFG->version > 2005000000) {
        if (!$metadatalom->visible) {
            //Show dimmed if the mod is hidden
            $link = "<a class=\"dimmed\" href=\"view.php?id={$metadatalom->coursemodule}\">{$metadatalom->name}</a>";
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:index.php

示例10: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuild, 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, $DB, $CFG;

    if (!$clearonly && !empty($CFG->upgraderunning)) {
        debugging('Function rebuild_course_cache() should not be called from upgrade script unless with argument clearonly.',
                DEBUG_DEVELOPER);
        $clearonly = true;
    }

    // Destroy navigation caches
    navigation_cache::destroy_volatile_caches();

    if ($clearonly) {
        if (empty($courseid)) {
            $DB->set_field('course', 'modinfo', null);
            $DB->set_field('course', 'sectioncache', null);
        } else {
            // Clear both fields in one update
            $resetobj = (object)array('id' => $courseid, 'modinfo' => null, 'sectioncache' => null);
            $DB->update_record('course', $resetobj);
        }
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id or empty($courseid)) {
            $COURSE->modinfo = null;
            $COURSE->sectioncache = null;
        }
        // reset the fast modinfo cache
        $reset = 'reset';
        get_fast_modinfo($reset);
        return;
    }

    require_once("$CFG->dirroot/course/lib.php");

    if ($courseid) {
        $select = array('id'=>$courseid);
    } else {
        $select = array();
        @set_time_limit(0);  // this could take a while!   MDL-10954
    }

    $rs = $DB->get_recordset("course", $select,'','id,fullname');
    foreach ($rs as $course) {
        $modinfo = serialize(get_array_of_activities($course->id));
        $sectioncache = serialize(course_modinfo::build_section_cache($course->id));
        $updateobj = (object)array('id' => $course->id,
                'modinfo' => $modinfo, 'sectioncache' => $sectioncache);
        $DB->update_record("course", $updateobj);
        // update cached global COURSE too ;-)
        if ($course->id == $COURSE->id) {
            $COURSE->modinfo = $modinfo;
            $COURSE->sectioncache = $sectioncache;
        }
    }
    $rs->close();
    // reset the fast modinfo cache
    $reset = 'reset';
    get_fast_modinfo($reset);
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:64,代码来源:modinfolib.php

示例11: 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, $DB;
    if ($clearonly) {
        if (empty($courseid)) {
            $courseselect = array();
        } else {
            $courseselect = array('id' => $courseid);
        }
        $DB->set_field('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 = array('id' => $courseid);
    } else {
        $select = array();
        @set_time_limit(0);
        // this could take a while!   MDL-10954
    }
    if ($rs = $DB->get_recordset("course", $select, '', 'id,fullname')) {
        foreach ($rs as $course) {
            $modinfo = serialize(get_array_of_activities($course->id));
            if (!$DB->set_field("course", "modinfo", $modinfo, array("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();
    }
    // reset the fast modinfo cache
    $reset = 'reset';
    get_fast_modinfo($reset);
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:48,代码来源:lib.php

示例12: get_course_modules

 /**
  * Get course modules
  * @global object $DB
  * @param array|struct $params - need to be define as struct for XMLRPC
  * @subparam string $params:course->id
  * @return array $return course modules
  * @subreturn string $return:id module id
  * @subreturn string $return:name module name
  * @subreturn string $return:type module type
  */
 static function get_course_modules($params, $type = null)
 {
     global $DB;
     if (has_capability('moodle/course:view', get_context_instance(CONTEXT_SYSTEM))) {
         $modules = array();
         foreach ($params as $courseparams) {
             if (array_key_exists('id', $courseparams)) {
                 $id = clean_param($courseparams['id'], PARAM_INT);
             }
             $activities = get_array_of_activities($id);
             foreach ($activities as $activity) {
                 if (empty($type)) {
                     $module = array('id' => $activity->id, 'courseid' => $id, 'name' => $activity->name, 'type' => $activity->mod);
                     $modules[] = $module;
                 } else {
                     if ($type == "activities") {
                         if ($activity->mod != "resource" && $activity->mod != "label") {
                             $module = array('id' => $activity->id, 'courseid' => $id, 'name' => $activity->name, 'type' => $activity->mod);
                             $modules[] = $module;
                         }
                     } else {
                         if ($type == "resources") {
                             if ($activity->mod == "resource" || $activity->mod == "label") {
                                 $module = array('id' => $activity->id, 'courseid' => $id, 'resource' => $activity->name, 'type' => $activity->mod);
                                 $modules[] = $module;
                             }
                         }
                     }
                 }
             }
         }
         return $modules;
     } else {
         throw new moodle_exception('wscouldnotgetcoursemodulesnopermission');
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:46,代码来源:external.php

示例13: get_course_info

 public static function get_course_info($courseID)
 {
     global $DB;
     console . log("in course_info. CourseID: " + $courseID);
     //check parameters
     $params = self::validate_parameters(self::get_course_info_parameters(), array('courseID' => $courseID));
     // now security checks
     $coursecontext = context_course::instance($params['courseID']);
     self::validate_context($coursecontext);
     //Is the user allowes to use this web service?
     //require_capability('moodle/site:viewparticipants', $context); // is the user normaly allowed to see all participants of the course
     require_capability('tool/supporter:get_course_info', $coursecontext);
     // is the user coursecreator, manager, teacher, editingteacher
     $select = "SELECT c.id, c.shortname, c.fullname, c.visible, cat.name AS fb, (SELECT name FROM {course_categories} WHERE id = cat.parent) AS semester FROM {course} c, {course_categories} cat WHERE c.category = cat.id AND c.id = '{$courseID}'";
     $courseDetails = $DB->get_record_sql($select);
     $courseDetails = (array) $courseDetails;
     $courseDetails['enrolledUsers'] = count_enrolled_users($coursecontext, $withcapability = '', $groupid = '0');
     $roles = array();
     $roleList = get_all_roles($coursecontext);
     // array('moodle/legacy:student', 'moodle/legacy:teacher', 'moodle/legacy:editingteacher', 'moodle/legacy:coursecreator');
     $count = count_role_users([1, 2, 3, 4, 5, 6, 7], $coursecontext);
     print_r($roleList);
     echo "count";
     print_r($count);
     foreach ($roleList as $r) {
         if ($r->coursealias != NULL) {
             $roleName = $r->coursealias;
         } else {
             $roleName = $r->shortname;
         }
         $roleNumber = count_role_users($r->id, $coursecontext);
         //$roleNumber = count_enrolled_users($coursecontext, $withcapability = $role, $groupid = 0);
         if ($roleNumber != 0) {
             $roles[] = ['roleName' => $roleName, 'roleNumber' => $roleNumber];
         }
     }
     $users_raw = get_enrolled_users($coursecontext, $withcapability = '', $groupid = 0, $userfields = 'u.id,u.username,u.firstname, u.lastname', $orderby = '', $limitfrom = 0, $limitnum = 0);
     $users = array();
     foreach ($users_raw as $u) {
         $users[] = (array) $u;
     }
     $activities = array();
     $modules = get_array_of_activities($courseID);
     foreach ($modules as $mo) {
         $section = get_section_name($courseID, $mo->section);
         $activity = ['section' => $section, 'activity' => $mo->mod, 'name' => $mo->name, 'visible' => $mo->visible];
         $activities[] = $activity;
     }
     $data = ['courseDetails' => $courseDetails, 'roles' => $roles, 'users' => $users, 'activities' => $activities];
     return $data;
 }
开发者ID:eLearning-TUDarmstadt,项目名称:moodle-tool_supporter,代码行数:51,代码来源:externallib.php


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