本文整理汇总了PHP中grade_scale::set_properties方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_scale::set_properties方法的具体用法?PHP grade_scale::set_properties怎么用?PHP grade_scale::set_properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_scale
的用法示例。
在下文中一共展示了grade_scale::set_properties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grade_scale
if ($data = $mform->get_data()) {
$scale = new grade_scale(array('id' => $id));
$data->userid = $USER->id;
if (empty($scale->id)) {
$data->description = $data->description_editor['text'];
$data->descriptionformat = $data->description_editor['format'];
grade_scale::set_properties($scale, $data);
if (!has_capability('moodle/grade:manage', $systemcontext)) {
$data->standard = 0;
}
$scale->courseid = !empty($data->standard) ? 0 : $courseid;
$scale->insert();
$data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale->id);
$DB->set_field($scale->table, 'description', $data->description, array('id' => $scale->id));
} else {
$data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $id);
grade_scale::set_properties($scale, $data);
if (isset($data->standard)) {
$scale->courseid = !empty($data->standard) ? 0 : $courseid;
} else {
unset($scale->courseid);
// keep previous
}
$scale->update();
}
redirect($returnurl);
}
}
print_grade_page_head($COURSE->id, 'scale', null, $heading, false, false, false);
$mform->display();
echo $OUTPUT->footer();
示例2: workshopform_accumulative_upgrade_scales
/**
* Creates new standard (global) scales to replace the legacy workshop ones
*
* In workshop 1.x, scale field in workshop_elements had the following meaning:
* 0 | 2 point Yes/No scale
* 1 | 2 point Present/Absent scale
* 2 | 2 point Correct/Incorrect scale
* 3 | 3 point Good/Poor scale
* 4 | 4 point Excellent/Very Poor scale
* 5 | 5 point Excellent/Very Poor scale
* 6 | 7 point Excellent/Very Poor scale
* 7 | Score out of 10
* 8 | Score out of 20
* 9 | Score out of 100
*
* @return array (int)oldscale => (int)newscaleid
*/
function workshopform_accumulative_upgrade_scales()
{
global $DB, $CFG, $USER;
require_once $CFG->libdir . '/gradelib.php';
$sql = 'SELECT DISTINCT scale
FROM {workshop_elements_old}
WHERE newplugin IS NULL';
$oldscales = $DB->get_records_sql($sql);
$newscales = array();
foreach ($oldscales as $oldscale => $whatever) {
switch ($oldscale) {
case 0:
$data = new stdclass();
$data->courseid = 0;
$data->userid = $USER->id;
$data->name = get_string('scalename0', 'workshopform_accumulative');
$data->scale = implode(',', array(get_string('no'), get_string('yes')));
$data->description = '';
$data->descriptionformat = FORMAT_HTML;
$scale = new grade_scale();
grade_scale::set_properties($scale, $data);
$newscales[0] = $scale->insert('mod/workshop');
break;
case 1:
$data = new stdclass();
$data->courseid = 0;
$data->userid = $USER->id;
$data->name = get_string('scalename1', 'workshopform_accumulative');
$data->scale = implode(',', array(get_string('absent', 'workshopform_accumulative'), get_string('present', 'workshopform_accumulative')));
$data->description = '';
$data->descriptionformat = FORMAT_HTML;
$scale = new grade_scale();
grade_scale::set_properties($scale, $data);
$newscales[1] = $scale->insert('mod/workshop');
break;
case 2:
$data = new stdclass();
$data->courseid = 0;
$data->userid = $USER->id;
$data->name = get_string('scalename2', 'workshopform_accumulative');
$data->scale = implode(',', array(get_string('incorrect', 'workshopform_accumulative'), get_string('correct', 'workshopform_accumulative')));
$data->description = '';
$data->descriptionformat = FORMAT_HTML;
$scale = new grade_scale();
grade_scale::set_properties($scale, $data);
$newscales[2] = $scale->insert('mod/workshop');
break;
case 3:
$data = new stdclass();
$data->courseid = 0;
$data->userid = $USER->id;
$data->name = get_string('scalename3', 'workshopform_accumulative');
$data->scale = implode(',', array('* ' . get_string('poor', 'workshopform_accumulative'), '**', '*** ' . get_string('good', 'workshopform_accumulative')));
$data->description = '';
$data->descriptionformat = FORMAT_HTML;
$scale = new grade_scale();
grade_scale::set_properties($scale, $data);
$newscales[3] = $scale->insert('mod/workshop');
break;
case 4:
$data = new stdclass();
$data->courseid = 0;
$data->userid = $USER->id;
$data->name = get_string('scalename4', 'workshopform_accumulative');
$data->scale = implode(',', array('* ' . get_string('verypoor', 'workshopform_accumulative'), '**', '***', '**** ' . get_string('excellent', 'workshopform_accumulative')));
$data->description = '';
$data->descriptionformat = FORMAT_HTML;
$scale = new grade_scale();
grade_scale::set_properties($scale, $data);
$newscales[4] = $scale->insert('mod/workshop');
break;
case 5:
$data = new stdclass();
$data->courseid = 0;
$data->userid = $USER->id;
$data->name = get_string('scalename5', 'workshopform_accumulative');
$data->scale = implode(',', array('* ' . get_string('verypoor', 'workshopform_accumulative'), '**', '***', '****', '***** ' . get_string('excellent', 'workshopform_accumulative')));
$data->description = '';
$data->descriptionformat = FORMAT_HTML;
$scale = new grade_scale();
grade_scale::set_properties($scale, $data);
$newscales[5] = $scale->insert('mod/workshop');
break;
//.........这里部分代码省略.........