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


PHP assign::update_calendar方法代码示例

本文整理汇总了PHP中assign::update_calendar方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::update_calendar方法的具体用法?PHP assign::update_calendar怎么用?PHP assign::update_calendar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在assign的用法示例。


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

示例1: save_dates

 public function save_dates(cm_info $cm, array $dates)
 {
     global $DB, $COURSE;
     $update = new stdClass();
     $update->id = $cm->instance;
     $update->duedate = $dates['duedate'];
     $update->allowsubmissionsfromdate = $dates['allowsubmissionsfromdate'];
     $update->cutoffdate = $dates['cutoffdate'];
     $result = $DB->update_record('assign', $update);
     $module = new assign(context_module::instance($cm->id), null, null);
     // Update the calendar and grades.
     $module->update_calendar($cm->id);
     $module->update_gradebook(false, $cm->id);
 }
开发者ID:merrill-oakland,项目名称:moodle-report_editdates,代码行数:14,代码来源:assigndates.php

示例2: cron


//.........这里部分代码省略.........
         // Filter out duplicates.
         $courseids = array_unique($courseids);
         $ctxselect = context_helper::get_preload_record_columns_sql('ctx');
         list($courseidsql, $params) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
         $sql = 'SELECT c.*, ' . $ctxselect . ' FROM {course} c
              LEFT JOIN {context} ctx ON ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel
                  WHERE c.id ' . $courseidsql;
         $params['contextlevel'] = CONTEXT_COURSE;
         $courses = $DB->get_records_sql($sql, $params);
         // Clean up... this could go on for a while.
         unset($courseids);
         unset($ctxselect);
         unset($courseidsql);
         unset($params);
         // Message students about new feedback.
         foreach ($submissions as $submission) {
             mtrace("Processing assignment submission {$submission->id} ...");
             // Do not cache user lookups - could be too many.
             if (!($user = $DB->get_record('user', array('id' => $submission->userid)))) {
                 mtrace('Could not find user ' . $submission->userid);
                 continue;
             }
             // Use a cache to prevent the same DB queries happening over and over.
             if (!array_key_exists($submission->course, $courses)) {
                 mtrace('Could not find course ' . $submission->course);
                 continue;
             }
             $course = $courses[$submission->course];
             if (isset($course->ctxid)) {
                 // Context has not yet been preloaded. Do so now.
                 context_helper::preload_from_record($course);
             }
             // Override the language and timezone of the "current" user, so that
             // mail is customised for the receiver.
             cron_setup_user($user, $course);
             // Context lookups are already cached.
             $coursecontext = context_course::instance($course->id);
             if (!is_enrolled($coursecontext, $user->id)) {
                 $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
                 mtrace(fullname($user) . ' not an active participant in ' . $courseshortname);
                 continue;
             }
             if (!($grader = $DB->get_record('user', array('id' => $submission->grader)))) {
                 mtrace('Could not find grader ' . $submission->grader);
                 continue;
             }
             $modinfo = get_fast_modinfo($course, $user->id);
             $cm = $modinfo->get_cm($submission->cmid);
             // Context lookups are already cached.
             $contextmodule = context_module::instance($cm->id);
             if (!$cm->uservisible) {
                 // Hold mail notification for assignments the user cannot access until later.
                 continue;
             }
             // Need to send this to the student.
             $messagetype = 'feedbackavailable';
             $eventtype = 'assign_notification';
             $updatetime = $submission->lastmodified;
             $modulename = get_string('modulename', 'assign');
             $uniqueid = 0;
             if ($submission->blindmarking && !$submission->revealidentities) {
                 $uniqueid = self::get_uniqueid_for_user_static($submission->assignment, $user->id);
             }
             $showusers = $submission->blindmarking && !$submission->revealidentities;
             self::send_assignment_notification($grader, $user, $messagetype, $eventtype, $updatetime, $cm, $contextmodule, $course, $modulename, $submission->name, $showusers, $uniqueid);
             $flags = $DB->get_record('assign_user_flags', array('userid' => $user->id, 'assignment' => $submission->assignment));
             if ($flags) {
                 $flags->mailed = 1;
                 $DB->update_record('assign_user_flags', $flags);
             } else {
                 $flags = new stdClass();
                 $flags->userid = $user->id;
                 $flags->assignment = $submission->assignment;
                 $flags->mailed = 1;
                 $DB->insert_record('assign_user_flags', $flags);
             }
             mtrace('Done');
         }
         mtrace('Done processing ' . count($submissions) . ' assignment submissions');
         cron_setup_user();
         // Free up memory just to be sure.
         unset($courses);
     }
     // Update calendar events to provide a description.
     $sql = 'SELECT id
                 FROM {assign}
                 WHERE
                     allowsubmissionsfromdate >= :lastcron AND
                     allowsubmissionsfromdate <= :timenow AND
                     alwaysshowdescription = 0';
     $params = array('lastcron' => $lastcron, 'timenow' => $timenow);
     $newlyavailable = $DB->get_records_sql($sql, $params);
     foreach ($newlyavailable as $record) {
         $cm = get_coursemodule_from_instance('assign', $record->id, 0, false, MUST_EXIST);
         $context = context_module::instance($cm->id);
         $assignment = new assign($context, null, null);
         $assignment->update_calendar($cm->id);
     }
     return true;
 }
开发者ID:mercysmart,项目名称:naikelas,代码行数:101,代码来源:locallib.php

示例3: assign_refresh_events

/**
 * This standard function will check all instances of this module
 * and make sure there are up-to-date events created for each of them.
 * If courseid = 0, then every assignment event in the site is checked, else
 * only assignment events belonging to the course specified are checked.
 *
 * @param int $courseid
 * @return bool
 */
function assign_refresh_events($courseid = 0)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/mod/assign/locallib.php';
    if ($courseid) {
        // Make sure that the course id is numeric.
        if (!is_numeric($courseid)) {
            return false;
        }
        if (!($assigns = $DB->get_records('assign', array('course' => $courseid)))) {
            return false;
        }
        // Get course from courseid parameter.
        if (!($course = $DB->get_record('course', array('id' => $courseid), '*'))) {
            return false;
        }
    } else {
        if (!($assigns = $DB->get_records('assign'))) {
            return false;
        }
    }
    foreach ($assigns as $assign) {
        // Use assignment's course column if courseid parameter is not given.
        if (!$courseid) {
            $courseid = $assign->course;
            if (!($course = $DB->get_record('course', array('id' => $courseid), '*'))) {
                continue;
            }
        }
        if (!($cm = get_coursemodule_from_instance('assign', $assign->id, $courseid, false))) {
            continue;
        }
        $context = context_module::instance($cm->id);
        $assignment = new assign($context, $cm, $course);
        $assignment->update_calendar($cm->id);
    }
    return true;
}
开发者ID:dg711,项目名称:moodle,代码行数:47,代码来源:lib.php

示例4: upgrade_assignment


//.........这里部分代码省略.........
                 // Submission has been graded - create a grade record.
                 $grade = new stdClass();
                 $grade->assignment = $newassignment->get_instance()->id;
                 $grade->userid = $oldsubmission->userid;
                 $grade->grader = $oldsubmission->teacher;
                 $grade->timemodified = $oldsubmission->timemarked;
                 $grade->timecreated = $oldsubmission->timecreated;
                 $grade->grade = $oldsubmission->grade;
                 if ($oldsubmission->mailed) {
                     // The mailed flag goes in the flags table.
                     $flags = new stdClass();
                     $flags->userid = $oldsubmission->userid;
                     $flags->assignment = $newassignment->get_instance()->id;
                     $flags->mailed = 1;
                     $DB->insert_record('assign_user_flags', $flags);
                 }
                 $grade->id = $DB->insert_record('assign_grades', $grade);
                 if (!$grade->id) {
                     $log .= get_string('couldnotinsertgrade', 'mod_assign', $grade->userid);
                     $rollback = true;
                 }
                 // Copy any grading instances.
                 if ($gradingarea) {
                     $gradeidmap[$grade->id] = $oldsubmission->id;
                     foreach ($gradingdefinitions as $definition) {
                         $params = array('definitionid' => $definition->id, 'itemid' => $oldsubmission->id);
                         $DB->set_field('grading_instances', 'itemid', $grade->id, $params);
                     }
                 }
                 foreach ($newassignment->get_feedback_plugins() as $plugin) {
                     if ($plugin->can_upgrade($oldassignment->assignmenttype, $oldversion)) {
                         if (!$plugin->upgrade($oldcontext, $oldassignment, $oldsubmission, $grade, $log)) {
                             $rollback = true;
                         }
                     }
                 }
             }
         }
         $newassignment->update_calendar($newcoursemodule->id);
         // Reassociate grade_items from the old assignment instance to the new assign instance.
         // This includes outcome linked grade_items.
         $params = array('assign', $newassignment->get_instance()->id, 'assignment', $oldassignment->id);
         $sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
         $DB->execute($sql, $params);
         // Create a mapping record to map urls from the old to the new assignment.
         $mapping = new stdClass();
         $mapping->oldcmid = $oldcoursemodule->id;
         $mapping->oldinstance = $oldassignment->id;
         $mapping->newcmid = $newcoursemodule->id;
         $mapping->newinstance = $newassignment->get_instance()->id;
         $mapping->timecreated = time();
         $DB->insert_record('assignment_upgrade', $mapping);
         $gradesdone = true;
     } catch (Exception $exception) {
         $rollback = true;
         $log .= get_string('conversionexception', 'mod_assign', $exception->getMessage());
     }
     if ($rollback) {
         // Roll back the grades changes.
         if ($gradesdone) {
             // Reassociate grade_items from the new assign instance to the old assignment instance.
             $params = array('assignment', $oldassignment->id, 'assign', $newassignment->get_instance()->id);
             $sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
             $DB->execute($sql, $params);
         }
         // Roll back the completion changes.
         if ($completiondone) {
             $DB->set_field('course_modules_completion', 'coursemoduleid', $oldcoursemodule->id, array('coursemoduleid' => $newcoursemodule->id));
             $allcriteria = $DB->get_records('course_completion_criteria', array('moduleinstance' => $newcoursemodule->id));
             foreach ($allcriteria as $criteria) {
                 $criteria->module = 'assignment';
                 $criteria->moduleinstance = $oldcoursemodule->id;
                 $DB->update_record('course_completion_criteria', $criteria);
             }
         }
         // Roll back the log changes.
         $logparams = array('cmid' => $newcoursemodule->id, 'course' => $newcoursemodule->course);
         $DB->set_field('log', 'module', 'assignment', $logparams);
         $DB->set_field('log', 'cmid', $oldcoursemodule->id, $logparams);
         // Roll back the advanced grading update.
         if ($gradingarea) {
             foreach ($gradeidmap as $newgradeid => $oldsubmissionid) {
                 foreach ($gradingdefinitions as $definition) {
                     $DB->set_field('grading_instances', 'itemid', $oldsubmissionid, array('definitionid' => $definition->id, 'itemid' => $newgradeid));
                 }
             }
             $params = array('id' => $gradingarea->id, 'contextid' => $oldcontext->id, 'component' => 'mod_assignment', 'areaname' => 'submission');
             $DB->update_record('grading_areas', $params);
         }
         $newassignment->delete_instance();
         return false;
     }
     // Delete the old assignment (use object delete).
     $cm = get_coursemodule_from_id('', $oldcoursemodule->id, $oldcoursemodule->course);
     if ($cm) {
         course_delete_module($cm->id);
     }
     rebuild_course_cache($oldcoursemodule->course);
     return true;
 }
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:101,代码来源:upgradelib.php

示例5: upgrade_assignment


//.........这里部分代码省略.........
             $submission->timemodified = $oldsubmission->timemodified;
             $submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
             $submission->id = $DB->insert_record('assign_submission', $submission);
             if (!$submission->id) {
                 $log .= get_string('couldnotinsertsubmission', 'mod_assign', $submission->userid);
                 $rollback = true;
             }
             foreach ($newassignment->get_submission_plugins() as $plugin) {
                 if ($plugin->can_upgrade($oldassignment->assignmenttype, $oldversion)) {
                     if (!$plugin->upgrade($oldcontext, $oldassignment, $oldsubmission, $submission, $log)) {
                         $rollback = true;
                     }
                 }
             }
             if ($oldsubmission->timemarked) {
                 // submission has been graded - create a grade record
                 $grade = new stdClass();
                 $grade->assignment = $newassignment->get_instance()->id;
                 $grade->userid = $oldsubmission->userid;
                 $grade->grader = $oldsubmission->teacher;
                 $grade->timemodified = $oldsubmission->timemarked;
                 $grade->timecreated = $oldsubmission->timecreated;
                 // $grade->locked = $oldsubmission->locked;
                 $grade->grade = $oldsubmission->grade;
                 $grade->mailed = $oldsubmission->mailed;
                 $grade->id = $DB->insert_record('assign_grades', $grade);
                 if (!$grade->id) {
                     $log .= get_string('couldnotinsertgrade', 'mod_assign', $grade->userid);
                     $rollback = true;
                 }
                 // copy any grading instances
                 if ($gradingarea) {
                     $gradeidmap[$grade->id] = $oldsubmission->id;
                     foreach ($gradingdefinitions as $definition) {
                         $DB->set_field('grading_instances', 'itemid', $grade->id, array('definitionid' => $definition->id, 'itemid' => $oldsubmission->id));
                     }
                 }
                 foreach ($newassignment->get_feedback_plugins() as $plugin) {
                     if ($plugin->can_upgrade($oldassignment->assignmenttype, $oldversion)) {
                         if (!$plugin->upgrade($oldcontext, $oldassignment, $oldsubmission, $grade, $log)) {
                             $rollback = true;
                         }
                     }
                 }
             }
         }
         $newassignment->update_calendar($newcoursemodule->id);
         // Reassociate grade_items from the old assignment instance to the new assign instance.
         // This includes outcome linked grade_items.
         $params = array('assign', $newassignment->get_instance()->id, 'assignment', $oldassignment->id);
         $sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
         $DB->execute($sql, $params);
         $gradesdone = true;
     } catch (Exception $exception) {
         $rollback = true;
         $log .= get_string('conversionexception', 'mod_assign', $exception->error);
     }
     if ($rollback) {
         // roll back the grades changes
         if ($gradesdone) {
             // Reassociate grade_items from the new assign instance to the old assignment instance.
             $params = array('assignment', $oldassignment->id, 'assign', $newassignment->get_instance()->id);
             $sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
             $DB->execute($sql, $params);
         }
         // roll back the completion changes
         if ($completiondone) {
             $DB->set_field('course_modules_completion', 'coursemoduleid', $oldcoursemodule->id, array('coursemoduleid' => $newcoursemodule->id));
             $allcriteria = $DB->get_records('course_completion_criteria', array('moduleinstance' => $newcoursemodule->id));
             foreach ($allcriteria as $criteria) {
                 $criteria->module = 'assignment';
                 $criteria->moduleinstance = $oldcoursemodule->id;
                 $DB->update_record('course_completion_criteria', $criteria);
             }
         }
         // Roll back the log changes
         $logparams = array('cmid' => $newcoursemodule->id, 'course' => $newcoursemodule->course);
         $DB->set_field('log', 'module', 'assignment', $logparams);
         $DB->set_field('log', 'cmid', $oldcoursemodule->id, $logparams);
         // roll back the advanced grading update
         if ($gradingarea) {
             foreach ($gradeidmap as $newgradeid => $oldsubmissionid) {
                 foreach ($gradingdefinitions as $definition) {
                     $DB->set_field('grading_instances', 'itemid', $oldsubmissionid, array('definitionid' => $definition->id, 'itemid' => $newgradeid));
                 }
             }
             $DB->update_record('grading_areas', array('id' => $gradingarea->id, 'contextid' => $oldcontext->id, 'component' => 'mod_assignment', 'areaname' => 'submission'));
         }
         $newassignment->delete_instance();
         return false;
     }
     // all is well,
     // delete the old assignment (use object delete)
     $cm = get_coursemodule_from_id('', $oldcoursemodule->id, $oldcoursemodule->course);
     if ($cm) {
         $this->delete_course_module($cm);
     }
     rebuild_course_cache($oldcoursemodule->course);
     return true;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:upgradelib.php


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