本文整理汇总了PHP中workshop::get_potential_authors方法的典型用法代码示例。如果您正苦于以下问题:PHP workshop::get_potential_authors方法的具体用法?PHP workshop::get_potential_authors怎么用?PHP workshop::get_potential_authors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类workshop
的用法示例。
在下文中一共展示了workshop::get_potential_authors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
//.........这里部分代码省略.........
}
if ($workshop->useselfassessment and $numofself) {
$task = new stdclass();
if ($numofselftodo == 0) {
$task->completed = true;
} elseif ($workshop->phase > workshop::PHASE_ASSESSMENT) {
$task->completed = false;
}
$task->title = get_string('taskassessself', 'workshop');
$phase->tasks['assessself'] = $task;
}
}
if ($workshop->assessmentstart) {
$task = new stdclass();
$task->title = get_string('assessmentstartdatetime', 'workshop', workshop::timestamp_formats($workshop->assessmentstart));
$task->completed = 'info';
$phase->tasks['assessmentstartdatetime'] = $task;
}
if ($workshop->assessmentend) {
$task = new stdclass();
$task->title = get_string('assessmentenddatetime', 'workshop', workshop::timestamp_formats($workshop->assessmentend));
$task->completed = 'info';
$phase->tasks['assessmentenddatetime'] = $task;
}
$this->phases[workshop::PHASE_ASSESSMENT] = $phase;
//---------------------------------------------------------
// setup | submission | assessment | * EVALUATION | closed
//---------------------------------------------------------
$phase = new stdclass();
$phase->title = get_string('phaseevaluation', 'workshop');
$phase->tasks = array();
if (has_capability('mod/workshop:overridegrades', $workshop->context)) {
$expected = count($workshop->get_potential_authors(false));
$calculated = $DB->count_records_select('workshop_submissions',
'workshopid = ? AND (grade IS NOT NULL OR gradeover IS NOT NULL)', array($workshop->id));
$task = new stdclass();
$task->title = get_string('calculatesubmissiongrades', 'workshop');
$a = new stdclass();
$a->expected = $expected;
$a->calculated = $calculated;
$task->details = get_string('calculatesubmissiongradesdetails', 'workshop', $a);
if ($calculated >= $expected) {
$task->completed = true;
} elseif ($workshop->phase > workshop::PHASE_EVALUATION) {
$task->completed = false;
}
$phase->tasks['calculatesubmissiongrade'] = $task;
$expected = count($workshop->get_potential_reviewers(false));
$calculated = $DB->count_records_select('workshop_aggregations',
'workshopid = ? AND gradinggrade IS NOT NULL', array($workshop->id));
$task = new stdclass();
$task->title = get_string('calculategradinggrades', 'workshop');
$a = new stdclass();
$a->expected = $expected;
$a->calculated = $calculated;
$task->details = get_string('calculategradinggradesdetails', 'workshop', $a);
if ($calculated >= $expected) {
$task->completed = true;
} elseif ($workshop->phase > workshop::PHASE_EVALUATION) {
$task->completed = false;
}
$phase->tasks['calculategradinggrade'] = $task;
} elseif ($workshop->phase == workshop::PHASE_EVALUATION) {
示例2: test_user_restrictions
/**
* Tests user restrictions, as they affect lists of users returned by
* core API functions.
*
* This includes the groupingid option (when group mode is in use), and
* standard activity restrictions using the availability API.
*/
public function test_user_restrictions()
{
global $DB, $CFG;
$this->resetAfterTest();
// Use existing sample course from setUp.
$courseid = $this->workshop->course->id;
// Make a test grouping and two groups.
$generator = $this->getDataGenerator();
$grouping = $generator->create_grouping(array('courseid' => $courseid));
$group1 = $generator->create_group(array('courseid' => $courseid));
groups_assign_grouping($grouping->id, $group1->id);
$group2 = $generator->create_group(array('courseid' => $courseid));
groups_assign_grouping($grouping->id, $group2->id);
// Group 3 is not in the grouping.
$group3 = $generator->create_group(array('courseid' => $courseid));
// Enrol some students.
$roleids = $DB->get_records_menu('role', null, '', 'shortname, id');
$student1 = $generator->create_user();
$student2 = $generator->create_user();
$student3 = $generator->create_user();
$generator->enrol_user($student1->id, $courseid, $roleids['student']);
$generator->enrol_user($student2->id, $courseid, $roleids['student']);
$generator->enrol_user($student3->id, $courseid, $roleids['student']);
// Place students in groups (except student 3).
groups_add_member($group1, $student1);
groups_add_member($group2, $student2);
groups_add_member($group3, $student3);
// The existing workshop doesn't have any restrictions, so user lists
// should include all three users.
$allusers = get_enrolled_users(context_course::instance($courseid));
$result = $this->workshop->get_grouped($allusers);
$this->assertCount(4, $result);
$users = array_keys($result[0]);
sort($users);
$this->assertEquals(array($student1->id, $student2->id, $student3->id), $users);
$this->assertEquals(array($student1->id), array_keys($result[$group1->id]));
$this->assertEquals(array($student2->id), array_keys($result[$group2->id]));
$this->assertEquals(array($student3->id), array_keys($result[$group3->id]));
// Test get_users_with_capability_sql (via get_potential_authors).
$users = $this->workshop->get_potential_authors(false);
$this->assertCount(3, $users);
$users = $this->workshop->get_potential_authors(false, $group2->id);
$this->assertEquals(array($student2->id), array_keys($users));
// Create another test workshop with grouping set.
$workshopitem = $this->getDataGenerator()->create_module('workshop', array('course' => $courseid, 'groupmode' => SEPARATEGROUPS, 'groupingid' => $grouping->id));
$cm = get_coursemodule_from_instance('workshop', $workshopitem->id, $courseid, false, MUST_EXIST);
$workshopgrouping = new testable_workshop($workshopitem, $cm, $this->workshop->course);
// This time the result should only include users and groups in the
// selected grouping.
$result = $workshopgrouping->get_grouped($allusers);
$this->assertCount(3, $result);
$users = array_keys($result[0]);
sort($users);
$this->assertEquals(array($student1->id, $student2->id), $users);
$this->assertEquals(array($student1->id), array_keys($result[$group1->id]));
$this->assertEquals(array($student2->id), array_keys($result[$group2->id]));
// Test get_users_with_capability_sql (via get_potential_authors).
$users = $workshopgrouping->get_potential_authors(false);
$userids = array_keys($users);
sort($userids);
$this->assertEquals(array($student1->id, $student2->id), $userids);
$users = $workshopgrouping->get_potential_authors(false, $group2->id);
$this->assertEquals(array($student2->id), array_keys($users));
// Enable the availability system and create another test workshop with
// availability restriction on grouping.
$CFG->enableavailability = true;
$workshopitem = $this->getDataGenerator()->create_module('workshop', array('course' => $courseid, 'availability' => json_encode(\core_availability\tree::get_root_json(array(\availability_grouping\condition::get_json($grouping->id)), \core_availability\tree::OP_AND, false))));
$cm = get_coursemodule_from_instance('workshop', $workshopitem->id, $courseid, false, MUST_EXIST);
$workshoprestricted = new testable_workshop($workshopitem, $cm, $this->workshop->course);
// The get_grouped function isn't intended to apply this restriction,
// so it should be the same as the base workshop. (Note: in reality,
// get_grouped is always run with the parameter being the result of
// one of the get_potential_xxx functions, so it works.)
$result = $workshoprestricted->get_grouped($allusers);
$this->assertCount(4, $result);
$this->assertCount(3, $result[0]);
// The get_users_with_capability_sql-based functions should apply it.
$users = $workshoprestricted->get_potential_authors(false);
$userids = array_keys($users);
sort($userids);
$this->assertEquals(array($student1->id, $student2->id), $userids);
$users = $workshoprestricted->get_potential_authors(false, $group2->id);
$this->assertEquals(array($student2->id), array_keys($users));
}