示例#1
0
 /**
  * Set assign module specific test values for calling create_module().
  *
  * @param object $moduleinfo - the moduleinfo to add some specific values - passed in reference.
  */
 private function assign_create_set_values(&$moduleinfo)
 {
     // Specific values to the Assign module.
     $moduleinfo->alwaysshowdescription = true;
     $moduleinfo->submissiondrafts = true;
     $moduleinfo->requiresubmissionstatement = true;
     $moduleinfo->sendnotifications = true;
     $moduleinfo->sendlatenotifications = true;
     $moduleinfo->duedate = time() + 7 * 24 * 3600;
     $moduleinfo->cutoffdate = time() + 7 * 24 * 3600;
     $moduleinfo->allowsubmissionsfromdate = time();
     $moduleinfo->teamsubmission = true;
     $moduleinfo->requireallteammemberssubmit = true;
     $moduleinfo->teamsubmissiongroupingid = true;
     $moduleinfo->blindmarking = true;
     $moduleinfo->markingworkflow = true;
     $moduleinfo->markingallocation = true;
     $moduleinfo->assignsubmission_onlinetext_enabled = true;
     $moduleinfo->assignsubmission_file_enabled = true;
     $moduleinfo->assignsubmission_file_maxfiles = 1;
     $moduleinfo->assignsubmission_file_maxsizebytes = 1000000;
     $moduleinfo->assignsubmission_comments_enabled = true;
     $moduleinfo->assignfeedback_comments_enabled = true;
     $moduleinfo->assignfeedback_offline_enabled = true;
     $moduleinfo->assignfeedback_file_enabled = true;
     // Advanced grading.
     $gradingmethods = grading_manager::available_methods();
     $moduleinfo->advancedgradingmethod_submissions = current(array_keys($gradingmethods));
 }
 /**
  * Describes the parameters for save_grades
  * @return external_external_function_parameters
  * @since  Moodle 2.7
  */
 public static function save_grades_parameters()
 {
     global $CFG;
     require_once "{$CFG->dirroot}/mod/sepl/locallib.php";
     require_once "{$CFG->dirroot}/grade/grading/lib.php";
     $instance = new sepl(null, null, null);
     $pluginfeedbackparams = array();
     foreach ($instance->get_feedback_plugins() as $plugin) {
         $pluginparams = $plugin->get_external_parameters();
         if (!empty($pluginparams)) {
             $pluginfeedbackparams = array_merge($pluginfeedbackparams, $pluginparams);
         }
     }
     $advancedgradingdata = array();
     $methods = array_keys(grading_manager::available_methods(false));
     foreach ($methods as $method) {
         require_once $CFG->dirroot . '/grade/grading/form/' . $method . '/lib.php';
         $details = call_user_func('gradingform_' . $method . '_controller::get_external_instance_filling_details');
         if (!empty($details)) {
             $items = array();
             foreach ($details as $key => $value) {
                 $value->required = VALUE_OPTIONAL;
                 unset($value->content->keys['id']);
                 $items[$key] = new external_multiple_structure(new external_single_structure(array('criterionid' => new external_value(PARAM_INT, 'criterion id'), 'fillings' => $value)));
             }
             $advancedgradingdata[$method] = new external_single_structure($items, 'items', VALUE_OPTIONAL);
         }
     }
     return new external_function_parameters(array('seplmentid' => new external_value(PARAM_INT, 'The seplment id to operate on'), 'applytoall' => new external_value(PARAM_BOOL, 'If true, this grade will be applied ' . 'to all members ' . 'of the group (for group seplments).'), 'grades' => new external_multiple_structure(new external_single_structure(array('userid' => new external_value(PARAM_INT, 'The student id to operate on'), 'grade' => new external_value(PARAM_FLOAT, 'The new grade for this user. ' . 'Ignored if advanced grading used'), 'attemptnumber' => new external_value(PARAM_INT, 'The attempt number (-1 means latest attempt)'), 'addattempt' => new external_value(PARAM_BOOL, 'Allow another attempt if manual attempt reopen method'), 'workflowstate' => new external_value(PARAM_ALPHA, 'The next marking workflow state'), 'plugindata' => new external_single_structure($pluginfeedbackparams, 'plugin data', VALUE_DEFAULT, array()), 'advancedgradingdata' => new external_single_structure($advancedgradingdata, 'advanced grading data', VALUE_DEFAULT, array()))))));
 }
示例#3
0
 /**
  * @return array of available grading methods
  * @since Moodle 2.5
  */
 private static function get_grading_methods()
 {
     $methods = array_keys(grading_manager::available_methods(false));
     return $methods;
 }
示例#4
0
 $data->id = '';
 $data->instance = '';
 $data->coursemodule = '';
 $data->add = $add;
 $data->return = 0;
 //must be false if this is an add, go back to course view on cancel
 $data->sr = $sectionreturn;
 if (plugin_supports('mod', $data->modulename, FEATURE_MOD_INTRO, true)) {
     $draftid_editor = file_get_submitted_draft_itemid('introeditor');
     file_prepare_draft_area($draftid_editor, null, null, null, null, array('subdirs' => true));
     $data->introeditor = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => $draftid_editor);
     // TODO: add better default
 }
 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';
     $data->_advancedgradingdata['methods'] = grading_manager::available_methods();
     $areas = grading_manager::available_areas('mod_' . $module->name);
     foreach ($areas as $areaname => $areatitle) {
         $data->_advancedgradingdata['areas'][$areaname] = array('title' => $areatitle, 'method' => '');
         $formfield = 'advancedgradingmethod_' . $areaname;
         $data->{$formfield} = '';
     }
 }
 if (!empty($type)) {
     //TODO: hopefully will be removed in 2.0
     $data->type = $type;
 }
 $sectionname = get_section_name($course, $cw);
 $fullmodulename = get_string('modulename', $module->name);
 if ($data->section && $course->format != 'site') {
     $heading = new stdClass();
示例#5
0
/**
 * Prepare the standard module information for a new module instance.
 *
 * @param  stdClass $course  course object
 * @param  string $modulename  module name
 * @param  int $section section number
 * @return array module information about other required data
 * @since  Moodle 3.2
 */
function prepare_new_moduleinfo_data($course, $modulename, $section)
{
    global $CFG;
    list($module, $context, $cw) = can_add_moduleinfo($course, $modulename, $section);
    $cm = null;
    $data = new stdClass();
    $data->section = $section;
    // The section number itself - relative!!! (section column in course_sections)
    $data->visible = $cw->visible;
    $data->course = $course->id;
    $data->module = $module->id;
    $data->modulename = $module->name;
    $data->groupmode = $course->groupmode;
    $data->groupingid = $course->defaultgroupingid;
    $data->id = '';
    $data->instance = '';
    $data->coursemodule = '';
    if (plugin_supports('mod', $data->modulename, FEATURE_MOD_INTRO, true)) {
        $draftid_editor = file_get_submitted_draft_itemid('introeditor');
        file_prepare_draft_area($draftid_editor, null, null, null, null, array('subdirs' => true));
        $data->introeditor = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => $draftid_editor);
        // TODO: add better default
    }
    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';
        $data->_advancedgradingdata['methods'] = grading_manager::available_methods();
        $areas = grading_manager::available_areas('mod_' . $module->name);
        foreach ($areas as $areaname => $areatitle) {
            $data->_advancedgradingdata['areas'][$areaname] = array('title' => $areatitle, 'method' => '');
            $formfield = 'advancedgradingmethod_' . $areaname;
            $data->{$formfield} = '';
        }
    }
    return array($module, $context, $cw, $cm, $data);
}