protected function get_other_values(renderer_base $output)
 {
     $result = new stdClass();
     if ($this->persistent->get_grade() === null) {
         $gradename = '-';
     } else {
         $gradename = $this->related['scale']->scale_items[$this->persistent->get_grade() - 1];
     }
     $result->gradename = $gradename;
     if ($this->persistent->get_proficiency() === null) {
         $proficiencyname = get_string('no');
     } else {
         $proficiencyname = get_string($this->persistent->get_proficiency() ? 'yes' : 'no');
     }
     $result->proficiencyname = $proficiencyname;
     $statusname = '-';
     if ($this->persistent->get_status() != user_competency::STATUS_IDLE) {
         $statusname = (string) user_competency::get_status_name($this->persistent->get_status());
     }
     $result->statusname = $statusname;
     $result->canrequestreview = $this->persistent->can_request_review();
     $result->canreview = $this->persistent->can_review();
     $result->isstatusidle = $this->persistent->get_status() == user_competency::STATUS_IDLE;
     $result->isstatusinreview = $this->persistent->get_status() == user_competency::STATUS_IN_REVIEW;
     $result->isstatuswaitingforreview = $this->persistent->get_status() == user_competency::STATUS_WAITING_FOR_REVIEW;
     $result->isrequestreviewallowed = $result->canrequestreview && $result->isstatusidle;
     $result->iscancelreviewrequestallowed = $result->canrequestreview && $result->isstatuswaitingforreview;
     $result->isstartreviewallowed = $result->canreview && $result->isstatuswaitingforreview;
     $result->isstopreviewallowed = $result->canreview && $result->isstatusinreview;
     if (!empty($result->isstatusinreview)) {
         // TODO Make this more efficient.
         $userexporter = new user_summary_exporter(core_user::get_user($this->persistent->get_reviewerid(), '*', MUST_EXIST));
         $result->reviewer = $userexporter->export($output);
     }
     $result->url = url::user_competency($this->persistent->get_id())->out(false);
     return (array) $result;
 }
 /**
  * Get URL related to the action
  *
  * @return \moodle_url
  */
 public function get_url()
 {
     return \core_competency\url::user_competency($this->objectid);
 }
示例#3
0
 /**
  * Test evidence_created event.
  */
 public function test_evidence_created()
 {
     global $USER;
     $this->resetAfterTest(true);
     $dg = $this->getDataGenerator();
     $syscontext = context_system::instance();
     // Create a student.
     $student = $dg->create_user();
     // Create a competency for the course.
     $lpg = $dg->get_plugin_generator('core_competency');
     $framework = $lpg->create_framework();
     $comp = $lpg->create_competency(['competencyframeworkid' => $framework->get_id()]);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     // Add evidence.
     $recommend = false;
     $evidence = api::add_evidence($student->id, $comp, $syscontext, \core_competency\evidence::ACTION_OVERRIDE, 'commentincontext', 'core', null, $recommend, null, 1);
     // Get event.
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\competency_evidence_created', $event);
     $this->assertEquals($evidence->get_contextid(), $event->contextid);
     $this->assertEquals($evidence->get_id(), $event->objectid);
     $this->assertEquals($evidence->get_actionuserid(), $event->userid);
     $this->assertEquals($student->id, $event->relateduserid);
     $this->assertEquals($evidence->get_usercompetencyid(), $event->other['usercompetencyid']);
     $this->assertEquals($comp->get_id(), $event->other['competencyid']);
     $this->assertEquals($evidence->get_action(), $event->other['action']);
     $this->assertEquals($recommend, $event->other['recommend']);
     // Test get_name().
     $this->assertEquals(get_string('eventevidencecreated', 'core_competency'), $event->get_name());
     // Test get_description().
     $description = "The user with id '{$USER->id}' created an evidence with id '{$evidence->get_id()}'.";
     $this->assertEquals($description, $event->get_description());
     // Test get_url().
     $url = url::user_competency($evidence->get_usercompetencyid());
     $this->assertEquals($url, $event->get_url());
     // Test get_objectid_mapping().
     $this->assertEquals(\core\event\base::NOT_MAPPED, $event->get_objectid_mapping());
     $this->assertEventContextNotUsed($event);
     $this->assertDebuggingNotCalled();
 }
 /**
  * Returns relevant URL.
  *
  * @return \moodle_url
  */
 public function get_url()
 {
     return \core_competency\url::user_competency($this->other['usercompetencyid']);
 }