예제 #1
0
 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     $data = new stdClass();
     $planstoreview = array();
     foreach ($this->planstoreview['plans'] as $plandata) {
         $planexporter = new plan_exporter($plandata->plan, array('template' => $plandata->template));
         $userexporter = new user_summary_exporter($plandata->owner);
         $planstoreview[] = array('plan' => $planexporter->export($output), 'user' => $userexporter->export($output));
     }
     $data = array('plans' => $planstoreview, 'pluginbaseurl' => (new moodle_url('/blocks/lp'))->out(false));
     return $data;
 }
 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     $data = new stdClass();
     $compstoreview = array();
     foreach ($this->compstoreview['competencies'] as $compdata) {
         $ucexporter = new user_competency_exporter($compdata->usercompetency, array('scale' => $compdata->competency->get_scale()));
         $compexporter = new competency_exporter($compdata->competency, array('context' => $compdata->competency->get_context()));
         $userexporter = new user_summary_exporter($compdata->user);
         $compstoreview[] = array('usercompetency' => $ucexporter->export($output), 'competency' => $compexporter->export($output), 'user' => $userexporter->export($output));
     }
     $data = array('competencies' => $compstoreview, 'pluginbaseurl' => (new moodle_url('/blocks/lp'))->out(false));
     return $data;
 }
예제 #3
0
파일: external.php 프로젝트: evltuma/moodle
 /**
  * Returns description of data_for_report() result value.
  *
  * @return \external_description
  */
 public static function data_for_report_returns()
 {
     return new external_single_structure(array('courseid' => new external_value(PARAM_INT, 'Course id'), 'user' => user_summary_exporter::get_read_structure(), 'course' => course_summary_exporter::get_read_structure(), 'usercompetencies' => new external_multiple_structure(new external_single_structure(array('usercompetencycourse' => user_competency_course_exporter::get_read_structure(), 'competency' => competency_summary_exporter::get_read_structure()))), 'pushratingstouserplans' => new external_value(PARAM_BOOL, 'True if rating is push to user plans')));
 }
예제 #4
0
 protected static function define_other_properties()
 {
     return array('canrequestreview' => array('type' => PARAM_BOOL), 'canreview' => array('type' => PARAM_BOOL), 'gradename' => array('type' => PARAM_TEXT), 'isrequestreviewallowed' => array('type' => PARAM_BOOL), 'iscancelreviewrequestallowed' => array('type' => PARAM_BOOL), 'isstartreviewallowed' => array('type' => PARAM_BOOL), 'isstopreviewallowed' => array('type' => PARAM_BOOL), 'isstatusidle' => array('type' => PARAM_BOOL), 'isstatusinreview' => array('type' => PARAM_BOOL), 'isstatuswaitingforreview' => array('type' => PARAM_BOOL), 'proficiencyname' => array('type' => PARAM_RAW), 'reviewer' => array('type' => user_summary_exporter::read_properties_definition(), 'optional' => true), 'statusname' => array('type' => PARAM_RAW), 'url' => array('type' => PARAM_URL));
 }
예제 #5
0
 public static function define_other_properties()
 {
     return array('statusname' => array('type' => PARAM_RAW), 'isbasedontemplate' => array('type' => PARAM_BOOL), 'canmanage' => array('type' => PARAM_BOOL), 'canrequestreview' => array('type' => PARAM_BOOL), 'canreview' => array('type' => PARAM_BOOL), 'canbeedited' => array('type' => PARAM_BOOL), 'isactive' => array('type' => PARAM_BOOL), 'isdraft' => array('type' => PARAM_BOOL), 'iscompleted' => array('type' => PARAM_BOOL), 'isinreview' => array('type' => PARAM_BOOL), 'iswaitingforreview' => array('type' => PARAM_BOOL), 'isreopenallowed' => array('type' => PARAM_BOOL), 'iscompleteallowed' => array('type' => PARAM_BOOL), 'isunlinkallowed' => array('type' => PARAM_BOOL), 'isrequestreviewallowed' => array('type' => PARAM_BOOL), 'iscancelreviewrequestallowed' => array('type' => PARAM_BOOL), 'isstartreviewallowed' => array('type' => PARAM_BOOL), 'isstopreviewallowed' => array('type' => PARAM_BOOL), 'isapproveallowed' => array('type' => PARAM_BOOL), 'isunapproveallowed' => array('type' => PARAM_BOOL), 'duedateformatted' => array('type' => PARAM_TEXT), 'commentarea' => array('type' => comment_area_exporter::read_properties_definition()), 'reviewer' => array('type' => user_summary_exporter::read_properties_definition(), 'optional' => true), 'template' => array('type' => template_exporter::read_properties_definition(), 'optional' => true), 'url' => array('type' => PARAM_URL));
 }
예제 #6
0
 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     global $CFG, $DB, $SESSION, $PAGE;
     $context = context_course::instance($this->courseid);
     $data = new stdClass();
     $data->userid = $this->userid;
     $data->courseid = $this->courseid;
     $data->baseurl = $this->baseurl;
     $data->groupselector = '';
     if (has_any_capability(array('moodle/competency:usercompetencyview', 'moodle/competency:coursecompetencymanage'), $context)) {
         $course = $DB->get_record('course', array('id' => $this->courseid));
         $currentgroup = groups_get_course_group($course, true);
         if ($currentgroup !== false) {
             $select = groups_allgroups_course_menu($course, $PAGE->url, true, $currentgroup);
             $data->groupselector = $select;
         }
         // Fetch showactive.
         $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
         $showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
         $showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
         // Fetch current active group.
         $groupmode = groups_get_course_groupmode($course);
         $users = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.*', null, 0, 0, $showonlyactiveenrol);
         $data->users = array();
         foreach ($users as $user) {
             $exporter = new user_summary_exporter($user);
             $user = $exporter->export($output);
             if ($user->id == $this->userid) {
                 $user->selected = true;
             }
             $data->users[] = $user;
         }
         $data->hasusers = true;
     } else {
         $data->users = array();
         $data->hasusers = false;
     }
     return $data;
 }
 protected function get_other_values(renderer_base $output)
 {
     global $DB;
     $result = new stdClass();
     $result->showrelatedcompetencies = true;
     $competency = $this->related['competency'];
     $exporter = new competency_summary_exporter(null, array('competency' => $competency, 'context' => $competency->get_context(), 'framework' => $competency->get_framework(), 'linkedcourses' => array(), 'relatedcompetencies' => $this->related['relatedcompetencies']));
     $result->competency = $exporter->export($output);
     $result->cangrade = user_competency::can_grade_user($this->related['user']->id);
     if ($this->related['user']) {
         $exporter = new user_summary_exporter($this->related['user']);
         $result->user = $exporter->export($output);
     }
     $related = array('scale' => $competency->get_scale());
     if ($this->related['usercompetency']) {
         $exporter = new user_competency_exporter($this->related['usercompetency'], $related);
         $result->usercompetency = $exporter->export($output);
     }
     if ($this->related['usercompetencyplan']) {
         $exporter = new user_competency_plan_exporter($this->related['usercompetencyplan'], $related);
         $result->usercompetencyplan = $exporter->export($output);
     }
     if ($this->related['usercompetencycourse']) {
         $exporter = new user_competency_course_exporter($this->related['usercompetencycourse'], $related);
         $result->usercompetencycourse = $exporter->export($output);
     }
     $allevidence = array();
     $usercache = array();
     $scale = $competency->get_scale();
     $result->evidence = array();
     if (count($this->related['evidence'])) {
         foreach ($this->related['evidence'] as $evidence) {
             $actionuserid = $evidence->get_actionuserid();
             if (!empty($actionuserid)) {
                 $usercache[$evidence->get_actionuserid()] = true;
             }
         }
         $users = array();
         if (!empty($usercache)) {
             list($sql, $params) = $DB->get_in_or_equal(array_keys($usercache));
             $users = $DB->get_records_select('user', 'id ' . $sql, $params);
         }
         foreach ($users as $user) {
             $usercache[$user->id] = $user;
         }
         foreach ($this->related['evidence'] as $evidence) {
             $actionuserid = $evidence->get_actionuserid();
             $related = array('scale' => $scale, 'usercompetency' => $this->related['usercompetency'] ? $this->related['usercompetency'] : null, 'usercompetencyplan' => $this->related['usercompetencyplan'] ? $this->related['usercompetencyplan'] : null);
             $related['actionuser'] = !empty($actionuserid) ? $usercache[$actionuserid] : null;
             $exporter = new evidence_exporter($evidence, $related);
             $allevidence[] = $exporter->export($output);
         }
         $result->evidence = $allevidence;
     }
     $usercompetency = !empty($this->related['usercompetency']) ? $this->related['usercompetency'] : null;
     if (!empty($usercompetency) && $usercompetency->can_read_comments()) {
         $commentareaexporter = new comment_area_exporter($usercompetency->get_comment_object());
         $result->commentarea = $commentareaexporter->export($output);
     }
     return (array) $result;
 }
예제 #8
0
파일: external.php 프로젝트: evltuma/moodle
 /**
  * Returns description of external function result value.
  *
  * @return external_description
  */
 public static function search_users_returns()
 {
     global $CFG;
     require_once $CFG->dirroot . '/user/externallib.php';
     return new external_single_structure(array('users' => new external_multiple_structure(user_summary_exporter::get_read_structure()), 'count' => new external_value(PARAM_INT, 'Total number of results.')));
 }
예제 #9
0
 public static function define_other_properties()
 {
     return array('actionuser' => array('type' => user_summary_exporter::read_properties_definition(), 'optional' => true), 'description' => array('type' => PARAM_TEXT), 'gradename' => array('type' => PARAM_TEXT), 'userdate' => array('type' => PARAM_TEXT), 'candelete' => array('type' => PARAM_BOOL));
 }
예제 #10
0
파일: summary.php 프로젝트: evltuma/moodle
 public function export_for_template(renderer_base $output)
 {
     $plans = array();
     foreach ($this->plans as $plan) {
         if (count($plans) >= 3) {
             break;
         }
         if ($plan->get_status() == plan::STATUS_ACTIVE) {
             $plans[] = $plan;
         }
     }
     $activeplans = array();
     foreach ($plans as $plan) {
         $planexporter = new plan_exporter($plan, array('template' => $plan->get_template()));
         $activeplans[] = $planexporter->export($output);
     }
     $compstoreview = array();
     foreach ($this->compstoreview['competencies'] as $compdata) {
         $ucexporter = new user_competency_exporter($compdata->usercompetency, array('scale' => $compdata->competency->get_scale()));
         $compexporter = new competency_exporter($compdata->competency, array('context' => $compdata->competency->get_context()));
         $userexporter = new user_summary_exporter($compdata->user);
         $compstoreview[] = array('usercompetency' => $ucexporter->export($output), 'competency' => $compexporter->export($output), 'user' => $userexporter->export($output));
     }
     $planstoreview = array();
     foreach ($this->planstoreview['plans'] as $plandata) {
         $planexporter = new plan_exporter($plandata->plan, array('template' => $plandata->template));
         $userexporter = new user_summary_exporter($plandata->owner);
         $planstoreview[] = array('plan' => $planexporter->export($output), 'user' => $userexporter->export($output));
     }
     $data = array('hasplans' => !empty($this->plans), 'hasactiveplans' => !empty($activeplans), 'hasmoreplans' => count($this->plans) > count($activeplans), 'activeplans' => $activeplans, 'compstoreview' => $compstoreview, 'hascompstoreview' => $this->compstoreview['count'] > 0, 'hasmorecompstoreview' => $this->compstoreview['count'] > 3, 'planstoreview' => $planstoreview, 'hasplanstoreview' => $this->planstoreview['count'] > 0, 'hasmoreplanstoreview' => $this->planstoreview['count'] > 3, 'plansurl' => url::plans($this->user->id)->out(false), 'pluginbaseurl' => (new \moodle_url('/blocks/lp'))->out(false), 'userid' => $this->user->id);
     return $data;
 }
예제 #11
0
파일: report.php 프로젝트: evltuma/moodle
 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param \renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     global $DB;
     $data = new stdClass();
     $data->courseid = $this->courseid;
     $course = $DB->get_record('course', array('id' => $this->courseid));
     $coursecontext = context_course::instance($course->id);
     $exporter = new course_summary_exporter($course, array('context' => $coursecontext));
     $coursecompetencysettings = api::read_course_competency_settings($course->id);
     $data->pushratingstouserplans = $coursecompetencysettings->get_pushratingstouserplans();
     $data->course = $exporter->export($output);
     $data->usercompetencies = array();
     $scalecache = array();
     $frameworkcache = array();
     $user = core_user::get_user($this->userid);
     $exporter = new user_summary_exporter($user);
     $data->user = $exporter->export($output);
     $data->usercompetencies = array();
     $coursecompetencies = api::list_course_competencies($this->courseid);
     $usercompetencycourses = api::list_user_competencies_in_course($this->courseid, $user->id);
     foreach ($usercompetencycourses as $usercompetencycourse) {
         $onerow = new stdClass();
         $competency = null;
         foreach ($coursecompetencies as $coursecompetency) {
             if ($coursecompetency['competency']->get_id() == $usercompetencycourse->get_competencyid()) {
                 $competency = $coursecompetency['competency'];
                 break;
             }
         }
         if (!$competency) {
             continue;
         }
         // Fetch the framework.
         if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
             $frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
         }
         $framework = $frameworkcache[$competency->get_competencyframeworkid()];
         // Fetch the scale.
         $scaleid = $competency->get_scaleid();
         if ($scaleid === null) {
             $scaleid = $framework->get_scaleid();
             if (!isset($scalecache[$scaleid])) {
                 $scalecache[$competency->get_scaleid()] = $framework->get_scale();
             }
         } else {
             if (!isset($scalecache[$scaleid])) {
                 $scalecache[$competency->get_scaleid()] = $competency->get_scale();
             }
         }
         $scale = $scalecache[$competency->get_scaleid()];
         $exporter = new user_competency_course_exporter($usercompetencycourse, array('scale' => $scale));
         $record = $exporter->export($output);
         $onerow->usercompetencycourse = $record;
         $exporter = new competency_summary_exporter(null, array('competency' => $competency, 'framework' => $framework, 'context' => $framework->get_context(), 'relatedcompetencies' => array(), 'linkedcourses' => array()));
         $onerow->competency = $exporter->export($output);
         array_push($data->usercompetencies, $onerow);
     }
     return $data;
 }