本文整理汇总了PHP中get_grading_manager函数的典型用法代码示例。如果您正苦于以下问题:PHP get_grading_manager函数的具体用法?PHP get_grading_manager怎么用?PHP get_grading_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_grading_manager函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_set_and_get_grading_area
/**
* Unit test to set and get grading areas
*/
public function test_set_and_get_grading_area()
{
global $DB;
$this->resetAfterTest(true);
//sleep(2); // to make sure the microtime will always return unique values // No sleeping in tests!!! --skodak
$areaname1 = 'area1-' . (string) microtime(true);
$areaname2 = 'area2-' . (string) microtime(true);
$fakecontext = (object) array('id' => 42, 'contextlevel' => CONTEXT_MODULE, 'instanceid' => 22, 'path' => '/1/3/15/42', 'depth' => 4);
// non-existing area
$gradingman = get_grading_manager($fakecontext, 'mod_foobar', $areaname1);
$this->assertNull($gradingman->get_active_method());
// creates area implicitly and sets active method
$this->assertTrue($gradingman->set_active_method('rubric'));
$this->assertEquals('rubric', $gradingman->get_active_method());
// repeat setting of already set active method
$this->assertFalse($gradingman->set_active_method('rubric'));
// switch the manager to another area
$gradingman->set_area($areaname2);
$this->assertNull($gradingman->get_active_method());
// switch back and ask again
$gradingman->set_area($areaname1);
$this->assertEquals('rubric', $gradingman->get_active_method());
// attempting to set an invalid method
$this->setExpectedException('moodle_exception');
$gradingman->set_active_method('no_one_should_ever_try_to_implement_a_method_with_this_silly_name');
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:29,代码来源:grading_manager_test.php
示例2: test_get_or_create_instance
/**
* Unit test to get draft instance and create new instance.
*/
public function test_get_or_create_instance()
{
global $DB;
$this->resetAfterTest(true);
// Create fake areas.
$fakearea = (object) array('contextid' => 1, 'component' => 'mod_assign', 'areaname' => 'submissions', 'activemethod' => 'guide');
$fakearea1id = $DB->insert_record('grading_areas', $fakearea);
$fakearea->contextid = 2;
$fakearea2id = $DB->insert_record('grading_areas', $fakearea);
// Create fake definitions.
$fakedefinition = (object) array('areaid' => $fakearea1id, 'method' => 'guide', 'name' => 'fakedef', 'status' => gradingform_controller::DEFINITION_STATUS_READY, 'timecreated' => 0, 'usercreated' => 1, 'timemodified' => 0, 'usermodified' => 1);
$fakedef1id = $DB->insert_record('grading_definitions', $fakedefinition);
$fakedefinition->areaid = $fakearea2id;
$fakedef2id = $DB->insert_record('grading_definitions', $fakedefinition);
// Create fake guide instance in first area.
$fakeinstance = (object) array('definitionid' => $fakedef1id, 'raterid' => 1, 'itemid' => 1, 'rawgrade' => null, 'status' => 0, 'feedback' => null, 'feedbackformat' => 0, 'timemodified' => 0);
$fakeinstanceid = $DB->insert_record('grading_instances', $fakeinstance);
$manager1 = get_grading_manager($fakearea1id);
$manager2 = get_grading_manager($fakearea2id);
$controller1 = $manager1->get_controller('guide');
$controller2 = $manager2->get_controller('guide');
$instance1 = $controller1->get_or_create_instance(0, 1, 1);
$instance2 = $controller2->get_or_create_instance(0, 1, 1);
// Definitions should not be the same.
$this->assertEquals(false, $instance1->get_data('definitionid') == $instance2->get_data('definitionid'));
}
开发者ID:evltuma,项目名称:moodle,代码行数:29,代码来源:guide_test.php
示例3: extend_navigation
/**
* Extends the module navigation
*
* This function is called when the context for the page is an activity module with the
* FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.
*
* @param global_navigation $navigation {@link global_navigation}
* @param navigation_node $node {@link navigation_node}
*/
public function extend_navigation(global_navigation $navigation, navigation_node $node = null)
{
if (has_capability('moodle/grade:managegradingforms', $this->get_context())) {
// no need for preview if user can manage forms, he will have link to manage.php in settings instead
return;
}
if ($this->is_form_defined() && ($options = $this->get_options()) && !empty($options['alwaysshowdefinition'])) {
$node->add(get_string('gradingof', 'gradingform_rubric', get_grading_manager($this->get_areaid())->get_area_title()), new moodle_url('/grade/grading/form/' . $this->get_method_name() . '/preview.php', array('areaid' => $this->get_areaid())), settings_navigation::TYPE_CUSTOM);
}
}
开发者ID:JP-Git,项目名称:moodle,代码行数:19,代码来源:lib.php
示例4: get_definitions
/**
* Returns the definitions for the requested course module ids
* @param array of ints $cmids
* @param string $areaname
* @param boolean $activeonly default is false, if true, only the active method is returned
* @return array of areas with definitions for each requested course module id
* @since Moodle 2.5
*/
public static function get_definitions($cmids, $areaname, $activeonly = false)
{
global $DB, $CFG;
require_once "{$CFG->dirroot}/grade/grading/form/lib.php";
$params = self::validate_parameters(self::get_definitions_parameters(), array('cmids' => $cmids, 'areaname' => $areaname, 'activeonly' => $activeonly));
$warnings = array();
$areas = array();
foreach ($params['cmids'] as $cmid) {
$context = context_module::instance($cmid);
try {
self::validate_context($context);
} catch (Exception $e) {
$warnings[] = array('item' => 'module', 'itemid' => $cmid, 'message' => 'No access rights in module context', 'warningcode' => '1');
continue;
}
// Check if the user has managegradingforms capability.
$isgradingmethodmanager = false;
if (has_capability('moodle/grade:managegradingforms', $context)) {
$isgradingmethodmanager = true;
}
$module = get_coursemodule_from_id('', $cmid, 0, false, MUST_EXIST);
$componentname = "mod_" . $module->modname;
// Get the grading manager.
$gradingmanager = get_grading_manager($context, $componentname, $params['areaname']);
// Get the controller for each grading method.
$methods = array();
if ($params['activeonly'] == true) {
$methods[] = $gradingmanager->get_active_method();
} else {
$methods = array_keys($gradingmanager->get_available_methods(false));
}
$area = array();
$area['cmid'] = $cmid;
$area['contextid'] = $context->id;
$area['component'] = $componentname;
$area['activemethod'] = $gradingmanager->get_active_method();
$area['definitions'] = array();
foreach ($methods as $method) {
$controller = $gradingmanager->get_controller($method);
$def = $controller->get_definition(true);
if ($def == false) {
continue;
}
if ($isgradingmethodmanager == false) {
$isviewable = true;
if ($def->status != gradingform_controller::DEFINITION_STATUS_READY) {
$warnings[] = array('item' => 'module', 'itemid' => $cmid, 'message' => 'Capability moodle/grade:managegradingforms required to view draft definitions', 'warningcode' => '1');
$isviewable = false;
}
if (!empty($def->options)) {
$options = json_decode($def->options);
if (isset($options->alwaysshowdefinition) && $options->alwaysshowdefinition == 0) {
$warnings[] = array('item' => 'module', 'itemid' => $cmid, 'message' => 'Capability moodle/grade:managegradingforms required to preview definition', 'warningcode' => '1');
$isviewable = false;
}
}
if ($isviewable == false) {
continue;
}
}
$definition = array();
$definition['id'] = $def->id;
$definition['method'] = $method;
$definition['name'] = $def->name;
$definition['description'] = $def->description;
$definition['descriptionformat'] = $def->descriptionformat;
$definition['status'] = $def->status;
$definition['copiedfromid'] = $def->copiedfromid;
$definition['timecreated'] = $def->timecreated;
$definition['usercreated'] = $def->usercreated;
$definition['timemodified'] = $def->timemodified;
$definition['usermodified'] = $def->usermodified;
$definition['timecopied'] = $def->timecopied;
// Format the description text field.
$formattedtext = external_format_text($definition['description'], $definition['descriptionformat'], $context->id, $componentname, 'description', $def->id);
$definition['description'] = $formattedtext[0];
$definition['descriptionformat'] = $formattedtext[1];
$details = $controller->get_external_definition_details();
$items = array();
foreach ($details as $key => $value) {
$items[$key] = self::format_text($def->{$key}, $context->id, $componentname, $def->id);
}
$definition[$method] = $items;
$area['definitions'][] = $definition;
}
$areas[] = $area;
}
$result = array('areas' => $areas, 'warnings' => $warnings);
return $result;
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:98,代码来源:externallib.php
示例5: delete_all_for_context
/**
* Removes all data associated with the given context
*
* This is called by {@link context::delete_content()}
*
* @param int $contextid context id
*/
public static function delete_all_for_context($contextid)
{
global $DB;
$areaids = $DB->get_fieldset_select('grading_areas', 'id', 'contextid = ?', array($contextid));
$methods = array_keys(self::available_methods(false));
foreach ($areaids as $areaid) {
$manager = get_grading_manager($areaid);
foreach ($methods as $method) {
$controller = $manager->get_controller($method);
$controller->delete_definition();
}
}
$DB->delete_records_list('grading_areas', 'id', $areaids);
}
开发者ID:evltuma,项目名称:moodle,代码行数:21,代码来源:lib.php
示例6: require_capability
}
// publish the form as a template
if (!empty($shareform)) {
require_capability('moodle/grade:sharegradingforms', context_system::instance());
$controller = $manager->get_controller($method);
$definition = $controller->get_definition();
if (!$confirmed) {
// let the user confirm they understand what they are doing (haha ;-)
echo $output->header();
echo $output->confirm(get_string('manageactionshareconfirm', 'core_grading', s($definition->name)), new moodle_url($PAGE->url, array('shareform' => $shareform, 'confirmed' => 1)), $PAGE->url);
echo $output->footer();
die;
} else {
require_sesskey();
$newareaid = $manager->create_shared_area($method);
$targetarea = get_grading_manager($newareaid);
$targetcontroller = $targetarea->get_controller($method);
$targetcontroller->update_definition($controller->get_definition_copy($targetcontroller));
$DB->set_field('grading_definitions', 'timecopied', time(), array('id' => $definition->id));
redirect(new moodle_url($PAGE->url, array('message' => get_string('manageactionsharedone', 'core_grading'))));
}
}
// delete the form definition
if (!empty($deleteform)) {
$controller = $manager->get_controller($method);
$definition = $controller->get_definition();
if (!$confirmed) {
// let the user confirm they understand the consequences (also known as WTF-effect)
echo $output->header();
echo $output->confirm(markdown_to_html(get_string('manageactiondeleteconfirm', 'core_grading', array('formname' => s($definition->name), 'component' => $manager->get_component_title(), 'area' => $manager->get_area_title()))), new moodle_url($PAGE->url, array('deleteform' => $deleteform, 'confirmed' => 1)), $PAGE->url);
echo $output->footer();
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:manage.php
示例7: get_mform_data_object
/**
* Prepares the data for the grading form.
*
* @param $course
* @param $assignment
* @param $submission
* @param $user
* @param $coursemodule
* @param assignment_base $assignmentinstance
* @global $USER
* @global $CFG
* @return array
*/
private function get_mform_data_object($course, $assignment, $submission, $user, $coursemodule, $assignmentinstance)
{
global $USER, $CFG;
$context = context_module::instance($coursemodule->id);
// Get grading information to see whether we should be allowed to make changed at all.
$grading_info = grade_get_grades($course->id, 'mod', 'assignment', $assignment->id, array($user->id));
$locked = $grading_info->items[0]->grades[$user->id]->locked;
$overridden = $grading_info->items[0]->grades[$user->id]->overridden;
$gradingdisabled = $locked || $overridden;
$mformdata = new stdClass();
$mformdata->context = $context;
$mformdata->maxbytes = $course->maxbytes;
$mformdata->courseid = $course->id;
$mformdata->teacher = $USER;
$mformdata->assignment = $assignment;
$mformdata->submission = $submission;
$mformdata->lateness = assignment_display_lateness($submission->timemodified, $assignment->timedue);
$mformdata->user = $user;
$mformdata->offset = false;
$mformdata->userid = $user->id;
$mformdata->cm = $coursemodule;
$mformdata->grading_info = $grading_info;
$mformdata->enableoutcomes = $CFG->enableoutcomes;
$mformdata->grade = $assignment->grade;
$mformdata->gradingdisabled = $gradingdisabled;
// TODO set nextid to the nextnode id.
$mformdata->nextid = false;
$mformdata->submissioncomment = $submission->submissioncomment;
$mformdata->submissioncommentformat = FORMAT_HTML;
$mformdata->submission_content = $assignmentinstance->print_user_files($user->id, true);
if ($assignment->assignmenttype == 'upload') {
$mformdata->fileui_options = array('subdirs' => 1, 'maxbytes' => $assignment->maxbytes, 'maxfiles' => $assignment->var1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
} else {
if ($assignment->assignmenttype == 'uploadsingle') {
$mformdata->fileui_options = array('subdirs' => 0, 'maxbytes' => $CFG->userquota, 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
}
}
$advancedgradingwarning = false;
$gradingmanager = get_grading_manager($context, 'mod_assignment', 'submission');
if ($gradingmethod = $gradingmanager->get_active_method()) {
// This returns a gradingform_controller instance, not grading_controller as docs
// say.
/* @var gradingform_controller $controller */
$controller = $gradingmanager->get_controller($gradingmethod);
if ($controller->is_form_available()) {
$itemid = null;
if (!empty($submission->id)) {
$itemid = $submission->id;
}
if ($gradingdisabled && $itemid) {
$mformdata->advancedgradinginstance = $controller->get_current_instance($USER->id, $itemid);
return array($mformdata, $advancedgradingwarning);
} else {
if (!$gradingdisabled) {
$instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
$mformdata->advancedgradinginstance = $controller->get_or_create_instance($instanceid, $USER->id, $itemid);
return array($mformdata, $advancedgradingwarning);
}
}
return array($mformdata, $advancedgradingwarning);
} else {
$advancedgradingwarning = $controller->form_unavailable_notification();
return array($mformdata, $advancedgradingwarning);
}
}
return array($mformdata, $advancedgradingwarning);
}
开发者ID:nadavkav,项目名称:moodle-block_ajax_marking,代码行数:80,代码来源:block_ajax_marking_assignment.class.php
示例8: view_feedback
function view_feedback($submission=NULL) {
global $USER, $CFG, $DB, $OUTPUT, $PAGE;
require_once($CFG->libdir.'/gradelib.php');
require_once("$CFG->dirroot/grade/grading/lib.php");
if (!$submission) { /// Get submission for this assignment
$userid = $USER->id;
$submission = $this->get_submission($userid);
} else {
$userid = $submission->userid;
}
// Check the user can submit
$canviewfeedback = ($userid == $USER->id && has_capability('mod/assignment:submit', $this->context, $USER->id, false));
// If not then check if the user still has the view cap and has a previous submission
$canviewfeedback = $canviewfeedback || (!empty($submission) && $submission->userid == $USER->id && has_capability('mod/assignment:view', $this->context));
// Or if user can grade (is a teacher or admin)
$canviewfeedback = $canviewfeedback || has_capability('mod/assignment:grade', $this->context);
if (!$canviewfeedback) {
// can not view or submit assignments -> no feedback
return;
}
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $userid);
$item = $grading_info->items[0];
$grade = $item->grades[$userid];
if ($grade->hidden or $grade->grade === false) { // hidden or error
return;
}
if ($grade->grade === null and empty($grade->str_feedback)) { // No grade to show yet
if ($this->count_responsefiles($userid)) { // but possibly response files are present
echo $OUTPUT->heading(get_string('responsefiles', 'assignment'), 3);
$responsefiles = $this->print_responsefiles($userid, true);
echo $OUTPUT->box($responsefiles, 'generalbox boxaligncenter');
}
return;
}
$graded_date = $grade->dategraded;
$graded_by = $grade->usermodified;
/// We need the teacher info
if (!$teacher = $DB->get_record('user', array('id'=>$graded_by))) {
print_error('cannotfindteacher');
}
/// Print the feedback
echo $OUTPUT->heading(get_string('submissionfeedback', 'assignment'), 3);
echo '<table cellspacing="0" class="feedback">';
echo '<tr>';
echo '<td class="left picture">';
echo $OUTPUT->user_picture($teacher);
echo '</td>';
echo '<td class="topic">';
echo '<div class="from">';
echo '<div class="fullname">'.fullname($teacher).'</div>';
echo '<div class="time">'.userdate($graded_date).'</div>';
echo '</div>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="left side"> </td>';
echo '<td class="content">';
$gradestr = '<div class="grade">'. get_string("grade").': '.$grade->str_long_grade. '</div>';
if (!empty($submission) && $controller = get_grading_manager($this->context, 'mod_assignment', 'submission')->get_active_controller()) {
$controller->set_grade_range(make_grades_menu($this->assignment->grade));
echo $controller->render_grade($PAGE, $submission->id, $item, $gradestr, has_capability('mod/assignment:grade', $this->context));
} else {
echo $gradestr;
}
echo '<div class="clearer"></div>';
echo '<div class="comment">';
echo $grade->str_feedback;
echo '</div>';
echo '</tr>';
echo '<tr>';
echo '<td class="left side"> </td>';
echo '<td class="content">';
echo $this->print_responsefiles($userid, true);
echo '</tr>';
echo '</table>';
}
开发者ID:JP-Git,项目名称:moodle,代码行数:91,代码来源:assignment.class.php
示例9: get_pass_ratio
function get_pass_ratio($cmid, $emarkingid, $extracategory, $ids)
{
global $DB, $CFG;
if (!($emarking = $DB->get_record('emarking', array('id' => $emarkingid)))) {
print_error('Prueba inválida');
}
if (!($cm = get_coursemodule_from_id('emarking', $cmid))) {
print_error('Módulo inválido');
}
// Validate course
if (!($course = $DB->get_record('course', array('id' => $emarking->course)))) {
print_error('Curso inválido');
}
// Getting context
$context = context_module::instance($cmid);
$emarkingids = '' . $emarking->id;
// check for parallel courses
if ($CFG->emarking_parallelregex) {
$parallels = emarking_get_parallel_courses($course, $extracategory, $CFG->emarking_parallelregex);
} else {
$parallels = false;
}
// Form that lets you choose if you want to add to the report the other courses
$emarkingsform = new emarking_gradereport_form(null, array('course' => $course, 'cm' => $cm, 'parallels' => $parallels, 'id' => $emarkingids));
// Get the IDs from the parallel courses
$totalemarkings = 1;
if ($parallels && count($parallels) > 0) {
foreach ($parallels as $pcourse) {
$assid = '';
if ($emarkingsform->get_data() && property_exists($emarkingsform->get_data(), "emarkingid_{$pcourse->id}")) {
eval("\$assid = \$emarkingsform->get_data()->emarkingid_{$pcourse->id};");
if ($assid > 0) {
$emarkingids .= ',' . $assid;
$totalemarkings++;
}
}
}
}
// counts the total of disticts categories
$sqlcats = "select count(distinct(c.category)) as categories\n\tfrom {emarking} as a\n\tinner join {course} as c on (a.course = c.id)\n\twhere a.id in ({$emarkingids})";
$totalcategories = $DB->count_records_sql($sqlcats);
// Get the grading manager, then method and finally controller
$gradingmanager = get_grading_manager($context, 'mod_emarking', 'attempt');
$gradingmethod = $gradingmanager->get_active_method();
$rubriccontroller = $gradingmanager->get_controller($gradingmethod);
$definition = $rubriccontroller->get_definition();
// Search for stats regardig the exames (eg: max, min, number of students,etc)
$sql = "select *,\n\tcase\n\twhen categoryid is null then 'TOTAL'\n\twhen emarkingid is null then concat('SUBTOTAL ', categoryname)\n\telse coursename\n\tend as seriesname\n\tfrom (\n\tselect \tcategoryid as categoryid,\n\tcategoryname,\n\temarkingid as emarkingid,\n\tmodulename,\n\tcoursename,\n\tcount(*) as students,\n\tsum(pass) as pass,\n\tround((sum(pass) / count(*)) * 100,2) as pass_ratio,\n\tSUBSTRING_INDEX(\n\tSUBSTRING_INDEX(\n\tgroup_concat(grade order by grade separator ',')\n\t, ','\n\t, 25/100 * COUNT(*) + 1)\n\t, ','\n\t, -1\n\t) as percentile_25,\n\tSUBSTRING_INDEX(\n\tSUBSTRING_INDEX(\n\tgroup_concat(grade order by grade separator ',')\n\t, ','\n\t, 50/100 * COUNT(*) + 1)\n\t, ','\n\t, -1\n\t) as percentile_50,\n\tSUBSTRING_INDEX(\n\tSUBSTRING_INDEX(\n\tgroup_concat(grade order by grade separator ',')\n\t, ','\n\t, 75/100 * COUNT(*) + 1)\n\t, ','\n\t, -1\n\t) as percentile_75,\n\tmin(grade) as minimum,\n\tmax(grade) as maximum,\n\tround(avg(grade),2) as average,\n\tround(stddev(grade),2) as stdev,\n\tsum(histogram_01) as histogram_1,\n\tsum(histogram_02) as histogram_2,\n\tsum(histogram_03) as histogram_3,\n\tsum(histogram_04) as histogram_4,\n\tsum(histogram_05) as histogram_5,\n\tsum(histogram_06) as histogram_6,\n\tsum(histogram_07) as histogram_7,\n\tsum(histogram_08) as histogram_8,\n\tsum(histogram_09) as histogram_9,\n\tsum(histogram_10) as histogram_10,\n\tsum(histogram_11) as histogram_11,\n\tsum(histogram_12) as histogram_12,\n\tround(sum(rank_1)/count(*),3) as rank_1,\n\tround(sum(rank_2)/count(*),3) as rank_2,\n\tround(sum(rank_3)/count(*),3) as rank_3,\n\tmin(mingrade) as mingradeemarking,\n\tmin(maxgrade) as maxgradeemarking\n\tfrom (\n\tselect\n\tround(ss.grade,2) as grade, -- Nota final (calculada o manual via calificador)\n\ti.grademax as maxgrade, -- Nota máxima del emarking\n\ti.grademin as mingrade, -- Nota mínima del emarking\n\tcase when ss.grade is null then 0 -- Indicador de si la nota es null\n\telse 1\n\tend as attended,\n\tcase when ss.grade >= i.gradepass then 1\n\telse 0\n\tend as pass,\n\tcase when ss.grade >= 0 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 1 then 1 else 0 end as histogram_01,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 1 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 2 then 1 else 0 end as histogram_02,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 2 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 3 then 1 else 0 end as histogram_03,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 3 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 4 then 1 else 0 end as histogram_04,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 4 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 5 then 1 else 0 end as histogram_05,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 5 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 6 then 1 else 0 end as histogram_06,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 6 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 7 then 1 else 0 end as histogram_07,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 7 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 8 then 1 else 0 end as histogram_08,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 8 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 9 then 1 else 0 end as histogram_09,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 9 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 10 then 1 else 0 end as histogram_10,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 10 AND ss.grade < i.grademin + (i.grademax - i.grademin) / 12 * 11 then 1 else 0 end as histogram_11,\n\tcase when ss.grade >= i.grademin + (i.grademax - i.grademin) / 12 * 11 then 1 else 0 end as histogram_12,\n\tcase when ss.grade - i.grademin < (i.grademax - i.grademin) / 3 then 1 else 0 end as rank_1,\n\tcase when ss.grade - i.grademin >= (i.grademax - i.grademin) / 3 AND ss.grade - i.grademin < (i.grademax - i.grademin) / 2 then 1 else 0 end as rank_2,\n\tcase when ss.grade - i.grademin >= (i.grademax - i.grademin) / 2 then 1 else 0 end as rank_3,\n\tc.category as categoryid,\n\tcc.name as categoryname,\n\ti.iteminstance as emarkingid,\n\ta.name as modulename,\n\tc.fullname as coursename\n\tfrom {grade_items} as i\n\tinner join {emarking} as a on (i.itemtype = 'mod' AND i.itemmodule = 'emarking' and i.iteminstance in ( '.{$ids}.') AND i.iteminstance = a.id)\n\tinner join {course} as c on (i.courseid = c.id)\n\tinner join {course_categories} as cc on (c.category = cc.id)\n\tinner join {emarking_submission} as ss on (a.id = ss.emarking)\n\twhere ss.grade is not null AND ss.status >= 20\n\torder by emarkingid asc, ss.grade asc) as G\n\tgroup by categoryid, emarkingid\n\twith rollup) as T";
$emarkingstats = $DB->get_recordset_sql($sql);
$data = array();
foreach ($emarkingstats as $stats) {
if ($totalcategories == 1 && !strncmp($stats->seriesname, 'SUBTOTAL', 8)) {
continue;
}
if ($totalemarkings == 1 && !strncmp($stats->seriesname, 'TOTAL', 5)) {
continue;
}
$histogram_courses = '';
$histogram_totals = '';
$histograms = array();
$histograms_totals = array();
$histogramlabels = array();
if (!strncmp($stats->seriesname, 'SUBTOTAL', 8) || !strncmp($stats->seriesname, 'TOTAL', 5)) {
$histogram_totals .= "'{$stats->seriesname}',";
} else {
$histogram_courses .= "'{$stats->seriesname} (N={$stats->students})',";
}
for ($i = 1; $i <= 12; $i++) {
$histogramvalue = '';
eval("\$histogramvalue = \$stats->histogram_{$i};");
if (!strncmp($stats->seriesname, 'SUBTOTAL', 8) || !strncmp($stats->seriesname, 'TOTAL', 5)) {
if (!isset($histograms_totals[$i])) {
$histograms_totals[$i] = $histogramvalue . ',';
} else {
$histograms_totals[$i] .= $histogramvalue . ',';
}
} else {
if (!isset($histograms[$i])) {
$histograms[$i] = $histogramvalue . ',';
} else {
$histograms[$i] .= $histogramvalue . ',';
}
}
if ($i % 2 != 0) {
if ($i <= 6) {
$histogramlabels[$i] = '< ' . ($stats->mingradeemarking + ($stats->maxgradeemarking - $stats->mingradeemarking) / 12 * $i);
} else {
$histogramlabels[$i] = '>= ' . ($stats->mingradeemarking + ($stats->maxgradeemarking - $stats->mingradeemarking) / 12 * ($i - 1));
}
} else {
$histogramlabels[$i] = '';
}
}
$pass_ratio[] = array('seriesname' => $stats->seriesname . "(N=" . $stats->students . ")", 'rank1' => $stats->rank_1, 'rank2' => $stats->rank_2, 'rank3' => $stats->rank_3);
// "['$stats->seriesname (N=$stats->students)',$stats->rank_1,$stats->rank_2,$stats->rank_3],";
}
return $pass_ratio;
}
开发者ID:jorgecabane93,项目名称:eMarkingWeb,代码行数:98,代码来源:reportsquerylib.php
示例10: if
// move the new outcome into correct category and fix sortorder if needed
if ($grade_item) {
$outcome_item->set_parent($grade_item->categoryid);
$outcome_item->move_after_sortorder($grade_item->sortorder);
} else if (isset($fromform->gradecat)) {
$outcome_item->set_parent($fromform->gradecat);
}
}
}
}
if (plugin_supports('mod', $fromform->modulename, FEATURE_ADVANCED_GRADING, false)
and has_capability('moodle/grade:managegradingforms', $modcontext)) {
require_once($CFG->dirroot.'/grade/grading/lib.php');
$gradingman = get_grading_manager($modcontext, 'mod_'.$fromform->modulename);
$showgradingmanagement = false;
foreach ($gradingman->get_available_areas() as $areaname => $aretitle) {
$formfield = 'advancedgradingmethod_'.$areaname;
if (isset($fromform->{$formfield})) {
$gradingman->set_area($areaname);
$methodchanged = $gradingman->set_active_method($fromform->{$formfield});
if (empty($fromform->{$formfield})) {
// going back to the simple direct grading is not a reason
// to open the management screen
$methodchanged = false;
}
$showgradingmanagement = $showgradingmanagement || $methodchanged;
}
}
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:31,代码来源:modedit.php
示例11: get_user_grades_advanced
/**
* Returns the user's advanced grades for the specified grade item.
*
* @param grade_item $gradeitem
* @param array $userids The user ids whose grades should be retrieved.
* @return array|null
*/
protected function get_user_grades_advanced($gradeitem, array $userids)
{
// Users container.
$users = array_fill_keys($userids, array());
// Grades container.
$grades = array();
foreach ($users as $userid => $unused) {
$grades[$userid] = (object) array('id' => $userid, 'userid' => $userid, 'rawgrade' => null);
}
$areaname = $gradeitem->gradingarea;
$gradingman = get_grading_manager($df->context, 'mod_dataform', $areaname);
$controller = $gradingman->get_active_controller();
if (empty($controller)) {
return array();
}
// Now get the gradefordisplay.
$gradesmenu = make_grades_menu($gradeitem->grade);
$controller->set_grade_range($gradesmenu, $gradeitem->grade > 0);
$grade->gradefordisplay = $controller->render_grade($PAGE, $grade->id, $gradingitem, $grade->grade, $cangrade);
//} else {
// $grade->gradefordisplay = $this->display_grade($grade->grade, false);
//}
return $grades;
}
开发者ID:parksandwildlife,项目名称:learning,代码行数:31,代码来源:grade_manager.php
示例12: get_moduleinfo_data
/**
* Get module information data required for updating the module.
*
* @param stdClass $cm course module object
* @param stdClass $course course object
* @return array required data for updating a module
* @since Moodle 3.2
*/
function get_moduleinfo_data($cm, $course)
{
global $CFG;
list($cm, $context, $module, $data, $cw) = can_update_moduleinfo($cm);
$data->coursemodule = $cm->id;
$data->section = $cw->section;
// The section number itself - relative!!! (section column in course_sections)
$data->visible = $cm->visible;
//?? $cw->visible ? $cm->visible : 0; // section hiding overrides
$data->cmidnumber = $cm->idnumber;
// The cm IDnumber
$data->groupmode = groups_get_activity_groupmode($cm);
// locked later if forced
$data->groupingid = $cm->groupingid;
$data->course = $course->id;
$data->module = $module->id;
$data->modulename = $module->name;
$data->instance = $cm->instance;
$data->completion = $cm->completion;
$data->completionview = $cm->completionview;
$data->completionexpected = $cm->completionexpected;
$data->completionusegrade = is_null($cm->completiongradeitemnumber) ? 0 : 1;
$data->showdescription = $cm->showdescription;
$data->tags = core_tag_tag::get_item_tags_array('core', 'course_modules', $cm->id);
if (!empty($CFG->enableavailability)) {
$data->availabilityconditionsjson = $cm->availability;
}
if (plugin_supports('mod', $data->modulename, FEATURE_MOD_INTRO, true)) {
$draftid_editor = file_get_submitted_draft_itemid('introeditor');
$currentintro = file_prepare_draft_area($draftid_editor, $context->id, 'mod_' . $data->modulename, 'intro', 0, array('subdirs' => true), $data->intro);
$data->introeditor = array('text' => $currentintro, 'format' => $data->introformat, 'itemid' => $draftid_editor);
}
if (plugin_supports('mod', $data->modulename, FEATURE_ADVANCED_GRADING, false) and has_capability('moodle/grade:managegradingforms', $context)) {
require_once $CFG->dirroot . '/grade/grading/lib.php';
$gradingman = get_grading_manager($context, 'mod_' . $data->modulename);
$data->_advancedgradingdata['methods'] = $gradingman->get_available_methods();
$areas = $gradingman->get_available_areas();
foreach ($areas as $areaname => $areatitle) {
$gradingman->set_area($areaname);
$method = $gradingman->get_active_method();
$data->_advancedgradingdata['areas'][$areaname] = array('title' => $areatitle, 'method' => $method);
$formfield = 'advancedgradingmethod_' . $areaname;
$data->{$formfield} = $method;
}
}
if ($items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $data->modulename, 'iteminstance' => $data->instance, 'courseid' => $course->id))) {
// Add existing outcomes.
foreach ($items as $item) {
if (!empty($item->outcomeid)) {
$data->{'outcome_' . $item->outcomeid} = 1;
} else {
if (isset($item->gradepass)) {
$decimalpoints = $item->get_decimals();
$data->gradepass = format_float($item->gradepass, $decimalpoints);
}
}
}
// set category if present
$gradecat = false;
foreach ($items as $item) {
if ($gradecat === false) {
$gradecat = $item->categoryid;
continue;
}
if ($gradecat != $item->categoryid) {
//mixed categories
$gradecat = false;
break;
}
}
if ($gradecat !== false) {
// do not set if mixed categories present
$data->gradecat = $gradecat;
}
}
return array($cm, $context, $module, $data, $cw);
}
开发者ID:rajeshtaneja,项目名称:moodle,代码行数:85,代码来源:modlib.php
示例13: emarking_validate_rubric
/**
* Validates that there is a rubric set for the emarking activity. If there
* isn't it shows a message and optionally buttons to create or import a rubric.
* Optionally it will stop the page processing if no rubric is present.
*
* @param context $context
* emarking context
* @param boolean $die
* die if there is no rubric
* @param boolean $showrubricbuttons
* show buttons to create and import rubric
* @return multitype:unknown list($gradingmanager, $gradingmethod, $definition,
* $rubriccontroller)
*/
function emarking_validate_rubric(context $context, $die, $showrubricbuttons)
{
global $OUTPUT, $CFG, $COURSE;
require_once $CFG->dirroot . '/grade/grading/lib.php';
// Get rubric instance.
$gradingmanager = get_grading_manager($context, 'mod_emarking', 'attempt');
$gradingmethod = $gradingmanager->get_active_method();
$definition = null;
$rubriccontroller = null;
if ($gradingmethod !== 'rubric') {
$gradingmanager->set_active_method('rubric');
$gradingmethod = $gradingmanager->get_active_method();
}
$rubriccontroller = $gradingmanager->get_controller($gradingmethod);
$definition = $rubriccontroller->get_definition();
$managerubricurl = $gradingmanager->get_management_url();
$importrubricurl = new moodle_url("/mod/emarking/marking/importrubric.php", array("id" => $context->instanceid));
// Validate that activity has a rubric ready.
if ($gradingmethod !== 'rubric' || !$definition || $definition == null) {
if ($showrubricbuttons) {
echo $OUTPUT->notification(get_string('rubricneeded', 'mod_emarking'), 'notifyproblem');
if (has_capability("mod/emarking:addinstance", $context)) {
echo "<table>";
echo "<tr><td>" . $OUTPUT->single_button($managerubricurl, get_string('createrubric', 'mod_emarking'), "GET") . "</td>";
echo "<td>" . $OUTPUT->single_button($importrubricurl, get_string('importrubric', 'mod_emarking'), "GET") . "</td></tr>";
echo "</table>";
}
}
if ($die) {
echo $OUTPUT->footer();
die;
}
}
if (isset($definition->status)) {
if ($definition->status == 10) {
echo $OUTPUT->notification(get_string('rubricdraft', 'mod_emarking'), 'notifyproblem');
if (has_capability("mod/emarking:addinstance", $context)) {
echo $OUTPUT->single_button($managerubricurl, get_string('completerubric', 'mod_emarking'));
}
}
}
return array($gradingmanager, $gradingmethod, $definition, $rubriccontroller);
}
开发者ID:sikeze,项目名称:emarking,代码行数:57,代码来源:locallib.php
示例14: get_gradingform_instances
/**
* Returns the instances and fillings for the requested definition id
*
* @param int $definitionid
* @param int $since only return instances with timemodified >= since
* @return array of grading instances with fillings for the definition id
* @since Moodle 2.6
*/
public static function get_gradingform_instances($definitionid, $since = 0)
{
global $DB, $CFG;
require_once "{$CFG->dirroot}/grade/grading/form/lib.php";
$params = self::validate_parameters(self::get_gradingform_instances_parameters(), array('definitionid' => $definitionid, 'since' => $since));
$instances = array();
$warnings = array();
$definition = $DB->get_record('grading_definitions', array('id' => $params['definitionid']), 'areaid,method', MUST_EXIST);
$area = $DB->get_record('grading_areas', array('id' => $definition->areaid), 'contextid,component', MUST_EXIST);
$context = context::instance_by_id($area->contextid);
require_capability('moodle/grade:managegradingforms', $context);
$gradingmanager = get_grading_manager($definition->areaid);
$controller = $gradingmanager->get_controller($definition->method);
$activeinstances = $controller->get_all_active_instances($params['since']);
$details = $controller->get_external_instance_filling_details();
if ($details == null) {
$warnings[] = array('item' => 'definition', 'itemid' => $params['definitionid'], 'message' => 'Fillings unavailable because get_external_instance_filling_details is not defined', 'warningcode' => '1');
}
$getfilling = null;
if (method_exists('gradingform_' . $definition->method . '_instance', 'get_' . $definition->method . '_filling')) {
$getfilling = 'get_' . $definition->method . '_filling';
} else {
$warnings[] = array('item' => 'definition', 'itemid' => $params['definitionid'], 'message' => 'Fillings unavailable because get_' . $definition->method . '_filling is not defined', 'warningcode' => '1');
}
foreach ($activeinstances as $activeinstance) {
$instance = array();
$instance['id'] = $activeinstance->get_id();
$instance['raterid'] = $activeinstance->get_data('raterid');
$instance['itemid'] = $activeinstance->get_data('itemid');
$instance['rawgrade'] = $activeinstance->get_data('rawgrade');
$instance['status'] = $activeinstance->get_data('status');
$instance['feedback'] = $activeinstance->get_data('feedback');
$instance['feedbackformat'] = $activeinstance->get_data('feedbackformat');
// Format the feedback text field.
$formattedtext = external_format_text($activeinstance->get_data('feedback'), $activeinstance->get_data('feedbackformat'), $context->id, $area->component, 'feedback', $params['definitionid']);
$instance['feedback'] = $formattedtext[0];
$instance['feedbackformat'] = $formattedtext[1];
$instance['timemodified'] = $activeinstance->get_data('timemodified');
if ($details != null && $getfilling != null) {
$fillingdata = $activeinstance->{$getfilling}();
$filling = array();
foreach ($details as $key => $value) {
$filling[$key] = self::format_text($fillingdata[$key], $context->id, $area->component, $params['definitionid']);
}
$instance[$definition->method] = $filling;
}
$instances[] = $instance;
}
$result = array('instances' => $instances, 'warnings' => $warnings);
return $result;
}
开发者ID:EmmanuelYupit,项目名 |
请发表评论