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


PHP student::can_manage_assoc方法代码示例

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


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

示例1: can_do_edit

 function can_do_edit()
 {
     $association_id = 0;
     if (!empty($this->params['association_id'])) {
         $association_id = $this->params['association_id'];
     } else {
         $association_id = $this->optional_param('association_id', '', PARAM_INT);
     }
     $student = new student($association_id);
     return student::can_manage_assoc($student->userid, $student->classid);
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:11,代码来源:studentpage.class.php

示例2: attempt_enrolment

 /**
  * Attempt initial enrolment.
  *
  * This performs an initial attempt at enroling the selected users. This has not yet taken into account the enrolment limit
  * or permissions.
  *
  * @param array $elements An array of elements to perform the action on.
  * @param int $classid The ID of the class we're enrolling into.
  * @param string $enroldata A JSON string containing enrolment data for the users we want to overenrol.
  * @param bool $bulkaction Whether this attempt is a bulk action or not.
  * @return array An array consisting of "result", and optionally "users" and "total", explained below:
  *                   result: Will be "success" if all users were enrolled successfully, or "waitlist", if we have users that
  *                           need to be waitlisted.
  *                   users:  If some users need enrolment limit resolution, this will be present.
  *                           This will either contain an array of arrays like array('userid' => $userid, 'name' => $label),
  *                           or the string 'bulklist', if we're performing a bulk action.
  *                   total:  If we're performing a bulk action, and some users need enrolment limit resolution, this will be
  *                           included, indicating the number of users needed resolution.
  */
 protected function attempt_enrolment($elements, $classid, $enroldata, $bulkaction)
 {
     set_time_limit(0);
     // Enrolment data.
     $enroldata = $this->process_enrolment_data($classid, @json_decode($enroldata));
     if (empty($enroldata)) {
         throw new Exception('Did not receive valid enrolment data.');
     }
     // Attempt enrolment.
     $waitlist = array();
     foreach ($elements as $userid => $label) {
         // Skip invalid userids or users which we dont have permission to modify.
         if (!is_numeric($userid) || !student::can_manage_assoc($userid, $classid)) {
             continue;
         }
         // Build student.
         $sturecord = $enroldata;
         $sturecord['userid'] = $userid;
         $newstu = new student($sturecord);
         $newstu->validation_overrides[] = 'prerequisites';
         if ($newstu->completestatusid != STUSTATUS_NOTCOMPLETE) {
             // User is set to completed, so don't worry about enrolment limit.
             $newstu->validation_overrides[] = 'enrolment_limit';
         }
         // Attempt enrolment.
         try {
             $newstu->save();
             unset($elements[$userid]);
             $this->datatable->bulklist_modify(array(), array($userid));
         } catch (pmclass_enrolment_limit_validation_exception $e) {
             $waitlist[] = array('userid' => $userid, 'name' => $label);
         } catch (Exception $e) {
             $param = array('message' => $e->getMessage());
             throw new Exception(get_string('record_not_created_reason', 'local_elisprogram', $param));
         }
     }
     if ($bulkaction === true) {
         if (!empty($waitlist)) {
             list($bulklistdisplay, $totalusers) = $this->datatable->bulklist_get_display(1);
             return array('result' => 'waitlist', 'users' => 'bulklist', 'total' => $totalusers);
         } else {
             return array('result' => 'success');
         }
     } else {
         return !empty($waitlist) ? array('result' => 'waitlist', 'users' => $waitlist) : array('result' => 'success');
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:66,代码来源:enrol.action.php

示例3: do_update

 /**
  * Perform an update for a single user/class pair.
  *
  * @param int $userid The user ID we're updating.
  * @param int $classid The class ID we're updating information for.
  * @param array $enroldata The updated enrolment data.
  * @param array $learningobjectives The updated learning objective data.
  */
 protected function do_update($userid, $classid, array $enroldata, array $learningobjectives)
 {
     global $DB;
     if (student::can_manage_assoc($userid, $classid) !== true) {
         throw new Exception('Unauthorized');
     }
     if (!isset($enroldata['id'])) {
         $associationid = $DB->get_field(student::TABLE, 'id', array('classid' => $classid, 'userid' => $userid));
         if (empty($associationid)) {
             return false;
         } else {
             $enroldata['id'] = $associationid;
         }
     }
     $enroldata['userid'] = $userid;
     $stu = new student($enroldata);
     if ($stu->completestatusid == STUSTATUS_PASSED && $DB->get_field(student::TABLE, 'completestatusid', array('id' => $stu->id)) != STUSTATUS_PASSED) {
         $stu->complete();
     } else {
         $status = $stu->save();
     }
     foreach ($learningobjectives as $id => $data) {
         $graderec = array('userid' => $userid, 'classid' => $classid, 'completionid' => $id);
         $existingrec = $DB->get_record(student_grade::TABLE, $graderec);
         if (!empty($existingrec)) {
             $graderec = (array) $existingrec;
         }
         $graderec['timegraded'] = $data['timegraded'];
         $graderec['grade'] = $data['grade'];
         $graderec['locked'] = $data['locked'];
         $sgrade = new student_grade($graderec);
         $sgrade->save();
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:42,代码来源:enroledit.action.php


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