本文整理汇总了PHP中assign::list_participants方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::list_participants方法的具体用法?PHP assign::list_participants怎么用?PHP assign::list_participants使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::list_participants方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* overridden constructor keeps a reference to the assignment class that is displaying this table
*
* @param assign $assignment The assignment class
* @param int $perpage how many per page
* @param string $filter The current filter
* @param int $rowoffset For showing a subsequent page of results
* @param bool $quickgrading Is this table wrapped in a quickgrading form?
*/
public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading, $downloadfilename = null)
{
global $CFG, $PAGE, $DB;
parent::__construct('mod_assign_grading');
$this->assignment = $assignment;
foreach ($assignment->get_feedback_plugins() as $plugin) {
if ($plugin->is_visible() && $plugin->is_enabled()) {
foreach ($plugin->get_grading_batch_operations() as $action => $description) {
if (empty($this->plugingradingbatchoperations)) {
$this->plugingradingbatchoperations[$plugin->get_type()] = array();
}
$this->plugingradingbatchoperations[$plugin->get_type()][$action] = $description;
}
}
}
$this->perpage = $perpage;
$this->quickgrading = $quickgrading;
$this->output = $PAGE->get_renderer('mod_assign');
$this->define_baseurl(new moodle_url($CFG->wwwroot . '/mod/assign/view.php', array('action' => 'grading', 'id' => $assignment->get_course_module()->id)));
// do some business - then set the sql
$currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
if ($rowoffset) {
$this->rownum = $rowoffset - 1;
}
$users = array_keys($assignment->list_participants($currentgroup, true));
if (count($users) == 0) {
// insert a record that will never match to the sql is still valid.
$users[] = -1;
}
$params = array();
$params['assignmentid1'] = (int) $this->assignment->get_instance()->id;
$params['assignmentid2'] = (int) $this->assignment->get_instance()->id;
$fields = user_picture::fields('u') . ', ';
$fields .= 'u.id as userid, ';
$fields .= 's.status as status, ';
$fields .= 's.id as submissionid, ';
$fields .= 's.timecreated as firstsubmission, ';
$fields .= 's.timemodified as timesubmitted, ';
$fields .= 'g.id as gradeid, ';
$fields .= 'g.grade as grade, ';
$fields .= 'g.timemodified as timemarked, ';
$fields .= 'g.timecreated as firstmarked, ';
$fields .= 'g.mailed as mailed, ';
$fields .= 'g.locked as locked, ';
$fields .= 'g.extensionduedate as extensionduedate';
$from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1' . ' LEFT JOIN {assign_grades} g ON u.id = g.userid AND g.assignment = :assignmentid2';
$userparams = array();
$userindex = 0;
list($userwhere, $userparams) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED, 'user');
$where = 'u.id ' . $userwhere;
$params = array_merge($params, $userparams);
if ($filter == ASSIGN_FILTER_SUBMITTED) {
$where .= ' AND s.timecreated > 0 ';
}
if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) {
$where .= ' AND (s.timemodified > g.timemodified OR (s.timemodified IS NOT NULL AND g.timemodified IS NULL))';
}
if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) {
$userfilter = (int) array_pop(explode('=', $filter));
$where .= ' AND (u.id = :userid)';
$params['userid'] = $userfilter;
}
$this->set_sql($fields, $from, $where, $params);
if ($downloadfilename) {
$this->is_downloading('csv', $downloadfilename);
}
$columns = array();
$headers = array();
// Select.
if (!$this->is_downloading()) {
$columns[] = 'select';
$headers[] = get_string('select') . '<div class="selectall"><label class="accesshide" for="selectall">' . get_string('selectall') . '</label>
<input type="checkbox" id="selectall" name="selectall" title="' . get_string('selectall') . '"/></div>';
}
// User picture.
if (!$this->assignment->is_blind_marking()) {
if (!$this->is_downloading()) {
$columns[] = 'picture';
$headers[] = get_string('pictureofuser');
} else {
$columns[] = 'recordid';
$headers[] = get_string('recordid', 'assign');
}
// Fullname.
$columns[] = 'fullname';
$headers[] = get_string('fullname');
} else {
// Record ID.
$columns[] = 'recordid';
$headers[] = get_string('recordid', 'assign');
}
//.........这里部分代码省略.........
示例2: __construct
/**
* overridden constructor keeps a reference to the assignment class that is displaying this table
*
* @param assign $assignment The assignment class
* @param int $perpage how many per page
* @param string $filter The current filter
* @param int $rowoffset For showing a subsequent page of results
* @param bool $quickgrading Is this table wrapped in a quickgrading form?
* @param string $downloadfilename
*/
public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading, $downloadfilename = null)
{
global $CFG, $PAGE, $DB, $USER;
parent::__construct('mod_assign_grading');
$this->is_persistent(true);
$this->assignment = $assignment;
// Check permissions up front.
$this->hasgrantextension = has_capability('mod/assign:grantextension', $this->assignment->get_context());
$this->hasgrade = $this->assignment->can_grade();
// Check if we have the elevated view capablities to see the blind details.
$this->hasviewblind = has_capability('mod/assign:viewblinddetails', $this->assignment->get_context());
foreach ($assignment->get_feedback_plugins() as $plugin) {
if ($plugin->is_visible() && $plugin->is_enabled()) {
foreach ($plugin->get_grading_batch_operations() as $action => $description) {
if (empty($this->plugingradingbatchoperations)) {
$this->plugingradingbatchoperations[$plugin->get_type()] = array();
}
$this->plugingradingbatchoperations[$plugin->get_type()][$action] = $description;
}
}
}
$this->perpage = $perpage;
$this->quickgrading = $quickgrading && $this->hasgrade;
$this->output = $PAGE->get_renderer('mod_assign');
$urlparams = array('action' => 'grading', 'id' => $assignment->get_course_module()->id);
$url = new moodle_url($CFG->wwwroot . '/mod/assign/view.php', $urlparams);
$this->define_baseurl($url);
// Do some business - then set the sql.
$currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
if ($rowoffset) {
$this->rownum = $rowoffset - 1;
}
$users = array_keys($assignment->list_participants($currentgroup, true));
if (count($users) == 0) {
// Insert a record that will never match to the sql is still valid.
$users[] = -1;
}
$params = array();
$params['assignmentid1'] = (int) $this->assignment->get_instance()->id;
$params['assignmentid2'] = (int) $this->assignment->get_instance()->id;
$params['assignmentid3'] = (int) $this->assignment->get_instance()->id;
$extrauserfields = get_extra_user_fields($this->assignment->get_context());
$fields = user_picture::fields('u', $extrauserfields) . ', ';
$fields .= 'u.id as userid, ';
$fields .= 's.status as status, ';
$fields .= 's.id as submissionid, ';
$fields .= 's.timecreated as firstsubmission, ';
$fields .= 's.timemodified as timesubmitted, ';
$fields .= 's.attemptnumber as attemptnumber, ';
$fields .= 'g.id as gradeid, ';
$fields .= 'g.grade as grade, ';
$fields .= 'g.timemodified as timemarked, ';
$fields .= 'g.timecreated as firstmarked, ';
$fields .= 'uf.mailed as mailed, ';
$fields .= 'uf.locked as locked, ';
$fields .= 'uf.extensionduedate as extensionduedate, ';
$fields .= 'uf.workflowstate as workflowstate, ';
$fields .= 'uf.allocatedmarker as allocatedmarker ';
$from = '{user} u
LEFT JOIN {assign_submission} s
ON u.id = s.userid
AND s.assignment = :assignmentid1
AND s.latest = 1
LEFT JOIN {assign_grades} g
ON u.id = g.userid
AND g.assignment = :assignmentid2 ';
// For group submissions we don't immediately create an entry in the assign_submission table for each user,
// instead the userid is set to 0. In this case we use a different query to retrieve the grade for the user.
if ($this->assignment->get_instance()->teamsubmission) {
$params['assignmentid4'] = (int) $this->assignment->get_instance()->id;
$grademaxattempt = 'SELECT mxg.userid, MAX(mxg.attemptnumber) AS maxattempt
FROM {assign_grades} mxg
WHERE mxg.assignment = :assignmentid4
GROUP BY mxg.userid';
$from .= 'LEFT JOIN (' . $grademaxattempt . ') gmx
ON u.id = gmx.userid
AND g.attemptnumber = gmx.maxattempt ';
} else {
$from .= 'AND g.attemptnumber = s.attemptnumber ';
}
$from .= 'LEFT JOIN {assign_user_flags} uf
ON u.id = uf.userid
AND uf.assignment = :assignmentid3';
$userparams = array();
$userindex = 0;
list($userwhere, $userparams) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED, 'user');
$where = 'u.id ' . $userwhere;
$params = array_merge($params, $userparams);
// The filters do not make sense when there are no submissions, so do not apply them.
if ($this->assignment->is_any_submission_plugin_enabled()) {
//.........这里部分代码省略.........
示例3: array
/**
* overridden constructor keeps a reference to the assignment class that is displaying this table
*
* @param assign $assignment The assignment class
* @param int $perpage how many per page
* @param string $filter The current filter
* @param int $rowoffset For showing a subsequent page of results
* @param bool $quickgrading Is this table wrapped in a quickgrading form?
*/
function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading) {
global $CFG, $PAGE, $DB;
parent::__construct('mod_assign_grading');
$this->assignment = $assignment;
$this->perpage = $perpage;
$this->quickgrading = $quickgrading;
$this->output = $PAGE->get_renderer('mod_assign');
$this->define_baseurl(new moodle_url($CFG->wwwroot . '/mod/assign/view.php', array('action'=>'grading', 'id'=>$assignment->get_course_module()->id)));
// do some business - then set the sql
$currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
if ($rowoffset) {
$this->rownum = $rowoffset - 1;
}
$users = array_keys( $assignment->list_participants($currentgroup, true));
if (count($users) == 0) {
// insert a record that will never match to the sql is still valid.
$users[] = -1;
}
$params = array();
$params['assignmentid1'] = (int)$this->assignment->get_instance()->id;
$params['assignmentid2'] = (int)$this->assignment->get_instance()->id;
$fields = user_picture::fields('u') . ', u.id as userid, u.firstname as firstname, u.lastname as lastname, ';
$fields .= 's.status as status, s.id as submissionid, s.timecreated as firstsubmission, s.timemodified as timesubmitted, ';
$fields .= 'g.id as gradeid, g.grade as grade, g.timemodified as timemarked, g.timecreated as firstmarked, g.mailed as mailed, g.locked as locked';
$from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1' .
' LEFT JOIN {assign_grades} g ON u.id = g.userid AND g.assignment = :assignmentid2';
$userparams = array();
$userindex = 0;
list($userwhere, $userparams) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED, 'user');
$where = 'u.id ' . $userwhere;
$params = array_merge($params, $userparams);
if ($filter == ASSIGN_FILTER_SUBMITTED) {
$where .= ' AND s.timecreated > 0 ';
}
if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) {
$where .= ' AND (s.timemodified > g.timemodified OR (s.timemodified IS NOT NULL AND g.timemodified IS NULL))';
}
if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) {
$userfilter = (int) array_pop(explode('=', $filter));
$where .= ' AND (u.id = :userid)';
$params['userid'] = $userfilter;
}
$this->set_sql($fields, $from, $where, $params);
$columns = array();
$headers = array();
// Select
$columns[] = 'select';
$headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>';
// Edit links
if (!$this->is_downloading()) {
$columns[] = 'edit';
$headers[] = get_string('edit');
}
// User picture
$columns[] = 'picture';
$headers[] = get_string('pictureofuser');
// Fullname
$columns[] = 'fullname';
$headers[] = get_string('fullname');
// Submission status
if ($assignment->is_any_submission_plugin_enabled()) {
$columns[] = 'status';
$headers[] = get_string('status');
}
// Grade
$columns[] = 'grade';
$headers[] = get_string('grade');
// Submission plugins
if ($assignment->is_any_submission_plugin_enabled()) {
$columns[] = 'timesubmitted';
$headers[] = get_string('lastmodifiedsubmission', 'assign');
//.........这里部分代码省略.........
示例4: import_zip_files
/**
* Process an uploaded zip file
*
* @param assign $assignment - The assignment instance
* @param assign_feedback_file $fileplugin - The file feedback plugin
* @return string - The html response
*/
public function import_zip_files($assignment, $fileplugin) {
global $USER, $CFG, $PAGE, $DB;
@set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
$packer = get_file_packer('application/zip');
$feedbackfilesupdated = 0;
$feedbackfilesadded = 0;
$userswithnewfeedback = array();
$contextid = $assignment->get_context()->id;
$fs = get_file_storage();
$files = $fs->get_directory_files($contextid,
'assignfeedback_file',
ASSIGNFEEDBACK_FILE_IMPORT_FILEAREA,
$USER->id,
'/import/');
$currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
$allusers = $assignment->list_participants($currentgroup, false);
$participants = array();
foreach ($allusers as $user) {
$participants[$assignment->get_uniqueid_for_user($user->id)] = $user;
}
foreach ($files as $unzippedfile) {
// Set the timeout for unzipping each file.
$user = null;
$plugin = null;
$filename = '';
if ($this->is_valid_filename_for_import($assignment, $unzippedfile, $participants, $user, $plugin, $filename)) {
if ($this->is_file_modified($assignment, $user, $plugin, $filename, $unzippedfile)) {
$grade = $assignment->get_user_grade($user->id, true);
if ($oldfile = $fs->get_file($contextid,
'assignfeedback_file',
ASSIGNFEEDBACK_FILE_FILEAREA,
$grade->id,
'/',
$filename)) {
// Update existing feedback file.
$oldfile->replace_content_with($unzippedfile);
$feedbackfilesupdated++;
} else {
// Create a new feedback file.
$newfilerecord = new stdClass();
$newfilerecord->contextid = $contextid;
$newfilerecord->component = 'assignfeedback_file';
$newfilerecord->filearea = ASSIGNFEEDBACK_FILE_FILEAREA;
$newfilerecord->filename = $filename;
$newfilerecord->filepath = '/';
$newfilerecord->itemid = $grade->id;
$fs->create_file_from_storedfile($newfilerecord, $unzippedfile);
$feedbackfilesadded++;
}
$userswithnewfeedback[$user->id] = 1;
// Update the number of feedback files for this user.
$fileplugin->update_file_count($grade);
// Update the last modified time on the grade which will trigger student notifications.
$assignment->notify_grade_modified($grade);
}
}
}
require_once($CFG->dirroot . '/mod/assign/feedback/file/renderable.php');
$importsummary = new assignfeedback_file_import_summary($assignment->get_course_module()->id,
count($userswithnewfeedback),
$feedbackfilesadded,
$feedbackfilesupdated);
$assignrenderer = $assignment->get_renderer();
$renderer = $PAGE->get_renderer('assignfeedback_file');
$o = '';
$o .= $assignrenderer->render(new assign_header($assignment->get_instance(),
$assignment->get_context(),
false,
$assignment->get_course_module()->id,
get_string('uploadzipsummary', 'assignfeedback_file')));
$o .= $renderer->render($importsummary);
$o .= $assignrenderer->render_footer();
return $o;
}
示例5: import_zip_files
/**
* Process an uploaded zip file
*
* @param assign $assignment - The assignment instance
* @param assign_feedback_file $fileplugin - The file feedback plugin
* @return string - The html response
*/
public function import_zip_files($assignment, $fileplugin)
{
global $CFG, $PAGE, $DB;
core_php_time_limit::raise(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
$packer = get_file_packer('application/zip');
$feedbackfilesupdated = 0;
$feedbackfilesadded = 0;
$userswithnewfeedback = array();
$contextid = $assignment->get_context()->id;
$fs = get_file_storage();
$files = $this->get_import_files($contextid);
$currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
$allusers = $assignment->list_participants($currentgroup, false);
$participants = array();
foreach ($allusers as $user) {
$participants[$assignment->get_uniqueid_for_user($user->id)] = $user;
}
foreach ($files as $unzippedfile) {
// Set the timeout for unzipping each file.
$user = null;
$plugin = null;
$filename = '';
if ($this->is_valid_filename_for_import($assignment, $unzippedfile, $participants, $user, $plugin, $filename)) {
if ($this->is_file_modified($assignment, $user, $plugin, $filename, $unzippedfile)) {
$grade = $assignment->get_user_grade($user->id, true);
// In 3.1 the default download structure of the submission files changed so that each student had their own
// separate folder, the files were not renamed and the folder structure was kept. It is possible that
// a user downloaded the submission files in 3.0 (or earlier) and edited the zip to add feedback or
// changed the behavior back to the previous format, the following code means that we will still support the
// old file structure. For more information please see - MDL-52489 / MDL-56022.
$path = pathinfo($filename);
if ($path['dirname'] == '.') {
// Student submissions are not in separate folders.
$basename = $filename;
$dirname = "/";
$dirnamewslash = "/";
} else {
$basename = $path['basename'];
$dirname = $path['dirname'];
$dirnamewslash = $dirname . "/";
}
if ($oldfile = $fs->get_file($contextid, 'assignfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $grade->id, $dirname, $basename)) {
// Update existing feedback file.
$oldfile->replace_file_with($unzippedfile);
$feedbackfilesupdated++;
} else {
// Create a new feedback file.
$newfilerecord = new stdClass();
$newfilerecord->contextid = $contextid;
$newfilerecord->component = 'assignfeedback_file';
$newfilerecord->filearea = ASSIGNFEEDBACK_FILE_FILEAREA;
$newfilerecord->filename = $basename;
$newfilerecord->filepath = $dirnamewslash;
$newfilerecord->itemid = $grade->id;
$fs->create_file_from_storedfile($newfilerecord, $unzippedfile);
$feedbackfilesadded++;
}
$userswithnewfeedback[$user->id] = 1;
// Update the number of feedback files for this user.
$fileplugin->update_file_count($grade);
// Update the last modified time on the grade which will trigger student notifications.
$assignment->notify_grade_modified($grade);
}
}
}
require_once $CFG->dirroot . '/mod/assign/feedback/file/renderable.php';
$importsummary = new assignfeedback_file_import_summary($assignment->get_course_module()->id, count($userswithnewfeedback), $feedbackfilesadded, $feedbackfilesupdated);
$assignrenderer = $assignment->get_renderer();
$renderer = $PAGE->get_renderer('assignfeedback_file');
$o = '';
$o .= $assignrenderer->render(new assign_header($assignment->get_instance(), $assignment->get_context(), false, $assignment->get_course_module()->id, get_string('uploadzipsummary', 'assignfeedback_file')));
$o .= $renderer->render($importsummary);
$o .= $assignrenderer->render_footer();
return $o;
}
示例6: evaluate_enrichment
/**
* Automatic student evaluation
*
* This function automatically avaluates the student according to enrichment criteria
* which are cross referenced with the data obtained through Learning Analytics data mining procedures.
*
* For the new logging system from Moodle 2.6 onwards, Learning Analytics will only be obtained from
* Legacy log Table a.k.a. {log} or New Internal Log Table a.k.a {logstore_standard_log}.
*
* External logstores can't be used because their data structure and logging data are custom
* and can not be predicted. Only a log store creator would be able to change the data queries bellow
* according to his log store specifications.
*
*
* @param array $criterion data about the rubric design
* @param array $options enriched rubric options
*/
protected function evaluate_enrichment(&$criterion, $options)
{
global $DB;
global $PAGE;
global $CFG;
$moduletypename = null;
$benchmarkstudent = null;
$benchmarkstudents = null;
$benchmarkcriterion = null;
$untiltime = null;
$fromtime = null;
$selectallstudents = null;
$participatingstudents = null;
$iterations = 0;
$sql = null;
// Get the current assignment data.
$curmoduleid = (int) $PAGE->cm->module;
$curmodulename = $PAGE->cm->modname;
$curcmid = $PAGE->cm->id;
$gradingmoduleid = $PAGE->cm->instance;
$courseid = $PAGE->cm->course;
//**** For Moodle 2.6 onwards new logging system ***//
/* If the Legacy Log is used, we work with it. If not, we use the new Internal Log (Standard). The old log is more efficient for the queries used bellow.
* If en External Logstore is used and both Legacy and new Internal logs are deactivated, do nothing, as we can't know in advance how the new
* external logs are stored and how the store's log tables are structured.
*
*/
// Set the necessary variables
$uselegacyreader = true;
$useinternalreader = null;
$minloginternalreader = null;
$logtable = null;
$moodle_2_6_0_version = '2013111800';
// Get the necessary variables if needed
if ($CFG->version >= $moodle_2_6_0_version) {
require_once $CFG->dirroot . '/report/outline/locallib.php';
list($uselegacyreader, $useinternalreader, $minloginternalreader, $logtable) = report_outline_get_common_log_variables();
}
//**** For moodle 2.2 versions assignment modules ****//
$studentid = optional_param('userid', '', PARAM_INT);
//**** For moodle 2.3 onwards assignment module ****//
if (!$studentid) {
require_once $CFG->dirroot . '/mod/assign/locallib.php';
$context = context_module::instance($PAGE->cm->id);
$assignment = new assign($context, $PAGE->cm, $PAGE->cm->course);
$useridlist = array_keys($assignment->list_participants(0, true));
sort($useridlist);
// The users list containing the IDs of students evaluated.
$rownum = $_REQUEST['rownum'];
// Check if next or previous buttons are pressed in the avaluation form.
if (array_key_exists('saveandshownext', $_REQUEST) || array_key_exists('nosaveandnext', $_REQUEST)) {
$rownum++;
}
if (array_key_exists('nosaveandprevious', $_REQUEST)) {
$rownum--;
}
$studentid = $useridlist[$rownum];
}
// SQL for including all course enroled students.
$selectindividual = "= {$studentid}";
$selectallstudents = "IN (SELECT u.id\n FROM {role_assignments} ra\n JOIN {context} c ON ra.contextid = c.id AND c.contextlevel = 50\n JOIN {user} u ON u.id = ra.userid\n JOIN {course} crse ON c.instanceid = crse.id\n WHERE ra.roleid = 5\n AND crse.id = {$courseid})";
// Timestamp enrichment calculations according to assignment module (old or new type assignments).
// In case of old type assignment...
if ($curmoduleid == $this->oldassignmoduleid) {
// Get potential enrichment due date.
if ($options['timestampenrichmentend']) {
$sql = 'SELECT asmnt.timedue AS duedate FROM {assignment} asmnt WHERE asmnt.id = ' . $gradingmoduleid;
$untiltime = $DB->get_field_sql($sql, null);
}
// Get potential availability start time.
if ($options['timestampenrichmentstart']) {
$sql = 'SELECT asmnt.timeavailable AS startdate FROM {assignment} asmnt WHERE asmnt.id = ' . $gradingmoduleid;
$fromtime = $DB->get_field_sql($sql, null);
}
// In case of new type assignment...
} else {
if ($curmoduleid == $this->newassignmoduleid) {
// Get potential enrichment due date.
if ($options['timestampenrichmentend']) {
$sql = 'SELECT asmnt.duedate AS duedate FROM {assign} asmnt WHERE asmnt.id = ' . $gradingmoduleid;
$untiltime = $DB->get_field_sql($sql, null);
}
// Get potential availability start time.
//.........这里部分代码省略.........
示例7: test_list_participants_blind_marking
public function test_list_participants_blind_marking()
{
global $DB;
$this->resetAfterTest(true);
$course = $this->getDataGenerator()->create_course();
$roles = $DB->get_records('role', null, '', 'shortname, id');
$teacher = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $roles['teacher']->id);
$this->setUser($teacher);
// Enrol two students.
$students = [];
for ($i = 0; $i < 2; $i++) {
$student = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($student->id, $course->id, $roles['student']->id);
$students[$student->id] = $student;
}
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
$instance = $generator->create_instance(['course' => $course->id, 'blindmarking' => 1]);
$cm = get_coursemodule_from_instance('assign', $instance->id);
$context = context_module::instance($cm->id);
$assign = new assign($context, $cm, $course);
// Allocate IDs now.
// We're testing whether the IDs are correct after allocation.
assign::allocate_unique_ids($assign->get_instance()->id);
$participants = $assign->list_participants(null, false);
// There should be exactly two participants and they should be the students.
$this->assertCount(2, $participants);
foreach ($participants as $participant) {
$this->assertArrayHasKey($participant->id, $students);
}
$keys = array_keys($participants);
// Create a grading table, and query the DB This should have the same order.
$table = new assign_grading_table($assign, 10, '', 0, false);
$table->setup();
$table->query_db(10);
$this->assertEquals($keys, array_keys($table->rawdata));
// Submit a file for the second student.
$data = new stdClass();
$data->onlinetext_editor = array('itemid' => file_get_unused_draft_itemid(), 'text' => 'Submission text', 'format' => FORMAT_MOODLE);
static::helper_add_submission($assign, $participants[$keys[1]], $data, 'onlinetext');
// Assign has a private cache. The easiest way to clear this is to create a new instance.
$assign = new assign($context, $cm, $course);
$newparticipants = $assign->list_participants(null, false);
// There should be exactly two participants and they should be the students.
$this->assertCount(2, $newparticipants);
foreach ($newparticipants as $participant) {
$this->assertArrayHasKey($participant->id, $students);
}
$newkeys = array_keys($newparticipants);
// The user who submitted first should now be listed first.
$this->assertEquals($participants[$keys[1]]->id, $newparticipants[$newkeys[0]]->id);
$this->assertEquals($participants[$keys[0]]->id, $newparticipants[$newkeys[1]]->id);
// Submit for the other student.
static::helper_add_submission($assign, $participants[$keys[0]], $data, 'onlinetext');
$assign = new assign($context, $cm, $course);
$newparticipants = $assign->list_participants(null, false);
// The users should still be listed in order of the first submission
$this->assertEquals($participants[$keys[1]]->id, $newparticipants[$newkeys[0]]->id);
$this->assertEquals($participants[$keys[0]]->id, $newparticipants[$newkeys[1]]->id);
// The updated grading table should have the same order as the updated participant list.
$table->query_db(10);
$this->assertEquals($newkeys, array_keys($table->rawdata));
}