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

PHP get_all_instances_in_courses函数代码示例

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

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



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

示例1: get_glossaries_by_courses

 /**
  * Returns a list of glossaries in a provided list of courses.
  *
  * If no list is provided all glossaries that the user can view will be returned.
  *
  * @param array $courseids the course IDs.
  * @return array of glossaries
  * @since Moodle 3.1
  */
 public static function get_glossaries_by_courses($courseids = array())
 {
     $params = self::validate_parameters(self::get_glossaries_by_courses_parameters(), array('courseids' => $courseids));
     $warnings = array();
     $courses = array();
     $courseids = $params['courseids'];
     if (empty($courseids)) {
         $courses = enrol_get_my_courses();
         $courseids = array_keys($courses);
     }
     // Array to store the glossaries to return.
     $glossaries = array();
     // Ensure there are courseids to loop through.
     if (!empty($courseids)) {
         list($courses, $warnings) = external_util::validate_courses($courseids, $courses);
         // Get the glossaries in these courses, this function checks users visibility permissions.
         $glossaries = get_all_instances_in_courses('glossary', $courses);
         foreach ($glossaries as $glossary) {
             $context = context_module::instance($glossary->coursemodule);
             $glossary->name = external_format_string($glossary->name, $context->id);
             list($glossary->intro, $glossary->introformat) = external_format_text($glossary->intro, $glossary->introformat, $context->id, 'mod_glossary', 'intro', null);
         }
     }
     $result = array();
     $result['glossaries'] = $glossaries;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:37,代码来源:external.php


示例2: get_surveys_by_courses

 /**
  * Returns a list of surveys in a provided list of courses,
  * if no list is provided all surveys that the user can view will be returned.
  *
  * @param array $courseids the course ids
  * @return array of surveys details
  * @since Moodle 3.0
  */
 public static function get_surveys_by_courses($courseids = array())
 {
     global $CFG, $USER, $DB;
     $returnedsurveys = array();
     $warnings = array();
     $params = self::validate_parameters(self::get_surveys_by_courses_parameters(), array('courseids' => $courseids));
     $mycourses = array();
     if (empty($params['courseids'])) {
         $mycourses = enrol_get_my_courses();
         $params['courseids'] = array_keys($mycourses);
     }
     // Ensure there are courseids to loop through.
     if (!empty($params['courseids'])) {
         list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
         // Get the surveys in this course, this function checks users visibility permissions.
         // We can avoid then additional validate_context calls.
         $surveys = get_all_instances_in_courses("survey", $courses);
         foreach ($surveys as $survey) {
             $context = context_module::instance($survey->coursemodule);
             // Entry to return.
             $surveydetails = array();
             // First, we return information that any user can see in the web interface.
             $surveydetails['id'] = $survey->id;
             $surveydetails['coursemodule'] = $survey->coursemodule;
             $surveydetails['course'] = $survey->course;
             $surveydetails['name'] = external_format_string($survey->name, $context->id);
             if (has_capability('mod/survey:participate', $context)) {
                 $trimmedintro = trim($survey->intro);
                 if (empty($trimmedintro)) {
                     $tempo = $DB->get_field("survey", "intro", array("id" => $survey->template));
                     $survey->intro = get_string($tempo, "survey");
                 }
                 // Format intro.
                 list($surveydetails['intro'], $surveydetails['introformat']) = external_format_text($survey->intro, $survey->introformat, $context->id, 'mod_survey', 'intro', null);
                 $surveydetails['introfiles'] = external_util::get_area_files($context->id, 'mod_survey', 'intro', false, false);
                 $surveydetails['template'] = $survey->template;
                 $surveydetails['days'] = $survey->days;
                 $surveydetails['questions'] = $survey->questions;
                 $surveydetails['surveydone'] = survey_already_done($survey->id, $USER->id) ? 1 : 0;
             }
             if (has_capability('moodle/course:manageactivities', $context)) {
                 $surveydetails['timecreated'] = $survey->timecreated;
                 $surveydetails['timemodified'] = $survey->timemodified;
                 $surveydetails['section'] = $survey->section;
                 $surveydetails['visible'] = $survey->visible;
                 $surveydetails['groupmode'] = $survey->groupmode;
                 $surveydetails['groupingid'] = $survey->groupingid;
             }
             $returnedsurveys[] = $surveydetails;
         }
     }
     $result = array();
     $result['surveys'] = $returnedsurveys;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:64,代码来源:external.php


示例3: get_forums_by_courses

 /**
  * Returns a list of forums in a provided list of courses,
  * if no list is provided all forums that the user can view
  * will be returned.
  *
  * @param array $courseids the course ids
  * @return array the forum details
  * @since Moodle 2.5
  */
 public static function get_forums_by_courses($courseids = array())
 {
     global $CFG;
     require_once $CFG->dirroot . "/mod/forum/lib.php";
     $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids));
     if (empty($params['courseids'])) {
         // Get all the courses the user can view.
         $courseids = array_keys(enrol_get_my_courses());
     } else {
         $courseids = $params['courseids'];
     }
     // Array to store the forums to return.
     $arrforums = array();
     // Ensure there are courseids to loop through.
     if (!empty($courseids)) {
         // Array of the courses we are going to retrieve the forums from.
         $dbcourses = array();
         // Mod info for courses.
         $modinfocourses = array();
         // Go through the courseids and return the forums.
         foreach ($courseids as $courseid) {
             // Check the user can function in this context.
             try {
                 $context = context_course::instance($courseid);
                 self::validate_context($context);
                 // Get the modinfo for the course.
                 $modinfocourses[$courseid] = get_fast_modinfo($courseid);
                 $dbcourses[$courseid] = $modinfocourses[$courseid]->get_course();
             } catch (Exception $e) {
                 continue;
             }
         }
         // Get the forums in this course. This function checks users visibility permissions.
         if ($forums = get_all_instances_in_courses("forum", $dbcourses)) {
             foreach ($forums as $forum) {
                 $course = $dbcourses[$forum->course];
                 $cm = $modinfocourses[$course->id]->get_cm($forum->coursemodule);
                 $context = context_module::instance($cm->id);
                 // Skip forums we are not allowed to see discussions.
                 if (!has_capability('mod/forum:viewdiscussion', $context)) {
                     continue;
                 }
                 // Format the intro before being returning using the format setting.
                 list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat, $context->id, 'mod_forum', 'intro', 0);
                 // Discussions count. This function does static request cache.
                 $forum->numdiscussions = forum_count_discussions($forum, $cm, $course);
                 $forum->cmid = $forum->coursemodule;
                 // Add the forum to the array to return.
                 $arrforums[$forum->id] = $forum;
             }
         }
     }
     return $arrforums;
 }
开发者ID:educakanchay,项目名称:campus,代码行数:63,代码来源:externallib.php


示例4: get_wikis_by_courses

 /**
  * Returns a list of wikis in a provided list of courses,
  * if no list is provided all wikis that the user can view will be returned.
  *
  * @param array $courseids The courses IDs.
  * @return array Containing a list of warnings and a list of wikis.
  * @since Moodle 3.1
  */
 public static function get_wikis_by_courses($courseids = array())
 {
     $returnedwikis = array();
     $warnings = array();
     $params = self::validate_parameters(self::get_wikis_by_courses_parameters(), array('courseids' => $courseids));
     $mycourses = array();
     if (empty($params['courseids'])) {
         $mycourses = enrol_get_my_courses();
         $params['courseids'] = array_keys($mycourses);
     }
     // Ensure there are courseids to loop through.
     if (!empty($params['courseids'])) {
         list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
         // Get the wikis in this course, this function checks users visibility permissions.
         // We can avoid then additional validate_context calls.
         $wikis = get_all_instances_in_courses('wiki', $courses);
         foreach ($wikis as $wiki) {
             $context = context_module::instance($wiki->coursemodule);
             // Entry to return.
             $module = array();
             // First, we return information that any user can see in (or can deduce from) the web interface.
             $module['id'] = $wiki->id;
             $module['coursemodule'] = $wiki->coursemodule;
             $module['course'] = $wiki->course;
             $module['name'] = external_format_string($wiki->name, $context->id);
             $viewablefields = [];
             if (has_capability('mod/wiki:viewpage', $context)) {
                 list($module['intro'], $module['introformat']) = external_format_text($wiki->intro, $wiki->introformat, $context->id, 'mod_wiki', 'intro', $wiki->id);
                 $module['introfiles'] = external_util::get_area_files($context->id, 'mod_wiki', 'intro', false, false);
                 $viewablefields = array('firstpagetitle', 'wikimode', 'defaultformat', 'forceformat', 'editbegin', 'editend', 'section', 'visible', 'groupmode', 'groupingid');
             }
             // Check additional permissions for returning optional private settings.
             if (has_capability('moodle/course:manageactivities', $context)) {
                 $additionalfields = array('timecreated', 'timemodified');
                 $viewablefields = array_merge($viewablefields, $additionalfields);
             }
             foreach ($viewablefields as $field) {
                 $module[$field] = $wiki->{$field};
             }
             // Check if user can add new pages.
             $module['cancreatepages'] = wiki_can_create_pages($context);
             $returnedwikis[] = $module;
         }
     }
     $result = array();
     $result['wikis'] = $returnedwikis;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:57,代码来源:external.php


示例5: get_forums_by_courses

    /**
     * Returns a list of forums in a provided list of courses,
     * if no list is provided all forums that the user can view
     * will be returned.
     *
     * @param array $courseids the course ids
     * @return array the forum details
     * @since Moodle 2.5
     */
    public static function get_forums_by_courses($courseids = array()) {
        global $CFG;

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

        $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids));

        if (empty($params['courseids'])) {
            $params['courseids'] = array_keys(enrol_get_my_courses());
        }

        // Array to store the forums to return.
        $arrforums = array();
        $warnings = array();

        // Ensure there are courseids to loop through.
        if (!empty($params['courseids'])) {

            list($courses, $warnings) = external_util::validate_courses($params['courseids']);

            // Get the forums in this course. This function checks users visibility permissions.
            $forums = get_all_instances_in_courses("forum", $courses);
            foreach ($forums as $forum) {

                $course = $courses[$forum->course];
                $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id);
                $context = context_module::instance($cm->id);

                // Skip forums we are not allowed to see discussions.
                if (!has_capability('mod/forum:viewdiscussion', $context)) {
                    continue;
                }

                // Format the intro before being returning using the format setting.
                list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat,
                                                                                $context->id, 'mod_forum', 'intro', 0);
                // Discussions count. This function does static request cache.
                $forum->numdiscussions = forum_count_discussions($forum, $cm, $course);
                $forum->cmid = $forum->coursemodule;
                $forum->cancreatediscussions = forum_user_can_post_discussion($forum, null, -1, $cm, $context);

                // Add the forum to the array to return.
                $arrforums[$forum->id] = $forum;
            }
        }

        return $arrforums;
    }
开发者ID:uniedpa,项目名称:moodle,代码行数:57,代码来源:externallib.php


示例6: get_chats_by_courses

 /**
  * Returns a list of chats in a provided list of courses,
  * if no list is provided all chats that the user can view will be returned.
  *
  * @param array $courseids the course ids
  * @return array of chats details
  * @since Moodle 3.0
  */
 public static function get_chats_by_courses($courseids = array())
 {
     global $CFG;
     $returnedchats = array();
     $warnings = array();
     $params = self::validate_parameters(self::get_chats_by_courses_parameters(), array('courseids' => $courseids));
     $courses = array();
     if (empty($params['courseids'])) {
         $courses = enrol_get_my_courses();
         $params['courseids'] = array_keys($courses);
     }
     // Ensure there are courseids to loop through.
     if (!empty($params['courseids'])) {
         list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
         // Get the chats in this course, this function checks users visibility permissions.
         // We can avoid then additional validate_context calls.
         $chats = get_all_instances_in_courses("chat", $courses);
         foreach ($chats as $chat) {
             $chatcontext = context_module::instance($chat->coursemodule);
             // Entry to return.
             $chatdetails = array();
             // First, we return information that any user can see in the web interface.
             $chatdetails['id'] = $chat->id;
             $chatdetails['coursemodule'] = $chat->coursemodule;
             $chatdetails['course'] = $chat->course;
             $chatdetails['name'] = external_format_string($chat->name, $chatcontext->id);
             // Format intro.
             list($chatdetails['intro'], $chatdetails['introformat']) = external_format_text($chat->intro, $chat->introformat, $chatcontext->id, 'mod_chat', 'intro', null);
             if (has_capability('mod/chat:chat', $chatcontext)) {
                 $chatdetails['chatmethod'] = $CFG->chat_method;
                 $chatdetails['keepdays'] = $chat->keepdays;
                 $chatdetails['studentlogs'] = $chat->studentlogs;
                 $chatdetails['chattime'] = $chat->chattime;
                 $chatdetails['schedule'] = $chat->schedule;
             }
             if (has_capability('moodle/course:manageactivities', $chatcontext)) {
                 $chatdetails['timemodified'] = $chat->timemodified;
                 $chatdetails['section'] = $chat->section;
                 $chatdetails['visible'] = $chat->visible;
                 $chatdetails['groupmode'] = $chat->groupmode;
                 $chatdetails['groupingid'] = $chat->groupingid;
             }
             $returnedchats[] = $chatdetails;
         }
     }
     $result = array();
     $result['chats'] = $returnedchats;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:58,代码来源:external.php


示例7: assign_print_overview

/**
 * Print an overview of all assignments
 * for the courses.
 *
 * @param mixed $courses The list of courses to print the overview for
 * @param array $htmlarray The array of html to return
 *
 * @return true
 */
function assign_print_overview($courses, &$htmlarray)
{
    global $CFG, $DB;
    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return true;
    }
    if (!($assignments = get_all_instances_in_courses('assign', $courses))) {
        return true;
    }
    $assignmentids = array();
    // Do assignment_base::isopen() here without loading the whole thing for speed.
    foreach ($assignments as $key => $assignment) {
        $time = time();
        $isopen = false;
        if ($assignment->duedate) {
            $duedate = false;
            if ($assignment->cutoffdate) {
                $duedate = $assignment->cutoffdate;
            }
            if ($duedate) {
                $isopen = $assignment->allowsubmissionsfromdate <= $time && $time <= $duedate;
            } else {
                $isopen = $assignment->allowsubmissionsfromdate <= $time;
            }
        }
        if ($isopen) {
            $assignmentids[] = $assignment->id;
        }
    }
    if (empty($assignmentids)) {
        // No assignments to look at - we're done.
        return true;
    }
    // Definitely something to print, now include the constants we need.
    require_once $CFG->dirroot . '/mod/assign/locallib.php';
    $strduedate = get_string('duedate', 'assign');
    $strcutoffdate = get_string('nosubmissionsacceptedafter', 'assign');
    $strnolatesubmissions = get_string('nolatesubmissions', 'assign');
    $strduedateno = get_string('duedateno', 'assign');
    $strassignment = get_string('modulename', 'assign');
    // We do all possible database work here *outside* of the loop to ensure this scales.
    list($sqlassignmentids, $assignmentidparams) = $DB->get_in_or_equal($assignmentids);
    $mysubmissions = null;
    $unmarkedsubmissions = null;
    foreach ($assignments as $assignment) {
        // Do not show assignments that are not open.
        if (!in_array($assignment->id, $assignmentids)) {
            continue;
        }
        $context = context_module::instance($assignment->coursemodule);
        // Does the submission status of the assignment require notification?
        if (has_capability('mod/assign:submit', $context)) {
            // Does the submission status of the assignment require notification?
            $submitdetails = assign_get_mysubmission_details_for_print_overview($mysubmissions, $sqlassignmentids, $assignmentidparams, $assignment);
        } else {
            $submitdetails = false;
        }
        if (has_capability('mod/assign:grade', $context)) {
            // Does the grading status of the assignment require notification ?
            $gradedetails = assign_get_grade_details_for_print_overview($unmarkedsubmissions, $sqlassignmentids, $assignmentidparams, $assignment, $context);
        } else {
            $gradedetails = false;
        }
        if (empty($submitdetails) && empty($gradedetails)) {
            // There is no need to display this assignment as there is nothing to notify.
            continue;
        }
        $dimmedclass = '';
        if (!$assignment->visible) {
            $dimmedclass = ' class="dimmed"';
        }
        $href = $CFG->wwwroot . '/mod/assign/view.php?id=' . $assignment->coursemodule;
        $basestr = '<div class="assign overview">' . '<div class="name">' . $strassignment . ': ' . '<a ' . $dimmedclass . 'title="' . $strassignment . '" ' . 'href="' . $href . '">' . format_string($assignment->name) . '</a></div>';
        if ($assignment->duedate) {
            $userdate = userdate($assignment->duedate);
            $basestr .= '<div class="info">' . $strduedate . ': ' . $userdate . '</div>';
        } else {
            $basestr .= '<div class="info">' . $strduedateno . '</div>';
        }
        if ($assignment->cutoffdate) {
            if ($assignment->cutoffdate == $assignment->duedate) {
                $basestr .= '<div class="info">' . $strnolatesubmissions . '</div>';
            } else {
                $userdate = userdate($assignment->cutoffdate);
                $basestr .= '<div class="info">' . $strcutoffdate . ': ' . $userdate . '</div>';
            }
        }
        // Show only relevant information.
        if (!empty($submitdetails)) {
            $basestr .= $submitdetails;
        }
//.........这里部分代码省略.........
开发者ID:dg711,项目名称:moodle,代码行数:101,代码来源:lib.php


示例8: quiz_print_overview

/**
 * Prints quiz summaries on MyMoodle Page
 */
function quiz_print_overview($courses, &$htmlarray)
{
    global $USER, $CFG;
    /// These next 6 Lines are constant in all modules (just change module name)
    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return array();
    }
    if (!($quizzes = get_all_instances_in_courses('quiz', $courses))) {
        return;
    }
    /// Fetch some language strings outside the main loop.
    $strquiz = get_string('modulename', 'quiz');
    $strnoattempts = get_string('noattempts', 'quiz');
    /// We want to list quizzes that are currently available, and which have a close date.
    /// This is the same as what the lesson does, and the dabate is in MDL-10568.
    $now = time();
    foreach ($quizzes as $quiz) {
        if ($quiz->timeclose >= $now && $quiz->timeopen < $now) {
            /// Give a link to the quiz, and the deadline.
            $str = '<div class="quiz overview">' . '<div class="name">' . $strquiz . ': <a ' . ($quiz->visible ? '' : ' class="dimmed"') . ' href="' . $CFG->wwwroot . '/mod/quiz/view.php?id=' . $quiz->coursemodule . '">' . $quiz->name . '</a></div>';
            $str .= '<div class="info">' . get_string('quizcloseson', 'quiz', userdate($quiz->timeclose)) . '</div>';
            /// Now provide more information depending on the uers's role.
            $context = get_context_instance(CONTEXT_MODULE, $quiz->coursemodule);
            if (has_capability('mod/quiz:viewreports', $context)) {
                /// For teacher-like people, show a summary of the number of student attempts.
                // The $quiz objects returned by get_all_instances_in_course have the necessary $cm
                // fields set to make the following call work.
                $str .= '<div class="info">' . quiz_num_attempt_summary($quiz, $quiz, true) . '</div>';
            } else {
                if (has_capability('mod/quiz:attempt', $context)) {
                    // Student
                    /// For student-like people, tell them how many attempts they have made.
                    if (isset($USER->id) && ($attempts = quiz_get_user_attempts($quiz->id, $USER->id))) {
                        $numattempts = count($attempts);
                        $str .= '<div class="info">' . get_string('numattemptsmade', 'quiz', $numattempts) . '</div>';
                    } else {
                        $str .= '<div class="info">' . $strnoattempts . '</div>';
                    }
                } else {
                    /// For ayone else, there is no point listing this quiz, so stop processing.
                    continue;
                }
            }
            /// Add the output for this quiz to the rest.
            $str .= '</div>';
            if (empty($htmlarray[$quiz->course]['quiz'])) {
                $htmlarray[$quiz->course]['quiz'] = $str;
            } else {
                $htmlarray[$quiz->course]['quiz'] .= $str;
            }
        }
    }
}
开发者ID:e-rasvet,项目名称:reader,代码行数:56,代码来源:lib.php


示例9: get_books_by_courses

 /**
  * Returns a list of books in a provided list of courses,
  * if no list is provided all books that the user can view will be returned.
  *
  * @param array $courseids the course ids
  * @return array of books details
  * @since Moodle 3.0
  */
 public static function get_books_by_courses($courseids = array())
 {
     global $CFG;
     $returnedbooks = array();
     $warnings = array();
     $params = self::validate_parameters(self::get_books_by_courses_parameters(), array('courseids' => $courseids));
     $courses = array();
     if (empty($params['courseids'])) {
         $courses = enrol_get_my_courses();
         $params['courseids'] = array_keys($courses);
     }
     // Ensure there are courseids to loop through.
     if (!empty($params['courseids'])) {
         list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
         // Get the books in this course, this function checks users visibility permissions.
         // We can avoid then additional validate_context calls.
         $books = get_all_instances_in_courses("book", $courses);
         foreach ($books as $book) {
             $context = context_module::instance($book->coursemodule);
             // Entry to return.
             $bookdetails = array();
             // First, we return information that any user can see in the web interface.
             $bookdetails['id'] = $book->id;
             $bookdetails['coursemodule'] = $book->coursemodule;
             $bookdetails['course'] = $book->course;
             $bookdetails['name'] = external_format_string($book->name, $context->id);
             // Format intro.
             list($bookdetails['intro'], $bookdetails['introformat']) = external_format_text($book->intro, $book->introformat, $context->id, 'mod_book', 'intro', null);
             $bookdetails['numbering'] = $book->numbering;
             $bookdetails['navstyle'] = $book->navstyle;
             $bookdetails['customtitles'] = $book->customtitles;
             if (has_capability('moodle/course:manageactivities', $context)) {
                 $bookdetails['revision'] = $book->revision;
                 $bookdetails['timecreated'] = $book->timecreated;
                 $bookdetails['timemodified'] = $book->timemodified;
                 $bookdetails['section'] = $book->section;
                 $bookdetails['visible'] = $book->visible;
                 $bookdetails['groupmode'] = $book->groupmode;
                 $bookdetails['groupingid'] = $book->groupingid;
             }
             $returnedbooks[] = $bookdetails;
         }
     }
     $result = array();
     $result['books'] = $returnedbooks;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:56,代码来源:external.php


示例10: choice_print_overview

/**
 * Prints choice summaries on MyMoodle Page
 *
 * Prints choice name, due date and attempt information on
 * choice activities that have a deadline that has not already passed
 * and it is available for completing.
 * @uses CONTEXT_MODULE
 * @param array $courses An array of course objects to get choice instances from.
 * @param array $htmlarray Store overview output array( course ID => 'choice' => HTML output )
 */
function choice_print_overview($courses, &$htmlarray)
{
    global $USER, $DB, $OUTPUT;
    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return;
    }
    if (!($choices = get_all_instances_in_courses('choice', $courses))) {
        return;
    }
    $now = time();
    foreach ($choices as $choice) {
        if ($choice->timeclose != 0 and $choice->timeclose >= $now and ($choice->timeopen == 0 or $choice->timeopen <= $now)) {
            // And the choice is available.
            // Visibility.
            $class = !$choice->visible ? 'dimmed' : '';
            // Link to activity.
            $url = new moodle_url('/mod/choice/view.php', array('id' => $choice->coursemodule));
            $url = html_writer::link($url, format_string($choice->name), array('class' => $class));
            $str = $OUTPUT->box(get_string('choiceactivityname', 'choice', $url), 'name');
            // Deadline.
            $str .= $OUTPUT->box(get_string('choicecloseson', 'choice', userdate($choice->timeclose)), 'info');
            // Display relevant info based on permissions.
            if (has_capability('mod/choice:readresponses', context_module::instance($choice->coursemodule))) {
                $attempts = $DB->count_records('choice_answers', array('choiceid' => $choice->id));
                $str .= $OUTPUT->box(get_string('viewallresponses', 'choice', $attempts), 'info');
            } else {
                if (has_capability('mod/choice:choose', context_module::instance($choice->coursemodule))) {
                    // See if the user has submitted anything.
                    $answers = $DB->count_records('choice_answers', array('choiceid' => $choice->id, 'userid' => $USER->id));
                    if ($answers > 0) {
                        // User has already selected an answer, nothing to show.
                        $str = '';
                    } else {
                        // User has not made a selection yet.
                        $str .= $OUTPUT->box(get_string('notanswered', 'choice'), 'info');
                    }
                } else {
                    // Does not have permission to do anything on this choice activity.
                    $str = '';
                }
            }
            // Make sure we have something to display.
            if (!empty($str)) {
                // Generate the containing div.
                $str = $OUTPUT->box($str, 'choice overview');
                if (empty($htmlarray[$choice->course]['choice'])) {
                    $htmlarray[$choice->course]['choice'] = $str;
                } else {
                    $htmlarray[$choice->course]['choice'] .= $str;
                }
            }
        }
    }
    return;
}
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:65,代码来源:lib.php


示例11: get_scorms_by_courses

 /**
  * Returns a list of scorms in a provided list of courses,
  * if no list is provided all scorms that the user can view will be returned.
  *
  * @param array $courseids the course ids
  * @return array the scorm details
  * @since Moodle 3.0
  */
 public static function get_scorms_by_courses($courseids = array())
 {
     global $CFG;
     $returnedscorms = array();
     $warnings = array();
     $params = self::validate_parameters(self::get_scorms_by_courses_parameters(), array('courseids' => $courseids));
     $courses = array();
     if (empty($params['courseids'])) {
         $courses = enrol_get_my_courses();
         $params['courseids'] = array_keys($courses);
     }
     // Ensure there are courseids to loop through.
     if (!empty($params['courseids'])) {
         list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
         // Get the scorms in this course, this function checks users visibility permissions.
         // We can avoid then additional validate_context calls.
         $scorms = get_all_instances_in_courses("scorm", $courses);
         $fs = get_file_storage();
         foreach ($scorms as $scorm) {
             $context = context_module::instance($scorm->coursemodule);
             // Entry to return.
             $module = array();
             // First, we return information that any user can see in (or can deduce from) the web interface.
             $module['id'] = $scorm->id;
             $module['coursemodule'] = $scorm->coursemodule;
             $module['course'] = $scorm->course;
             $module['name'] = external_format_string($scorm->name, $context->id);
             list($module['intro'], $module['introformat']) = external_format_text($scorm->intro, $scorm->introformat, $context->id, 'mod_scorm', 'intro', $scorm->id);
             // Check if the SCORM open and return warnings if so.
             list($open, $openwarnings) = scorm_get_availability_status($scorm, true, $context);
             if (!$open) {
                 foreach ($openwarnings as $warningkey => $warningdata) {
                     $warnings[] = array('item' => 'scorm', 'itemid' => $scorm->id, 'warningcode' => $warningkey, 'message' => get_string($warningkey, 'scorm', $warningdata));
                 }
             } else {
                 $module['packagesize'] = 0;
                 // SCORM size.
                 if ($scorm->scormtype === SCORM_TYPE_LOCAL or $scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
                     if ($packagefile = $fs->get_file($context->id, 'mod_scorm', 'package', 0, '/', $scorm->reference)) {
                         $module['packagesize'] = $packagefile->get_filesize();
                         // Download URL.
                         $module['packageurl'] = moodle_url::make_webservice_pluginfile_url($context->id, 'mod_scorm', 'package', 0, '/', $scorm->reference)->out(false);
                     }
                 }
                 $module['protectpackagedownloads'] = get_config('scorm', 'protectpackagedownloads');
                 $viewablefields = array('version', 'maxgrade', 'grademethod', 'whatgrade', 'maxattempt', 'forcecompleted', 'forcenewattempt', 'lastattemptlock', 'displayattemptstatus', 'displaycoursestructure', 'sha1hash', 'md5hash', 'revision', 'launch', 'skipview', 'hidebrowse', 'hidetoc', 'nav', 'navpositionleft', 'navpositiontop', 'auto', 'popup', 'width', 'height', 'timeopen', 'timeclose', 'displayactivityname', 'scormtype', 'reference');
                 // Check additional permissions for returning optional private settings.
                 if (has_capability('moodle/course:manageactivities', $context)) {
                     $additionalfields = array('updatefreq', 'options', 'completionstatusrequired', 'completionscorerequired', 'autocommit', 'timemodified', 'section', 'visible', 'groupmode', 'groupingid');
                     $viewablefields = array_merge($viewablefields, $additionalfields);
                 }
                 foreach ($viewablefields as $field) {
                     $module[$field] = $scorm->{$field};
                 }
             }
             $returnedscorms[] = $module;
         }
     }
     $result = array();
     $result['scorms'] = $returnedscorms;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:matiasma,项目名称:moodle,代码行数:71,代码来源:external.php


示例12: assign_print_overview

/**
 * Print an overview of all assignments
 * for the courses.
 *
 * @param mixed $courses The list of courses to print the overview for
 * @param array $htmlarray The array of html to return
 */
function assign_print_overview($courses, &$htmlarray)
{
    global $USER, $CFG, $DB;
    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return array();
    }
    if (!($assignments = get_all_instances_in_courses('assign', $courses))) {
        return;
    }
    $assignmentids = array();
    // Do assignment_base::isopen() here without loading the whole thing for speed.
    foreach ($assignments as $key => $assignment) {
        $time = time();
        $isopen = false;
        if ($assignment->duedate) {
            $duedate = false;
            if ($assignment->cutoffdate) {
                $duedate = $assignment->cutoffdate;
            }
            if ($duedate) {
                $isopen = $assignment->allowsubmissionsfromdate <= $time && $time <= $duedate;
            } else {
                $isopen = $assignment->allowsubmissionsfromdate <= $time;
            }
        }
        if ($isopen) {
            $assignmentids[] = $assignment->id;
        }
    }
    if (empty($assignmentids)) {
        // No assignments to look at - we're done.
        return true;
    }
    // Definitely something to print, now include the constants we need.
    require_once $CFG->dirroot . '/mod/assign/locallib.php';
    $strduedate = get_string('duedate', 'assign');
    $strcutoffdate = get_string('nosubmissionsacceptedafter', 'assign');
    $strnolatesubmissions = get_string('nolatesubmissions', 'assign');
    $strduedateno = get_string('duedateno', 'assign');
    $strduedateno = get_string('duedateno', 'assign');
    $strgraded = get_string('graded', 'assign');
    $strnotgradedyet = get_string('notgradedyet', 'assign');
    $strnotsubmittedyet = get_string('notsubmittedyet', 'assign');
    $strsubmitted = get_string('submitted', 'assign');
    $strassignment = get_string('modulename', 'assign');
    $strreviewed = get_string('reviewed', 'assign');
    // We do all possible database work here *outside* of the loop to ensure this scales.
    list($sqlassignmentids, $assignmentidparams) = $DB->get_in_or_equal($assignmentids);
    $mysubmissions = null;
    $unmarkedsubmissions = null;
    foreach ($assignments as $assignment) {
        // Do not show assignments that are not open.
        if (!in_array($assignment->id, $assignmentids)) {
            continue;
        }
        $dimmedclass = '';
        if (!$assignment->visible) {
            $dimmedclass = ' class="dimmed"';
        }
        $href = $CFG->wwwroot . '/mod/assign/view.php?id=' . $assignment->coursemodule;
        $str = '<div class="assign overview">' . '<div class="name">' . $strassignment . ': ' . '<a ' . $dimmedclass . 'title="' . $strassignment . '" ' . 'href="' . $href . '">' . format_string($assignment->name) . '</a></div>';
        if ($assignment->duedate) {
            $userdate = userdate($assignment->duedate);
            $str .= '<div class="info">' . $strduedate . ': ' . $userdate . '</div>';
        } else {
            $str .= '<div class="info">' . $strduedateno . '</div>';
        }
        if ($assignment->cutoffdate) {
            if ($assignment->cutoffdate == $assignment->duedate) {
                $str .= '<div class="info">' . $strnolatesubmissions . '</div>';
            } else {
                $userdate = userdate($assignment->cutoffdate);
                $str .= '<div class="info">' . $strcutoffdate . ': ' . $userdate . '</div>';
            }
        }
        $context = context_module::instance($assignment->coursemodule);
        if (has_capability('mod/assign:grade', $context)) {
            if (!isset($unmarkedsubmissions)) {
                $submissionmaxattempt = 'SELECT mxs.userid, MAX(mxs.attemptnumber) AS maxattempt, mxs.assignment
                                         FROM {assign_submission} mxs
                                         WHERE mxs.assignment ' . $sqlassignmentids . '
                                         GROUP BY mxs.userid, mxs.assignment';
                // Build up and array of unmarked submissions indexed by assignment id/ userid
                // for use where the user has grading rights on assignment.
                $dbparams = array_merge($assignmentidparams, array(ASSIGN_SUBMISSION_STATUS_SUBMITTED), $assignmentidparams);
                $rs = $DB->get_recordset_sql('SELECT
                                                  s.assignment as assignment,
                                                  s.userid as userid,
                                                  s.id as id,
                                                  s.status as status,
                                                  g.timemodified as timegraded
                                              FROM {assign_submission} s
                                              LEFT JOIN ( ' . $submissionmaxattempt . ' ) smx ON
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:lib.php


示例13: get_glossaries_by_courses

 /**
  * Returns a list of glossaries in a provided list of courses.
  *
  * If no list is provided all glossaries that the user can view will be returned.
  *
  * @param array $courseids the course IDs.
  * @return array of glossaries
  * @since Moodle 3.1
  */
 public static function get_glossaries_by_courses($courseids = array())
 {
     $params = self::validate_parameters(self::get_glossaries_by_courses_parameters(), array('courseids' => $courseids));
     $warnings = array();
     $courses = array();
     $courseids = $params['courseids'];
     if (empty($courseids)) {
         $courses = enrol_get_my_courses();
         $courseids = array_keys($courses);
     }
     // Array to store the glossaries to return.
     $glossaries = array();
     $modes = array();
     // Ensure there are courseids to loop through.
     if (!empty($courseids)) {
         list($courses, $warnings) = external_util::validate_courses($courseids, $courses);
         // Get the glossaries in these courses, this function checks users visibility permissions.
         $glossaries = get_all_instances_in_courses('glossary', $courses);
         foreach ($glossaries as $glossary) {
             $context = context_module::instance($glossary->coursemodule);
             $glossary->name = external_format_string($glossary->name, $context->id);
             list($glossary->intro, $glossary->introformat) = external_format_text($glossary->intro, $glossary->introformat, $context->id, 'mod_glossary', 'intro', null);
             $glossary->introfiles = external_util::get_area_files($context->id, 'mod_glossary', 'intro', false, false);
             // Make sure we have a number of entries per page.
             if (!$glossary->entbypage) {
                 $glossary->entbypage = $CFG->glossary_entbypage;
             }
             // Add the list of browsing modes.
             if (!isset($modes[$glossary->displayformat])) {
                 $modes[$glossary->displayformat] = self::get_browse_modes_from_display_format($glossary->displayformat);
             }
             $glossary->browsemodes = $modes[$glossary->displayformat];
             $glossary->canaddentry = has_capability('mod/glossary:write', $context) ? 1 : 0;
         }
     }
     $result = array();
     $result['glossaries'] = $glossaries;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:janeklb,项目名称:moodle,代码行数:49,代码来源:external.php


示例14: webexactivity_print_overview

/**
 * Print an overview of all WebEx Meetings for the courses.
 *
 * @param mixed   $courses The list of courses to print the overview for
 * @param array   $htmlarray The array of html to return
 */
function webexactivity_print_overview($courses, &$htmlarray)
{
    global $USER, $CFG, $DB;
    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return;
    }
    if (!($meetings = get_all_instances_in_courses('webexactivity', $courses))) {
        return;
    }
    $displaymeetings = array();
    foreach ($meetings as $rec) {
        $meeting = \mod_webexactivity\meeting::load($rec);
        if ($meeting->is_available()) {
            $displaymeetings[] = $meeting;
        }
    }
    if (count($displaymeetings) == 0) {
        return;
    }
    $strmodname = get_string('modulename', 'webexactivity');
    $strinprogress = get_string('inprogress', 'webexactivity');
    $strstartsoon = get_string('startssoon', 'webexactivity');
    $strstarttime = get_string('starttime', 'webexactivity');
    $strstatus = get_string('status');
    foreach ($displaymeetings as $meeting) {
        $href = $CFG->wwwroot . '/mod/webexactivity/view.php?id=' . $meeting->coursemodule;
        $str = '<div class="webexactivity overview"><div class="name">';
        $str .= $strmodname . ': <a title="' . $strmodname . '" href="' . $href . '">';
        $str .= format_string($meeting->name) . '</a></div>';
        $status = $meeting->get_time_status();
        if (!isset($meeting->endtime)) {
            $str .= '<div class="start">' . $strstarttime . ': ' . userdate($meeting->starttime) . '</div>';
        }
        if ($status == \mod_webexac 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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