本文整理汇总了PHP中assign::get_submission_plugin_by_type方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::get_submission_plugin_by_type方法的具体用法?PHP assign::get_submission_plugin_by_type怎么用?PHP assign::get_submission_plugin_by_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::get_submission_plugin_by_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strlen
/**
* Format the submission and feedback columns
*
* @param string $colname The column name
* @param stdClass $row The submission row
* @return mixed string or NULL
*/
function other_cols($colname, $row)
{
if (($pos = strpos($colname, 'assignsubmission_')) !== false) {
$plugin = $this->assignment->get_submission_plugin_by_type(substr($colname, strlen('assignsubmission_')));
if ($plugin->is_visible() && $plugin->is_enabled()) {
if ($row->submissionid) {
$submission = new stdClass();
$submission->id = $row->submissionid;
$submission->timecreated = $row->firstsubmission;
$submission->timemodified = $row->timesubmitted;
$submission->assignment = $this->assignment->get_instance()->id;
$submission->userid = $row->userid;
return $this->format_plugin_summary_with_link($plugin, $submission, 'grading', array());
}
}
return '';
}
if (($pos = strpos($colname, 'feedback_')) !== false) {
$plugin = $this->assignment->get_feedback_plugin_by_type(substr($colname, strlen('assignfeedback_')));
if ($plugin->is_visible() && $plugin->is_enabled()) {
$grade = null;
if ($row->gradeid) {
$grade = new stdClass();
$grade->id = $row->gradeid;
$grade->timecreated = $row->firstmarked;
$grade->timemodified = $row->timemarked;
$grade->assignment = $this->assignment->get_instance()->id;
$grade->userid = $row->userid;
$grade->grade = $row->grade;
$grade->mailed = $row->mailed;
}
if ($this->quickgrading && $plugin->supports_quickgrading()) {
return $plugin->get_quickgrading_html($row->userid, $grade);
} else {
if ($grade) {
return $this->format_plugin_summary_with_link($plugin, $grade, 'grading', array());
}
}
}
return '';
}
return NULL;
}
示例2: get_submission_plugin
/**
* Fetch the plugin by its type.
*
* @return assign_submission_plugin
*/
protected function get_submission_plugin()
{
global $CFG;
if (!$this->plugin || !$this->cmid) {
return null;
}
require_once $CFG->dirroot . '/mod/assign/locallib.php';
$context = context_module::instance($this->cmid);
$assignment = new assign($context, null, null);
return $assignment->get_submission_plugin_by_type($this->plugin);
}
示例3: test_upgrade_offline_assignment
public function test_upgrade_offline_assignment() {
global $DB;
$this->setUser($this->editingteachers[0]);
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assignment');
$params = array('course'=>$this->course->id,
'assignmenttype'=>'offline');
$record = $generator->create_instance($params);
$assignment = new assignment_base($record->cmid);
$this->setAdminUser();
$log = '';
$upgrader = new assign_upgrade_manager();
$this->assertTrue($upgrader->upgrade_assignment($assignment->assignment->id, $log));
$record = $DB->get_record('assign', array('course'=>$this->course->id));
$cm = get_coursemodule_from_instance('assign', $record->id);
$context = context_module::instance($cm->id);
$assign = new assign($context, $cm, $this->course);
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
$this->assertEmpty($plugin->is_enabled());
$plugin = $assign->get_submission_plugin_by_type('comments');
$this->assertEmpty($plugin->is_enabled());
$plugin = $assign->get_submission_plugin_by_type('file');
$this->assertEmpty($plugin->is_enabled());
$plugin = $assign->get_feedback_plugin_by_type('comments');
$this->assertNotEmpty($plugin->is_enabled());
$plugin = $assign->get_feedback_plugin_by_type('file');
$this->assertEmpty($plugin->is_enabled());
$plugin = $assign->get_feedback_plugin_by_type('offline');
$this->assertEmpty($plugin->is_enabled());
course_delete_module($cm->id);
}
示例4: test_submit_for_grading
/**
* Test submit_for_grading
*/
public function test_submit_for_grading()
{
global $DB, $USER;
$this->resetAfterTest(true);
// Create a course and assignment and users.
$course = self::getDataGenerator()->create_course();
set_config('submissionreceipts', 0, 'assign');
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
$params['course'] = $course->id;
$params['assignsubmission_onlinetext_enabled'] = 1;
$params['submissiondrafts'] = 1;
$params['sendnotifications'] = 0;
$params['requiresubmissionstatement'] = 1;
$instance = $generator->create_instance($params);
$cm = get_coursemodule_from_instance('assign', $instance->id);
$context = context_module::instance($cm->id);
$assign = new assign($context, $cm, $course);
$student1 = self::getDataGenerator()->create_user();
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
// Create a student1 with an online text submission.
// Simulate a submission.
$this->setUser($student1);
$submission = $assign->get_user_submission($student1->id, true);
$data = new stdClass();
$data->onlinetext_editor = array('itemid' => file_get_unused_draft_itemid(), 'text' => 'Submission text', 'format' => FORMAT_MOODLE);
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
$plugin->save($submission, $data);
$result = mod_assign_external::submit_for_grading($instance->id, false);
$result = external_api::clean_returnvalue(mod_assign_external::submit_for_grading_returns(), $result);
// Should be 1 fail because the submission statement was not aceptted.
$this->assertEquals(1, count($result));
$result = mod_assign_external::submit_for_grading($instance->id, true);
$result = external_api::clean_returnvalue(mod_assign_external::submit_for_grading_returns(), $result);
// Check for 0 warnings.
$this->assertEquals(0, count($result));
$submission = $assign->get_user_submission($student1->id, false);
$this->assertEquals(ASSIGN_SUBMISSION_STATUS_SUBMITTED, $submission->status);
}