本文整理汇总了PHP中core_competency\api::add_evidence方法的典型用法代码示例。如果您正苦于以下问题:PHP api::add_evidence方法的具体用法?PHP api::add_evidence怎么用?PHP api::add_evidence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::add_evidence方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_list_evidence_in_course
public function test_list_evidence_in_course()
{
global $SITE;
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency');
$u1 = $dg->create_user();
$course = $dg->create_course();
$coursecontext = context_course::instance($course->id);
$this->setAdminUser();
$f = $lpg->create_framework();
$c = $lpg->create_competency(array('competencyframeworkid' => $f->get_id()));
$c2 = $lpg->create_competency(array('competencyframeworkid' => $f->get_id()));
$cc = api::add_competency_to_course($course->id, $c->get_id());
$cc2 = api::add_competency_to_course($course->id, $c2->get_id());
$pagegenerator = $this->getDataGenerator()->get_plugin_generator('mod_page');
$page = $pagegenerator->create_instance(array('course' => $course->id));
$cm = get_coursemodule_from_instance('page', $page->id);
$cmcontext = context_module::instance($cm->id);
// Add the competency to the course module.
$ccm = api::add_competency_to_course_module($cm, $c->get_id());
// Now add the evidence to the course.
$evidence1 = api::add_evidence($u1->id, $c->get_id(), $coursecontext->id, \core_competency\evidence::ACTION_LOG, 'invaliddata', 'error');
$result = api::list_evidence_in_course($u1->id, $course->id, $c->get_id());
$this->assertEquals($result[0]->get_id(), $evidence1->get_id());
// Now add the evidence to the course module.
$evidence2 = api::add_evidence($u1->id, $c->get_id(), $cmcontext->id, \core_competency\evidence::ACTION_LOG, 'invaliddata', 'error');
$result = api::list_evidence_in_course($u1->id, $course->id, $c->get_id(), 'timecreated', 'ASC');
$this->assertEquals($evidence1->get_id(), $result[0]->get_id());
$this->assertEquals($evidence2->get_id(), $result[1]->get_id());
}
示例2: test_add_evidence_user_competency_course_grade_in_course
/**
* Tests for the user_competency_course data when api::add_evidence() is invoked when
* grading a user competency in a course.
*/
public function test_add_evidence_user_competency_course_grade_in_course()
{
global $USER;
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
// Create a course.
$course = $dg->create_course();
$record = array('courseid' => $course->id, 'pushratingstouserplans' => false);
$settings = new course_competency_settings(0, (object) $record);
$settings->create();
$coursecontext = context_course::instance($course->id);
// Create a student and enrol into the course.
$student = $dg->create_user();
$studentarch = get_archetype_roles('student');
$studentrole = array_shift($studentarch);
$dg->role_assign($studentrole->id, $student->id, $coursecontext->id);
$dg->enrol_user($student->id, $course->id, $studentrole->id);
// Create a competency for the course.
$lpg = $dg->get_plugin_generator('core_competency');
$framework = $lpg->create_framework();
// Do not push ratings from course to user plans.
$comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get_id()));
// Query for user_competency_course data.
$filterparams = array('userid' => $student->id, 'competencyid' => $comp->get_id(), 'courseid' => $course->id);
// Add evidence that sets a grade to the course.
$evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE, 'commentincontext', 'core', null, false, null, 3, $USER->id);
// Get user competency course record.
$usercompcourse = \core_competency\user_competency_course::get_record($filterparams);
// There should be a user_competency_course object when adding a grade.
$this->assertNotEmpty($usercompcourse);
$grade = $evidence->get_grade();
$this->assertEquals($grade, $usercompcourse->get_grade());
$this->assertEquals(3, $usercompcourse->get_grade());
$proficiency = $comp->get_proficiency_of_grade($grade);
$this->assertEquals($proficiency, $usercompcourse->get_proficiency());
// Confirm that the user competency's grade/proficiency has not been affected by the grade.
$usercompetencyparams = ['userid' => $student->id, 'competencyid' => $comp->get_id()];
$usercompetency = \core_competency\user_competency::get_record($usercompetencyparams);
$this->assertNotEmpty($usercompetency);
$this->assertNotEquals($usercompcourse->get_grade(), $usercompetency->get_grade());
$this->assertNotEquals($usercompcourse->get_proficiency(), $usercompetency->get_proficiency());
}
示例3: process_user_competency_course
/**
* Process the user competency course.
*
* @param array $data The data.
*/
public function process_user_competency_course($data)
{
global $USER, $DB;
$data = (object) $data;
$data->competencyid = $this->get_mappingid(\core_competency\competency::TABLE, $data->competencyid);
if (!$data->competencyid) {
// This is strange, the competency does not belong to the course.
return;
} else {
if ($data->grade === null) {
// We do not need to do anything when there is no grade.
return;
}
}
$data->userid = $this->get_mappingid('user', $data->userid);
$shortname = $DB->get_field('course', 'shortname', array('id' => $this->task->get_courseid()), MUST_EXIST);
// The method add_evidence also sets the course rating.
\core_competency\api::add_evidence($data->userid, $data->competencyid, $this->task->get_contextid(), \core_competency\evidence::ACTION_OVERRIDE, 'evidence_courserestored', 'core_competency', $shortname, false, null, $data->grade, $USER->id);
}
示例4: test_evidence_created_with_invalid_user_competency
/**
* Test evidence_created event by linking an invalid user competency to an evidence.
*
* @expectedException coding_exception
* @expectedExceptionMessage The user competency linked with this evidence is invalid.
*/
public function test_evidence_created_with_invalid_user_competency()
{
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$syscontext = context_system::instance();
// Create students.
$student = $dg->create_user();
$student2 = $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()]);
// Create a different user competency.
$otheruc = \core_competency\user_competency::create_relation($student2->id, $comp->get_id());
$otheruc->create();
// Add evidence.
$recommend = false;
$evidence = api::add_evidence($student->id, $comp, $syscontext, \core_competency\evidence::ACTION_OVERRIDE, 'commentincontext', 'core', null, $recommend, null, 1);
// We expect this to fail and throw a coding exception.
\core\event\competency_evidence_created::create_from_evidence($evidence, $otheruc, $recommend)->trigger();
}