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


PHP assignment_get_all_submissions函数代码示例

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


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

示例1: assignment_get_content_for_index

/**
* part of search engine API
* @uses $CFG, $DB
*
*/
function assignment_get_content_for_index(&$assignment)
{
    global $CFG, $DB;
    $documents = array();
    $course = $DB->get_record('course', array('id' => $assignment->course));
    $coursemodule = $DB->get_field('modules', 'id', array('name' => 'assignment'));
    $cm = $DB->get_record('course_modules', array('course' => $assignment->course, 'module' => $coursemodule, 'instance' => $assignment->id));
    if ($cm) {
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        $assignment = assignment_add_document_fields($assignment);
        $documents[] = new AssignmentSearchDocument(get_object_vars($assignment), $cm->id, 'intro', $assignment->course, null, $context->id);
        $submissions = assignment_get_all_submissions($assignment);
        if ($submissions) {
            $submissionoffset = -1;
            foreach ($submissions as $submission) {
                $submissionoffset++;
                $submission = assignment_submission_add_document_fields($assignment, $submission);
                if (file_exists("{$CFG->dirroot}/mod/assignment/type/{$assignment->assignmenttype}/searchlib.php")) {
                    include_once "{$CFG->dirroot}/mod/assignment/type/{$assignment->assignmenttype}/searchlib.php";
                    if (function_exists('assignment_get_submission_location')) {
                        $submitted = assignment_get_submission_location($assignment, $submission);
                    }
                }
                if (empty($submitted)) {
                    // this is for moodle legacy types that would need not to be patched for searchlib.php
                    switch ($assignment->assignmenttype) {
                        case 'online':
                            $submitted->source = 'text';
                            $submitted->data = $submission->data1;
                            break;
                        case 'uploadsingle':
                        case 'upload':
                            $submitted->source = 'files';
                            $submitted->data = "{$assignment->course}/moddata/assignment/{$assignment->id}/{$submission->userid}";
                            break;
                        case 'offline':
                            continue;
                            // cannot index, no content in Moodle !!
                    }
                }
                if (empty($submitted)) {
                    continue;
                }
                // ignoring
                if ($submitted->source = 'text') {
                    $submission->description = $submitted->data;
                    $submission->description = preg_replace("/<[^>]*>/", '', $submission->description);
                    // stip all tags
                    $documents[] = new AssignmentSearchDocument(get_object_vars($submission), $cm->id, 'submission', $assignment->course, $submission->userid, $context->id, $submissionoffset);
                    mtrace("finished online submission for {$submission->authors} in assignment {$assignment->name}");
                } elseif ($submitted->source = 'files') {
                    $SUBMITTED = opendir($submitted->path);
                    while ($entry = readdir($SUBMITTED)) {
                        if (preg_match("/^\\./", $entry)) {
                            continue;
                        }
                        // exclude hidden and dirs . and ..
                        $path = "{$submitted->path}/{$entry}";
                        $documents[] = assignment_get_physical_file($submission, $assignment, $cm, $path, $context_id, $documents);
                        mtrace("finished attachement {$path} for {$submission->authors} in assignment {$assignment->name}");
                    }
                    closedir($submission->path);
                }
            }
        }
        mtrace("finished assignment {$assignment->name}");
        return $documents;
    }
    return array();
}
开发者ID:vuchannguyen,项目名称:web,代码行数:75,代码来源:assignment_document.php

示例2: get_submissions

 /**
  * Return all assignment submissions by ENROLLED students (even empty)
  *
  * @param string $sort optional field names for the ORDER BY in the sql query
  * @param string $dir optional specifying the sort direction, defaults to DESC
  * @return array The submission objects indexed by id
  */
 function get_submissions($sort='', $dir='DESC') {
     return assignment_get_all_submissions($this->assignment, $sort, $dir);
 }
开发者ID:nuckey,项目名称:moodle,代码行数:10,代码来源:lib.php

示例3: moss_trigger_assignment_events

/**
 * Trigger assessable_file_uploaded and assessable_files_done events of specified assignment.
 *
 * @param int $cmid
 * @param bool $trigger_done whether trigger assessable_files_done event. Advanced upload assignment only.
 * @return number of submissions found, or false on failed
 */
function moss_trigger_assignment_events($cmid, $trigger_done = true) {
    global $DB, $CFG;
    require_once($CFG->dirroot.'/mod/assignment/lib.php');

    $cm = get_coursemodule_from_id('assignment', $cmid);
    if (empty($cm)) {
        return false;
    }

    $context = get_context_instance(CONTEXT_MODULE, $cmid);
    $fs = get_file_storage();
    $assignment = $DB->get_record('assignment', array('id' => $cm->instance), '*', MUST_EXIST);
    $submissions = assignment_get_all_submissions($assignment);

    foreach ($submissions as $submission) {
        $files = $fs->get_area_files($context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false);
        $eventdata = new stdClass();
        $eventdata->modulename   = 'assignment';
        $eventdata->cmid         = $cmid;
        $eventdata->itemid       = $submission->id;
        $eventdata->courseid     = $cm->course;
        $eventdata->userid       = $submission->userid;
        if ($files) {
            if ($assignment->assignmenttype == 'upload') {
                $eventdata->files = $files;
            } else { // uploadsingle
                $eventdata->file = current($files);
            }
        }
        events_trigger('assessable_file_uploaded', $eventdata);
        if ($trigger_done and $assignment->assignmenttype == 'upload') {
            unset($eventdata->files);
            events_trigger('assessable_files_done', $eventdata);
        }
    }

    return count($submissions);
}
开发者ID:Jelinet,项目名称:moodle-plagiarism_moss,代码行数:45,代码来源:locallib.php


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