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


PHP shift_course_mod_dates函数代码示例

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


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

示例1: feedback_reset_userdata

/**
 * This function is used by the reset_course_userdata function in moodlelib.
 * This function will remove all responses from the specified feedback
 * and clean up any related data.
 *
 * @global object
 * @global object
 * @uses FEEDBACK_RESETFORM_RESET
 * @uses FEEDBACK_RESETFORM_DROP
 * @param object $data the data submitted from the reset course.
 * @return array status array
 */
function feedback_reset_userdata($data)
{
    global $CFG, $DB;
    $resetfeedbacks = array();
    $dropfeedbacks = array();
    $status = array();
    $componentstr = get_string('modulenameplural', 'feedback');
    //get the relevant entries from $data
    foreach ($data as $key => $value) {
        switch (true) {
            case substr($key, 0, strlen(FEEDBACK_RESETFORM_RESET)) == FEEDBACK_RESETFORM_RESET:
                if ($value == 1) {
                    $templist = explode('_', $key);
                    if (isset($templist[3])) {
                        $resetfeedbacks[] = intval($templist[3]);
                    }
                }
                break;
            case substr($key, 0, strlen(FEEDBACK_RESETFORM_DROP)) == FEEDBACK_RESETFORM_DROP:
                if ($value == 1) {
                    $templist = explode('_', $key);
                    if (isset($templist[3])) {
                        $dropfeedbacks[] = intval($templist[3]);
                    }
                }
                break;
        }
    }
    //reset the selected feedbacks
    foreach ($resetfeedbacks as $id) {
        $feedback = $DB->get_record('feedback', array('id' => $id));
        feedback_delete_all_completeds($feedback);
        $status[] = array('component' => $componentstr . ':' . $feedback->name, 'item' => get_string('resetting_data', 'feedback'), 'error' => false);
    }
    // Updating dates - shift may be negative too.
    if ($data->timeshift) {
        $shifterror = !shift_course_mod_dates('feedback', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => $shifterror);
    }
    return $status;
}
开发者ID:evltuma,项目名称:moodle,代码行数:53,代码来源:lib.php

示例2: reset_userdata

    /**
     * Reset all submissions
     */
    function reset_userdata($data) {
        global $CFG, $DB;

        if (!$DB->count_records('assignment', array('course'=>$data->courseid, 'assignmenttype'=>$this->type))) {
            return array(); // no assignments of this type present
        }

        $componentstr = get_string('modulenameplural', 'assignment');
        $status = array();

        $typestr = get_string('type'.$this->type, 'assignment');
        // ugly hack to support pluggable assignment type titles...
        if($typestr === '[[type'.$this->type.']]'){
            $typestr = get_string('type'.$this->type, 'assignment_'.$this->type);
        }

        if (!empty($data->reset_assignment_submissions)) {
            $assignmentssql = "SELECT a.id
                                 FROM {assignment} a
                                WHERE a.course=? AND a.assignmenttype=?";
            $params = array($data->courseid, $this->type);

            // now get rid of all submissions and responses
            $fs = get_file_storage();
            if ($assignments = $DB->get_records_sql($assignmentssql, $params)) {
                foreach ($assignments as $assignmentid=>$unused) {
                    if (!$cm = get_coursemodule_from_instance('assignment', $assignmentid)) {
                        continue;
                    }
                    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                    $fs->delete_area_files($context->id, 'mod_assignment', 'submission');
                    $fs->delete_area_files($context->id, 'mod_assignment', 'response');
                }
            }

            $DB->delete_records_select('assignment_submissions', "assignment IN ($assignmentssql)", $params);

            $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallsubmissions','assignment').': '.$typestr, 'error'=>false);

            if (empty($data->reset_gradebook_grades)) {
                // remove all grades from gradebook
                assignment_reset_gradebook($data->courseid, $this->type);
            }
        }

        /// updating dates - shift may be negative too
        if ($data->timeshift) {
            shift_course_mod_dates('assignment', array('timedue', 'timeavailable'), $data->timeshift, $data->courseid);
            $status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged').': '.$typestr, 'error'=>false);
        }

        return $status;
    }
开发者ID:nuckey,项目名称:moodle,代码行数:56,代码来源:lib.php

示例3: chat_reset_userdata

/**
 * Actual implementation of the rest coures functionality, delete all the
 * chat messages for course $data->courseid.
 *
 * @global object
 * @global object
 * @param object $data the data submitted from the reset course.
 * @return array status array
 */
function chat_reset_userdata($data)
{
    global $CFG, $DB;
    $componentstr = get_string('modulenameplural', 'chat');
    $status = array();
    if (!empty($data->reset_chat)) {
        $chatessql = "SELECT ch.id\n                        FROM {chat} ch\n                       WHERE ch.course=?";
        $params = array($data->courseid);
        $DB->delete_records_select('chat_messages', "chatid IN ({$chatessql})", $params);
        $DB->delete_records_select('chat_messages_current', "chatid IN ({$chatessql})", $params);
        $DB->delete_records_select('chat_users', "chatid IN ({$chatessql})", $params);
        $status[] = array('component' => $componentstr, 'item' => get_string('removemessages', 'chat'), 'error' => false);
    }
    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('chat', array('chattime'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
    }
    return $status;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:29,代码来源:lib.php

示例4: reset_userdata

 /**
  * Actual implementation of the reset course functionality, delete all the
  * assignment submissions for course $data->courseid.
  *
  * @param stdClass $data the data submitted from the reset course.
  * @return array status array
  */
 public function reset_userdata($data)
 {
     global $CFG, $DB;
     $componentstr = get_string('modulenameplural', 'assign');
     $status = array();
     $fs = get_file_storage();
     if (!empty($data->reset_assign_submissions)) {
         // Delete files associated with this assignment.
         foreach ($this->submissionplugins as $plugin) {
             $fileareas = array();
             $plugincomponent = $plugin->get_subtype() . '_' . $plugin->get_type();
             $fileareas = $plugin->get_file_areas();
             foreach ($fileareas as $filearea => $notused) {
                 $fs->delete_area_files($this->context->id, $plugincomponent, $filearea);
             }
             if (!$plugin->delete_instance()) {
                 $status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => $plugin->get_error());
             }
         }
         foreach ($this->feedbackplugins as $plugin) {
             $fileareas = array();
             $plugincomponent = $plugin->get_subtype() . '_' . $plugin->get_type();
             $fileareas = $plugin->get_file_areas();
             foreach ($fileareas as $filearea => $notused) {
                 $fs->delete_area_files($this->context->id, $plugincomponent, $filearea);
             }
             if (!$plugin->delete_instance()) {
                 $status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => $plugin->get_error());
             }
         }
         $assignids = $DB->get_records('assign', array('course' => $data->courseid), '', 'id');
         list($sql, $params) = $DB->get_in_or_equal(array_keys($assignids));
         $DB->delete_records_select('assign_submission', "assignment {$sql}", $params);
         $DB->delete_records_select('assign_user_flags', "assignment {$sql}", $params);
         $status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => false);
         if (!empty($data->reset_gradebook_grades)) {
             $DB->delete_records_select('assign_grades', "assignment {$sql}", $params);
             // Remove all grades from gradebook.
             require_once $CFG->dirroot . '/mod/assign/lib.php';
             assign_reset_gradebook($data->courseid);
             // Reset revealidentities if both submissions and grades have been reset.
             if ($this->get_instance()->blindmarking && $this->get_instance()->revealidentities) {
                 $DB->set_field('assign', 'revealidentities', 0, array('id' => $this->get_instance()->id));
             }
         }
     }
     // Updating dates - shift may be negative too.
     if ($data->timeshift) {
         shift_course_mod_dates('assign', array('duedate', 'allowsubmissionsfromdate', 'cutoffdate'), $data->timeshift, $data->courseid, $this->get_instance()->id);
         $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
     }
     return $status;
 }
开发者ID:mercysmart,项目名称:naikelas,代码行数:60,代码来源:locallib.php

示例5: assignment_reset_userdata

/**
 * This function is used by the reset_course_userdata function in moodlelib.
 * This function will remove all posts from the specified assignment
 * and clean up any related data.
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function assignment_reset_userdata($data)
{
    global $CFG;
    $status = array();
    foreach (core_component::get_plugin_list('assignment') as $type => $dir) {
        require_once "{$dir}/assignment.class.php";
        $assignmentclass = "assignment_{$type}";
        $ass = new $assignmentclass();
        $status = array_merge($status, $ass->reset_userdata($data));
    }
    // Updating dates - shift may be negative too.
    if ($data->timeshift) {
        shift_course_mod_dates('assignment', array('timedue', 'timeavailable'), $data->timeshift, $data->courseid);
        $status[] = array('component' => get_string('modulenameplural', 'assignment'), 'item' => get_string('datechanged'), 'error' => false);
    }
    return $status;
}
开发者ID:nanda555,项目名称:TestAppFromAWS,代码行数:24,代码来源:lib.php

示例6: opencast_reset_userdata

/**
 * Actual implementation of the reset course functionality, delete all the
 * opencast clip members for course $data->courseid.
 *
 * @param object $data the data submitted from the reset course.
 *
 * @return array status array
 */
function opencast_reset_userdata($data)
{
    global $CFG, $DB;
    $componentstr = get_string('modulenameplural', 'opencast');
    $status = [];
    if (!empty($data->reset_opencast)) {
        $DB->delete_records('opencast_cmember', ['courseid' => $data->courseid]);
        $status[] = ['component' => $componentstr, 'item' => get_string('removeclipmembers', 'opencast'), 'error' => false];
    }
    // updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('opencast', ['timeopen', 'timeclose'], $data->timeshift, $data->courseid);
        $status[] = ['component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false];
    }
    return $status;
}
开发者ID:ndunand,项目名称:moodle-mod_opencast,代码行数:24,代码来源:lib.php

示例7: quiz_reset_userdata

/**
 * Actual implementation of the reset course functionality, delete all the
 * quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is
 * set and true.
 *
 * Also, move the quiz open and close dates, if the course start date is changing.
 *
 * @global stdClass
 * @global object
 * @param object $data the data submitted from the reset course.
 * @return array status array
 */
function quiz_reset_userdata($data) {
    global $CFG, $DB;
    require_once($CFG->libdir.'/questionlib.php');

    $componentstr = get_string('modulenameplural', 'quiz');
    $status = array();

    /// Delete attempts.
    if (!empty($data->reset_quiz_attempts)) {
        $quizzes = $DB->get_records('quiz', array('course' => $data->courseid));
        foreach ($quizzes as $quiz) {
            quiz_delete_all_attempts($quiz);
        }

        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            quiz_reset_gradebook($data->courseid);
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('attemptsdeleted', 'quiz'), 'error' => false);
    }

    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('quiz', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('openclosedatesupdated', 'quiz'), 'error' => false);
    }

    return $status;
}
开发者ID:nfreear,项目名称:moodle,代码行数:41,代码来源:lib.php

示例8: glossary_reset_userdata


//.........这里部分代码省略.........
    $componentstr = get_string('modulenameplural', 'glossary');
    $status = array();
    $allentriessql = "SELECT e.id\n                        FROM {$CFG->prefix}glossary_entries e\n                             INNER JOIN {$CFG->prefix}glossary g ON e.glossaryid = g.id\n                       WHERE g.course = {$data->courseid}";
    $allglossariessql = "SELECT g.id\n                            FROM {$CFG->prefix}glossary g\n                           WHERE g.course={$data->courseid}";
    // delete entries if requested
    if (!empty($data->reset_glossary_all) or !empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types)) {
        delete_records_select('glossary_ratings', "entryid IN ({$allentriessql})");
        delete_records_select('glossary_comments', "entryid IN ({$allentriessql})");
        delete_records_select('glossary_entries', "glossaryid IN ({$allglossariessql})");
        if ($glossaries = get_records_sql($allglossariessql)) {
            foreach ($glossaries as $glossaryid => $unused) {
                fulldelete($CFG->dataroot . "/{$data->courseid}/moddata/glossary/{$glossaryid}");
            }
        }
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            glossary_reset_gradebook($data->courseid);
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('resetglossariesall', 'glossary'), 'error' => false);
    } else {
        if (!empty($data->reset_glossary_types)) {
            $mainentriessql = "{$allentries} AND g.mainglossary=1";
            $secondaryentriessql = "{$allentries} AND g.mainglossary=0";
            $mainglossariessql = "{$allglossariessql} AND g.mainglossary=1";
            $secondaryglossariessql = "{$allglossariessql} AND g.mainglossary=0";
            if (in_array('main', $data->reset_glossary_types)) {
                delete_records_select('glossary_ratings', "entryid IN ({$mainentriessql})");
                delete_records_select('glossary_comments', "entryid IN ({$mainentriessql})");
                delete_records_select('glossary_entries', "glossaryid IN ({$mainglossariessql})");
                if ($glossaries = get_records_sql($mainglossariessql)) {
                    foreach ($glossaries as $glossaryid => $unused) {
                        fulldelete("{$CFG->dataroot}/{$data->courseid}/moddata/glossary/{$glossaryid}");
                    }
                }
                // remove all grades from gradebook
                if (empty($data->reset_gradebook_grades)) {
                    glossary_reset_gradebook($data->courseid, 'main');
                }
                $status[] = array('component' => $componentstr, 'item' => get_string('resetglossaries', 'glossary'), 'error' => false);
            } else {
                if (in_array('secondary', $data->reset_glossary_types)) {
                    delete_records_select('glossary_ratings', "entryid IN ({$secondaryentriessql})");
                    delete_records_select('glossary_comments', "entryid IN ({$secondaryentriessql})");
                    delete_records_select('glossary_entries', "glossaryid IN ({$secondaryglossariessql})");
                    // remove exported source flag from entries in main glossary
                    execute_sql("UPDATE {$CFG->prefix}glossary_entries\n                            SET sourceglossaryid=0\n                          WHERE glossaryid IN ({$mainglossariessql})", false);
                    if ($glossaries = get_records_sql($secondaryglossariessql)) {
                        foreach ($glossaries as $glossaryid => $unused) {
                            fulldelete("{$CFG->dataroot}/{$data->courseid}/moddata/glossary/{$glossaryid}");
                        }
                    }
                    // remove all grades from gradebook
                    if (empty($data->reset_gradebook_grades)) {
                        glossary_reset_gradebook($data->courseid, 'secondary');
                    }
                    $status[] = array('component' => $componentstr, 'item' => get_string('resetglossaries', 'glossary') . ': ' . get_string('secondaryglossary', 'glossary'), 'error' => false);
                }
            }
        }
    }
    // remove entries by users not enrolled into course
    if (!empty($data->reset_glossary_notenrolled)) {
        $entriessql = "SELECT e.id, e.userid, e.glossaryid, u.id AS userexists, u.deleted AS userdeleted\n                         FROM {$CFG->prefix}glossary_entries e\n                              INNER JOIN {$CFG->prefix}glossary g ON e.glossaryid = g.id\n                              LEFT OUTER JOIN {$CFG->prefix}user u ON e.userid = u.id\n                        WHERE g.course = {$data->courseid} AND e.userid > 0";
        $course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
        $notenrolled = array();
        if ($rs = get_recordset_sql($entriessql)) {
            while ($entry = rs_fetch_next_record($rs)) {
                if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted or !has_capability('moodle/course:view', $course_context, $entry->userid)) {
                    delete_records('glossary_ratings', 'entryid', $entry->id);
                    delete_records('glossary_comments', 'entryid', $entry->id);
                    delete_records('glossary_entries', 'id', $entry->id);
                    fulldelete("{$CFG->dataroot}/{$data->courseid}/moddata/glossary/{$entry->glossaryid}");
                    $notenrolled[$entry->userid] = true;
                }
            }
            rs_close($rs);
            $status[] = array('component' => $componentstr, 'item' => get_string('deletenotenrolled', 'glossary'), 'error' => false);
        }
    }
    // remove all ratings
    if (!empty($data->reset_glossary_ratings)) {
        delete_records_select('glossary_ratings', "entryid IN ({$allentriessql})");
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            glossary_reset_gradebook($data->courseid);
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('deleteallratings'), 'error' => false);
    }
    // remove all comments
    if (!empty($data->reset_glossary_comments)) {
        delete_records_select('glossary_comments', "entryid IN ({$allentriessql})");
        $status[] = array('component' => $componentstr, 'item' => get_string('deleteallcomments'), 'error' => false);
    }
    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('glossary', array('assesstimestart', 'assesstimefinish'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
    }
    return $status;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:lib.php

示例9: lesson_reset_userdata

/**
 * Actual implementation of the reset course functionality, delete all the
 * lesson attempts for course $data->courseid.
 *
 * @global stdClass
 * @global object
 * @param object $data the data submitted from the reset course.
 * @return array status array
 */
function lesson_reset_userdata($data)
{
    global $CFG, $DB;
    $componentstr = get_string('modulenameplural', 'lesson');
    $status = array();
    if (!empty($data->reset_lesson)) {
        $lessonssql = "SELECT l.id\n                         FROM {lesson} l\n                        WHERE l.course=:course";
        $params = array("course" => $data->courseid);
        $lessons = $DB->get_records_sql($lessonssql, $params);
        // Get rid of attempts files.
        $fs = get_file_storage();
        if ($lessons) {
            foreach ($lessons as $lessonid => $unused) {
                if (!($cm = get_coursemodule_from_instance('lesson', $lessonid))) {
                    continue;
                }
                $context = context_module::instance($cm->id);
                $fs->delete_area_files($context->id, 'mod_lesson', 'essay_responses');
            }
        }
        $DB->delete_records_select('lesson_timer', "lessonid IN ({$lessonssql})", $params);
        $DB->delete_records_select('lesson_grades', "lessonid IN ({$lessonssql})", $params);
        $DB->delete_records_select('lesson_attempts', "lessonid IN ({$lessonssql})", $params);
        $DB->delete_records_select('lesson_branch', "lessonid IN ({$lessonssql})", $params);
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            lesson_reset_gradebook($data->courseid);
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('deleteallattempts', 'lesson'), 'error' => false);
    }
    // Remove user overrides.
    if (!empty($data->reset_lesson_user_overrides)) {
        $DB->delete_records_select('lesson_overrides', 'lessonid IN (SELECT id FROM {lesson} WHERE course = ?) AND userid IS NOT NULL', array($data->courseid));
        $status[] = array('component' => $componentstr, 'item' => get_string('useroverridesdeleted', 'lesson'), 'error' => false);
    }
    // Remove group overrides.
    if (!empty($data->reset_lesson_group_overrides)) {
        $DB->delete_records_select('lesson_overrides', 'lessonid IN (SELECT id FROM {lesson} WHERE course = ?) AND groupid IS NOT NULL', array($data->courseid));
        $status[] = array('component' => $componentstr, 'item' => get_string('groupoverridesdeleted', 'lesson'), 'error' => false);
    }
    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        $DB->execute("UPDATE {lesson_overrides}\n                         SET available = available + ?\n                       WHERE lessonid IN (SELECT id FROM {lesson} WHERE course = ?)\n                         AND available <> 0", array($data->timeshift, $data->courseid));
        $DB->execute("UPDATE {lesson_overrides}\n                         SET deadline = deadline + ?\n                       WHERE lessonid IN (SELECT id FROM {lesson} WHERE course = ?)\n                         AND deadline <> 0", array($data->timeshift, $data->courseid));
        shift_course_mod_dates('lesson', array('available', 'deadline'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
    }
    return $status;
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:58,代码来源:lib.php

示例10: organizer_reset_userdata

function organizer_reset_userdata($data)
{
    global $DB;
    if (!$DB->count_records('organizer', array('course' => $data->courseid))) {
        return array();
    }
    $componentstr = get_string('modulenameplural', 'organizer');
    $status = array();
    if (isset($data->reset_organizer_all)) {
        $params = array('courseid' => $data->courseid);
        $slotquery = 'SELECT s.*
                    FROM {organizer_slots} s
                    INNER JOIN {organizer} m ON s.organizerid = m.id
                    WHERE m.course = :courseid';
        $appquery = 'SELECT a.*
                    FROM {organizer_slot_appointments} a
                    INNER JOIN {organizer_slots} s ON a.slotid = s.id
                    INNER JOIN {organizer} m ON s.organizerid = m.id
                    WHERE m.course = :courseid';
        $slots = $DB->get_records_sql($slotquery, $params);
        $appointments = $DB->get_records_sql($appquery, $params);
        $ok = true;
        foreach ($slots as $slot) {
            $DB->delete_records('event', array('id' => $slot->eventid));
            //tscpr: Petr Skoda told us that $DB->delete_records will throw an exeption if it fails, otherwise it always succeeds...
            $ok &= $DB->delete_records('organizer_slots', array('id' => $slot->id));
        }
        foreach ($appointments as $appointment) {
            $DB->delete_records('event', array('id' => $appointment->eventid));
            //tscpr: Petr Skoda told us that $DB->delete_records will throw an exeption if it fails, otherwise it always succeeds...
            $ok &= $DB->delete_records('organizer_slot_appointments', array('id' => $appointment->id));
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('reset_organizer_all', 'organizer'), 'error' => !$ok);
    }
    if (isset($data->delete_organizer_grades)) {
        $ok = organizer_reset_gradebook($data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('delete_organizer_grades', 'organizer'), 'error' => !$ok);
    }
    if ($data->timeshift) {
        $ok = shift_course_mod_dates('organizer', array('allowregistrationsfromdate', 'duedate'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('timeshift', 'organizer'), 'error' => !$ok);
    }
    return $status;
}
开发者ID:miotto,项目名称:moodle-mod_organizer,代码行数:44,代码来源:lib.php

示例11: assign_reset_userdata

/**
 * This function is used by the reset_course_userdata function in moodlelib.
 * This function will remove all assignment submissions and feedbacks in the database
 * and clean up any related data.
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function assign_reset_userdata($data) {
    global $CFG, $DB;
    require_once($CFG->dirroot . '/mod/assign/locallib.php');

    $status = array();
    $params = array('courseid'=>$data->courseid);
    $sql = "SELECT a.id FROM {assign} a WHERE a.course=:courseid";
    $course = $DB->get_record('course', array('id'=>$data->courseid), '*', MUST_EXIST);
    if ($assigns = $DB->get_records_sql($sql, $params)) {
        foreach ($assigns as $assign) {
            $cm = get_coursemodule_from_instance('assign',
                                                 $assign->id,
                                                 $data->courseid,
                                                 false,
                                                 MUST_EXIST);
            $context = context_module::instance($cm->id);
            $assignment = new assign($context, $cm, $course);
            $status = array_merge($status, $assignment->reset_userdata($data));
        }
    }
    // Updating dates - shift may be negative too.
    if ($data->timeshift) {
        shift_course_mod_dates('assign',
                                array('duedate', 'allowsubmissionsfromdate', 'cutoffdate'),
                                $data->timeshift,
                                $data->courseid);

        $status[] = array('component' => get_string('modulenameplural', 'assign'),
                          'item' => get_string('datechanged'),
                          'error' => false);
    }
    return $status;
}
开发者ID:verbazend,项目名称:AWFA,代码行数:40,代码来源:lib.php

示例12: certificate_reset_userdata

/**
 * This function is used by the reset_course_userdata function in moodlelib.
 * This function will remove all posts from the specified certificate
 * and clean up any related data.
 *
 * Written by Jean-Michel Vedrine
 *
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function certificate_reset_userdata($data)
{
    global $DB;
    $componentstr = get_string('modulenameplural', 'certificate');
    $status = array();
    if (!empty($data->reset_certificate)) {
        $sql = "SELECT cert.id\n                  FROM {certificate} cert\n                 WHERE cert.course = :courseid";
        $params = array('courseid' => $data->courseid);
        $certificates = $DB->get_records_sql($sql, $params);
        $fs = get_file_storage();
        if ($certificates) {
            foreach ($certificates as $certid => $unused) {
                if (!($cm = get_coursemodule_from_instance('certificate', $certid))) {
                    continue;
                }
                $context = context_module::instance($cm->id);
                $fs->delete_area_files($context->id, 'mod_certificate', 'issue');
            }
        }
        $DB->delete_records_select('certificate_issues', "certificateid IN ({$sql})", $params);
        $status[] = array('component' => $componentstr, 'item' => get_string('removecert', 'certificate'), 'error' => false);
    }
    // Updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('certificate', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
    }
    return $status;
}
开发者ID:ccle,项目名称:moodle-mod_certificate,代码行数:39,代码来源:lib.php

示例13: glossary_reset_userdata


//.........这里部分代码省略.........
            $DB->delete_records_select('glossary_entries', "glossaryid IN ($secondaryglossariessql)", $params);
            // remove exported source flag from entries in main glossary
            $DB->execute("UPDATE {glossary_entries
                             SET sourceglossaryid=0
                           WHERE glossaryid IN ($mainglossariessql)", $params);

            if ($glossaries = $DB->get_records_sql($secondaryglossariessql, $params)) {
                foreach ($glossaries as $glossaryid=>$unused) {
                    if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
                        continue;
                    }
                    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                    $fs->delete_area_files($context->id, 'mod_glossary', 'attachment');

                    //delete ratings
                    $ratingdeloptions->contextid = $context->id;
                    $rm->delete_ratings($ratingdeloptions);
                }
            }

            // remove all grades from gradebook
            if (empty($data->reset_gradebook_grades)) {
                glossary_reset_gradebook($data->courseid, 'secondary');
            }

            $status[] = array('component'=>$componentstr, 'item'=>get_string('resetglossaries', 'glossary').': '.get_string('secondaryglossary', 'glossary'), 'error'=>false);
        }
    }

    // remove entries by users not enrolled into course
    if (!empty($data->reset_glossary_notenrolled)) {
        $entriessql = "SELECT e.id, e.userid, e.glossaryid, u.id AS userexists, u.deleted AS userdeleted
                         FROM {glossary_entries} e
                              JOIN {glossary} g ON e.glossaryid = g.id
                              LEFT JOIN {user} u ON e.userid = u.id
                        WHERE g.course = ? AND e.userid > 0";

        $course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
        $notenrolled = array();
        $rs = $DB->get_recordset_sql($entriessql, $params);
        if ($rs->valid()) {
            foreach ($rs as $entry) {
                if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted
                  or !is_enrolled($course_context , $entry->userid)) {
                    $DB->delete_records('comments', array('commentarea'=>'glossary_entry', 'itemid'=>$entry->id));
                    $DB->delete_records('glossary_entries', array('id'=>$entry->id));

                    if ($cm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
                        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                        $fs->delete_area_files($context->id, 'mod_glossary', 'attachment', $entry->id);

                        //delete ratings
                        $ratingdeloptions->contextid = $context->id;
                        $rm->delete_ratings($ratingdeloptions);
                    }
                }
            }
            $status[] = array('component'=>$componentstr, 'item'=>get_string('deletenotenrolled', 'glossary'), 'error'=>false);
        }
        $rs->close();
    }

    // remove all ratings
    if (!empty($data->reset_glossary_ratings)) {
        //remove ratings
        if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
            foreach ($glossaries as $glossaryid=>$unused) {
                if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
                    continue;
                }
                $context = get_context_instance(CONTEXT_MODULE, $cm->id);

                //delete ratings
                $ratingdeloptions->contextid = $context->id;
                $rm->delete_ratings($ratingdeloptions);
            }
        }

        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            glossary_reset_gradebook($data->courseid);
        }
        $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallratings'), 'error'=>false);
    }

    // remove comments
    if (!empty($data->reset_glossary_comments)) {
        $params[] = 'glossary_entry';
        $DB->delete_records_select('comments', "itemid IN ($allentriessql) AND commentarea= ? ", $params);
        $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallcomments'), 'error'=>false);
    }

    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('glossary', array('assesstimestart', 'assesstimefinish'), $data->timeshift, $data->courseid);
        $status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged'), 'error'=>false);
    }

    return $status;
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:101,代码来源:lib.php

示例14: simplecertificate_reset_userdata

/**
 * This function is used by the reset_course_userdata function in moodlelib.
 * This function will remove all posts from the specified certificate
 * and clean up any related data.
 * Written by Jean-Michel Vedrine
 * 
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function simplecertificate_reset_userdata($data)
{
    global $CFG, $DB;
    $componentstr = get_string('modulenameplural', 'simplecertificate');
    $status = array();
    if (!empty($data->reset_certificate)) {
        $timedeleted = time();
        $certificates = $DB->get_records('simplecertificate', array('course' => $data->courseid));
        foreach ($certificates as $certificate) {
            $issuecertificates = $DB->get_records('simplecertificate_issues', array('certificateid' => $certificate->id, 'timedeleted' => null));
            foreach ($issuecertificates as $issuecertificate) {
                $issuecertificate->timedeleted = $timedeleted;
                if (!$DB->update_record('simplecertificate_issues', $issuecertificate)) {
                    print_error(get_string('cantdeleteissue', 'simplecertificate'));
                }
            }
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('modulenameplural', 'simplecertificate'), 'error' => false);
    }
    // Updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('simplecertificate', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
    }
    return $status;
}
开发者ID:v--k,项目名称:moodle-mod_simplecertificate,代码行数:35,代码来源:lib.php

示例15: quiz_reset_userdata

/**
 * Actual implementation of the rest coures functionality, delete all the
 * quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is
 * set and true.
 *
 * Also, move the quiz open and close dates, if the course start date is changing.
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function quiz_reset_userdata($data)
{
    global $CFG, $QTYPES;
    // TODO: this should use the delete_attempt($attempt->uniqueid) function in questionlib.php
    // require_once($CFG->libdir.'/questionlib.php');
    $componentstr = get_string('modulenameplural', 'quiz');
    $status = array();
    /// Delete attempts.
    if (!empty($data->reset_quiz_attempts)) {
        $stateslistsql = "SELECT s.id\n                            FROM {$CFG->prefix}question_states s\n                                 INNER JOIN {$CFG->prefix}quiz_attempts qza ON s.attempt=qza.uniqueid\n                                 INNER JOIN {$CFG->prefix}quiz q ON qza.quiz=q.id\n                           WHERE q.course={$data->courseid}";
        $attemptssql = "SELECT a.uniqueid\n                            FROM {$CFG->prefix}quiz_attempts a, {$CFG->prefix}quiz q\n                           WHERE q.course={$data->courseid} AND a.quiz=q.id";
        $quizessql = "SELECT q.id\n                            FROM {$CFG->prefix}quiz q\n                           WHERE q.course={$data->courseid}";
        if ($states = get_records_sql($stateslistsql)) {
            //TODO: not sure if this works
            $stateslist = implode(',', array_keys($states));
            foreach ($QTYPES as $qtype) {
                $qtype->delete_states($stateslist);
            }
        }
        delete_records_select('question_states', "attempt IN ({$attemptssql})");
        delete_records_select('question_sessions', "attemptid IN ({$attemptssql})");
        delete_records_select('question_attempts', "id IN ({$attemptssql})");
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            quiz_reset_gradebook($data->courseid);
        }
        delete_records_select('quiz_grades', "quiz IN ({$quizessql})");
        $status[] = array('component' => $componentstr, 'item' => get_string('gradesdeleted', 'quiz'), 'error' => false);
        delete_records_select('quiz_attempts', "quiz IN ({$quizessql})");
        $status[] = array('component' => $componentstr, 'item' => get_string('attemptsdeleted', 'quiz'), 'error' => false);
    }
    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('quiz', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('openclosedatesupdated', 'quiz'), 'error' => false);
    }
    return $status;
}
开发者ID:e-rasvet,项目名称:reader,代码行数:47,代码来源:lib.php


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