コード例 #1
0
ファイル: locallib.php プロジェクト: covex-nn/moodle
 /**
  * View the grading table of all submissions for this assignment.
  *
  * @return string
  */
 protected function view_grading_table()
 {
     global $USER, $CFG;
     // Include grading options form.
     require_once $CFG->dirroot . '/mod/assign/gradingoptionsform.php';
     require_once $CFG->dirroot . '/mod/assign/quickgradingform.php';
     require_once $CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php';
     $o = '';
     $cmid = $this->get_course_module()->id;
     $links = array();
     if (has_capability('gradereport/grader:view', $this->get_course_context()) && has_capability('moodle/grade:viewall', $this->get_course_context())) {
         $gradebookurl = '/grade/report/grader/index.php?id=' . $this->get_course()->id;
         $links[$gradebookurl] = get_string('viewgradebook', 'assign');
     }
     if ($this->is_any_submission_plugin_enabled() && $this->count_submissions()) {
         $downloadurl = '/mod/assign/view.php?id=' . $cmid . '&action=downloadall';
         $links[$downloadurl] = get_string('downloadall', 'assign');
     }
     if ($this->is_blind_marking() && has_capability('mod/assign:revealidentities', $this->get_context())) {
         $revealidentitiesurl = '/mod/assign/view.php?id=' . $cmid . '&action=revealidentities';
         $links[$revealidentitiesurl] = get_string('revealidentities', 'assign');
     }
     foreach ($this->get_feedback_plugins() as $plugin) {
         if ($plugin->is_enabled() && $plugin->is_visible()) {
             foreach ($plugin->get_grading_actions() as $action => $description) {
                 $url = '/mod/assign/view.php' . '?id=' . $cmid . '&plugin=' . $plugin->get_type() . '&pluginsubtype=assignfeedback' . '&action=viewpluginpage&pluginaction=' . $action;
                 $links[$url] = $description;
             }
         }
     }
     // Sort links alphabetically based on the link description.
     core_collator::asort($links);
     $gradingactions = new url_select($links);
     $gradingactions->set_label(get_string('choosegradingaction', 'assign'));
     $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
     $perpage = get_user_preferences('assign_perpage', 10);
     $filter = get_user_preferences('assign_filter', '');
     $markerfilter = get_user_preferences('assign_markerfilter', '');
     $workflowfilter = get_user_preferences('assign_workflowfilter', '');
     $controller = $gradingmanager->get_active_controller();
     $showquickgrading = empty($controller);
     $quickgrading = get_user_preferences('assign_quickgrading', false);
     $showonlyactiveenrolopt = has_capability('moodle/course:viewsuspendedusers', $this->context);
     $markingallocation = $this->get_instance()->markingallocation && has_capability('mod/assign:manageallocations', $this->context);
     // Get markers to use in drop lists.
     $markingallocationoptions = array();
     if ($markingallocation) {
         $markers = get_users_by_capability($this->context, 'mod/assign:grade');
         $markingallocationoptions[''] = get_string('filternone', 'assign');
         foreach ($markers as $marker) {
             $markingallocationoptions[$marker->id] = fullname($marker);
         }
     }
     $markingworkflow = $this->get_instance()->markingworkflow;
     // Get marking states to show in form.
     $markingworkflowoptions = array();
     if ($markingworkflow) {
         $notmarked = get_string('markingworkflowstatenotmarked', 'assign');
         $markingworkflowoptions[''] = get_string('filternone', 'assign');
         $markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = $notmarked;
         $markingworkflowoptions = array_merge($markingworkflowoptions, $this->get_marking_workflow_states_for_current_user());
     }
     // Print options for changing the filter and changing the number of results per page.
     $gradingoptionsformparams = array('cm' => $cmid, 'contextid' => $this->context->id, 'userid' => $USER->id, 'submissionsenabled' => $this->is_any_submission_plugin_enabled(), 'showquickgrading' => $showquickgrading, 'quickgrading' => $quickgrading, 'markingworkflowopt' => $markingworkflowoptions, 'markingallocationopt' => $markingallocationoptions, 'showonlyactiveenrolopt' => $showonlyactiveenrolopt, 'showonlyactiveenrol' => $this->show_only_active_users());
     $classoptions = array('class' => 'gradingoptionsform');
     $gradingoptionsform = new mod_assign_grading_options_form(null, $gradingoptionsformparams, 'post', '', $classoptions);
     $batchformparams = array('cm' => $cmid, 'submissiondrafts' => $this->get_instance()->submissiondrafts, 'duedate' => $this->get_instance()->duedate, 'attemptreopenmethod' => $this->get_instance()->attemptreopenmethod, 'feedbackplugins' => $this->get_feedback_plugins(), 'context' => $this->get_context(), 'markingworkflow' => $markingworkflow, 'markingallocation' => $markingallocation);
     $classoptions = array('class' => 'gradingbatchoperationsform');
     $gradingbatchoperationsform = new mod_assign_grading_batch_operations_form(null, $batchformparams, 'post', '', $classoptions);
     $gradingoptionsdata = new stdClass();
     $gradingoptionsdata->perpage = $perpage;
     $gradingoptionsdata->filter = $filter;
     $gradingoptionsdata->markerfilter = $markerfilter;
     $gradingoptionsdata->workflowfilter = $workflowfilter;
     $gradingoptionsform->set_data($gradingoptionsdata);
     $actionformtext = $this->get_renderer()->render($gradingactions);
     $header = new assign_header($this->get_instance(), $this->get_context(), false, $this->get_course_module()->id, get_string('grading', 'assign'), $actionformtext);
     $o .= $this->get_renderer()->render($header);
     $currenturl = $CFG->wwwroot . '/mod/assign/view.php?id=' . $this->get_course_module()->id . '&action=grading';
     $o .= groups_print_activity_menu($this->get_course_module(), $currenturl, true);
     // Plagiarism update status apearring in the grading book.
     if (!empty($CFG->enableplagiarism)) {
         require_once $CFG->libdir . '/plagiarismlib.php';
         $o .= plagiarism_update_status($this->get_course(), $this->get_course_module());
     }
     // Load and print the table of submissions.
     if ($showquickgrading && $quickgrading) {
         $gradingtable = new assign_grading_table($this, $perpage, $filter, 0, true);
         $table = $this->get_renderer()->render($gradingtable);
         $quickformparams = array('cm' => $this->get_course_module()->id, 'gradingtable' => $table);
         $quickgradingform = new mod_assign_quick_grading_form(null, $quickformparams);
         $o .= $this->get_renderer()->render(new assign_form('quickgradingform', $quickgradingform));
     } else {
         $gradingtable = new assign_grading_table($this, $perpage, $filter, 0, false);
         $o .= $this->get_renderer()->render($gradingtable);
     }
     $currentgroup = groups_get_activity_group($this->get_course_module(), true);
     $users = array_keys($this->list_participants($currentgroup, true));
     if (count($users) != 0) {
         // If no enrolled user in a course then don't display the batch operations feature.
         $assignform = new assign_form('gradingbatchoperationsform', $gradingbatchoperationsform);
         $o .= $this->get_renderer()->render($assignform);
     }
     $assignform = new assign_form('gradingoptionsform', $gradingoptionsform, 'M.mod_assign.init_grading_options');
     $o .= $this->get_renderer()->render($assignform);
     return $o;
 }
コード例 #2
0
ファイル: lib.php プロジェクト: EmmanuelYupit/educursos
/**
 * Print grading plugin selection popup form.
 *
 * @param array   $plugin_info An array of plugins containing information for the selector
 * @param boolean $return return as string
 *
 * @return nothing or string if $return true
 */
function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return = false)
{
    global $CFG, $OUTPUT, $PAGE;
    $menu = array();
    $count = 0;
    $active = '';
    foreach ($plugin_info as $plugin_type => $plugins) {
        if ($plugin_type == 'strings') {
            continue;
        }
        $first_plugin = reset($plugins);
        $sectionname = $plugin_info['strings'][$plugin_type];
        $section = array();
        foreach ($plugins as $plugin) {
            $link = $plugin->link->out(false);
            $section[$link] = $plugin->string;
            $count++;
            if ($plugin_type === $active_type and $plugin->id === $active_plugin) {
                $active = $link;
            }
        }
        if ($section) {
            $menu[] = array($sectionname => $section);
        }
    }
    // finally print/return the popup form
    if ($count > 1) {
        $select = new url_select($menu, $active, null, 'choosepluginreport');
        $select->set_label(get_string('gradereport', 'grades'), array('class' => 'accesshide'));
        if ($return) {
            return $OUTPUT->render($select);
        } else {
            echo $OUTPUT->render($select);
        }
    } else {
        // only one option - no plugin selector needed
        return '';
    }
}
コード例 #3
0
ファイル: deprecatedlib.php プロジェクト: nuckey/moodle
/**
 * Implements a complete little form with a dropdown menu.
 *
 * @deprecated since Moodle 2.0
 *
 * When JavaScript is on selecting an option from the dropdown automatically
 * submits the form (while avoiding the usual acessibility problems with this appoach).
 * With JavaScript off, a 'Go' button is printed.
 *
 * @global object
 * @global object
 * @param string $baseurl The target URL up to the point of the variable that changes
 * @param array $options A list of value-label pairs for the popup list
 * @param string $formid id for the control. Must be unique on the page. Used in the HTML.
 * @param string $selected The option that is initially selected
 * @param string $nothing The label for the "no choice" option
 * @param string $help The name of a help page if help is required
 * @param string $helptext The name of the label for the help button
 * @param boolean $return Indicates whether the function should return the HTML
 *         as a string or echo it directly to the page being rendered
 * @param string $targetwindow The name of the target page to open the linked page in.
 * @param string $selectlabel Text to place in a [label] element - preferred for accessibility.
 * @param array $optionsextra an array with the same keys as $options. The values are added within the corresponding <option ...> tag.
 * @param string $submitvalue Optional label for the 'Go' button. Defaults to get_string('go').
 * @param boolean $disabled If true, the menu will be displayed disabled.
 * @param boolean $showbutton If true, the button will always be shown even if JavaScript is available
 * @return string|void If $return=true returns string, else echo's and returns void
 */
function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false,
    $targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false, $showbutton=false) {
    global $OUTPUT, $CFG;

    debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->single_select() or $OUTPUT->url_select().');

    if (empty($options)) {
        return '';
    }

    $urls = array();

    foreach ($options as $value=>$label) {
        $url = $baseurl.$value;
        $url = str_replace($CFG->wwwroot, '', $url);
        $url = str_replace('&amp;', '&', $url);
        $urls[$url] = $label;
        if ($selected == $value) {
            $active = $url;
        }
    }

    $nothing = $nothing ? array(''=>$nothing) : null;

    $select = new url_select($urls, $active, $nothing, $formid);
    $select->disabled = $disabled;

    $select->set_label($selectlabel);
    $select->set_old_help_icon($help, $helptext);

    $output = $OUTPUT->render($select);

    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #4
0
ファイル: lib.php プロジェクト: numbas/moodle
/**
 * Prints the menus to add activities and resources.
 */
function print_section_add_menus($course, $section, $modnames, $vertical = false, $return = false)
{
    global $CFG, $OUTPUT;
    // check to see if user can add menus
    if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
        return false;
    }
    // Retrieve all modules with associated metadata
    $modules = get_module_metadata($course, $modnames);
    // We'll sort resources and activities into two lists
    $resources = array();
    $activities = array();
    // We need to add the section section to the link for each module
    $sectionlink = '&section=' . $section;
    foreach ($modules as $module) {
        if (isset($module->types)) {
            // This module has a subtype
            // NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
            $subtypes = array();
            foreach ($module->types as $subtype) {
                $subtypes[$subtype->link . $sectionlink] = $subtype->title;
            }
            // Sort module subtypes into the list
            if (!empty($module->title)) {
                // This grouping has a name
                if ($module->archetype == MOD_CLASS_RESOURCE) {
                    $resources[] = array($module->title => $subtypes);
                } else {
                    $activities[] = array($module->title => $subtypes);
                }
            } else {
                // This grouping does not have a name
                if ($module->archetype == MOD_CLASS_RESOURCE) {
                    $resources = array_merge($resources, $subtypes);
                } else {
                    $activities = array_merge($activities, $subtypes);
                }
            }
        } else {
            // This module has no subtypes
            if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
                $resources[$module->link . $sectionlink] = $module->title;
            } else {
                if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
                    // System modules cannot be added by user, do not add to dropdown
                } else {
                    $activities[$module->link . $sectionlink] = $module->title;
                }
            }
        }
    }
    $straddactivity = get_string('addactivity');
    $straddresource = get_string('addresource');
    $output = '<div class="section_add_menus">';
    if (!$vertical) {
        $output .= '<div class="horizontal">';
    }
    if (!empty($resources)) {
        $select = new url_select($resources, '', array('' => $straddresource), "ressection{$section}");
        $select->set_help_icon('resources');
        $output .= $OUTPUT->render($select);
    }
    if (!empty($activities)) {
        $select = new url_select($activities, '', array('' => $straddactivity), "section{$section}");
        $select->set_help_icon('activities');
        $output .= $OUTPUT->render($select);
    }
    if (!$vertical) {
        $output .= '</div>';
    }
    $output .= '</div>';
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #5
0
ファイル: instances.php プロジェクト: JP-Git/moodle
                    // plugin specific state - do not mess with it!
                    $edit[] = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/show'), 'alt' => '', 'class' => 'smallicon'));
                }
            }
        }
    }
    // link to instance management
    if (enrol_is_enabled($instance->enrol)) {
        if ($icons = $plugin->get_action_icons($instance)) {
            $edit = array_merge($edit, $icons);
        }
    }
    // add a row to the table
    $table->data[] = array($displayname, $users, implode('&nbsp;', $updown), implode('&nbsp;', $edit));
}
echo html_writer::table($table);
// access security is in each plugin
$candidates = array();
foreach (enrol_get_plugins(true) as $name => $plugin) {
    if (!($link = $plugin->get_newinstance_link($course->id))) {
        continue;
    }
    $candidates[$link->out(false)] = get_string('pluginname', 'enrol_' . $name);
}
if ($candidates) {
    $select = new url_select($candidates);
    $select->set_label(get_string('addinstance', 'enrol'));
    echo $OUTPUT->render($select);
}
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
コード例 #6
0
ファイル: renderer.php プロジェクト: rushi963/moodle
 /**
  * Renders HTML for the menus to add activities and resources to the current course
  *
  * Note, if theme overwrites this function and it does not use modchooser,
  * see also {@link core_course_renderer::add_modchoosertoggle()}
  *
  * @param stdClass $course
  * @param int $section relative section number (field course_sections.section)
  * @param int $sectionreturn The section to link back to
  * @param array $displayoptions additional display options, for example blocks add
  *     option 'inblock' => true, suggesting to display controls vertically
  * @return string
  */
 function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = array())
 {
     global $CFG;
     $vertical = !empty($displayoptions['inblock']);
     // check to see if user can add menus and there are modules to add
     if (!has_capability('moodle/course:manageactivities', context_course::instance($course->id)) || !$this->page->user_is_editing() || !($modnames = get_module_types_names()) || empty($modnames)) {
         return '';
     }
     // Retrieve all modules with associated metadata
     $modules = get_module_metadata($course, $modnames, $sectionreturn);
     $urlparams = array('section' => $section);
     // We'll sort resources and activities into two lists
     $activities = array(MOD_CLASS_ACTIVITY => array(), MOD_CLASS_RESOURCE => array());
     foreach ($modules as $module) {
         if (isset($module->types)) {
             // This module has a subtype
             // NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
             $subtypes = array();
             foreach ($module->types as $subtype) {
                 $link = $subtype->link->out(true, $urlparams);
                 $subtypes[$link] = $subtype->title;
             }
             // Sort module subtypes into the list
             $activityclass = MOD_CLASS_ACTIVITY;
             if ($module->archetype == MOD_CLASS_RESOURCE) {
                 $activityclass = MOD_CLASS_RESOURCE;
             }
             if (!empty($module->title)) {
                 // This grouping has a name
                 $activities[$activityclass][] = array($module->title => $subtypes);
             } else {
                 // This grouping does not have a name
                 $activities[$activityclass] = array_merge($activities[$activityclass], $subtypes);
             }
         } else {
             // This module has no subtypes
             $activityclass = MOD_CLASS_ACTIVITY;
             if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
                 $activityclass = MOD_CLASS_RESOURCE;
             } else {
                 if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
                     // System modules cannot be added by user, do not add to dropdown
                     continue;
                 }
             }
             $link = $module->link->out(true, $urlparams);
             $activities[$activityclass][$link] = $module->title;
         }
     }
     $straddactivity = get_string('addactivity');
     $straddresource = get_string('addresource');
     $sectionname = get_section_name($course, $section);
     $strresourcelabel = get_string('addresourcetosection', null, $sectionname);
     $stractivitylabel = get_string('addactivitytosection', null, $sectionname);
     $output = html_writer::start_tag('div', array('class' => 'section_add_menus', 'id' => 'add_menus-section-' . $section));
     if (!$vertical) {
         $output .= html_writer::start_tag('div', array('class' => 'horizontal'));
     }
     if (!empty($activities[MOD_CLASS_RESOURCE])) {
         $select = new url_select($activities[MOD_CLASS_RESOURCE], '', array('' => $straddresource), "ressection{$section}");
         $select->set_help_icon('resources');
         $select->set_label($strresourcelabel, array('class' => 'accesshide'));
         $output .= $this->output->render($select);
     }
     if (!empty($activities[MOD_CLASS_ACTIVITY])) {
         $select = new url_select($activities[MOD_CLASS_ACTIVITY], '', array('' => $straddactivity), "section{$section}");
         $select->set_help_icon('activities');
         $select->set_label($stractivitylabel, array('class' => 'accesshide'));
         $output .= $this->output->render($select);
     }
     if (!$vertical) {
         $output .= html_writer::end_tag('div');
     }
     $output .= html_writer::end_tag('div');
     if (course_ajax_enabled($course) && $course->id == $this->page->course->id) {
         // modchooser can be added only for the current course set on the page!
         $straddeither = get_string('addresourceoractivity');
         // The module chooser link
         $modchooser = html_writer::start_tag('div', array('class' => 'mdl-right'));
         $modchooser .= html_writer::start_tag('div', array('class' => 'section-modchooser'));
         $icon = $this->output->pix_icon('t/add', '');
         $span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));
         $modchooser .= html_writer::tag('span', $icon . $span, array('class' => 'section-modchooser-link'));
         $modchooser .= html_writer::end_tag('div');
         $modchooser .= html_writer::end_tag('div');
         // Wrap the normal output in a noscript div
         $usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault);
         if ($usemodchooser) {
             $output = html_writer::tag('div', $output, array('class' => 'hiddenifjs addresourcedropdown'));
             $modchooser = html_writer::tag('div', $modchooser, array('class' => 'visibleifjs addresourcemodchooser'));
         } else {
             // If the module chooser is disabled, we need to ensure that the dropdowns are shown even if javascript is disabled
             $output = html_writer::tag('div', $output, array('class' => 'show addresourcedropdown'));
             $modchooser = html_writer::tag('div', $modchooser, array('class' => 'hide addresourcemodchooser'));
         }
         $output = $this->course_modchooser($modules, $course) . $modchooser . $output;
     }
     return $output;
 }
コード例 #7
0
ファイル: lib.php プロジェクト: hitphp/moodle
/**
 * Prints the menus to add activities and resources.
 */
function print_section_add_menus($course, $section, $modnames, $vertical = false, $return = false)
{
    global $CFG, $OUTPUT;
    // check to see if user can add menus
    if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
        return false;
    }
    $urlbase = "/course/mod.php?id={$course->id}&section={$section}&sesskey=" . sesskey() . '&add=';
    $resources = array();
    $activities = array();
    foreach ($modnames as $modname => $modnamestr) {
        if (!course_allowed_module($course, $modname)) {
            continue;
        }
        $libfile = "{$CFG->dirroot}/mod/{$modname}/lib.php";
        if (!file_exists($libfile)) {
            continue;
        }
        include_once $libfile;
        $gettypesfunc = $modname . '_get_types';
        if (function_exists($gettypesfunc)) {
            // NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
            if ($types = $gettypesfunc()) {
                $menu = array();
                $atype = null;
                $groupname = null;
                foreach ($types as $type) {
                    if ($type->typestr === '--') {
                        continue;
                    }
                    if (strpos($type->typestr, '--') === 0) {
                        $groupname = str_replace('--', '', $type->typestr);
                        continue;
                    }
                    $type->type = str_replace('&amp;', '&', $type->type);
                    if ($type->modclass == MOD_CLASS_RESOURCE) {
                        $atype = MOD_CLASS_RESOURCE;
                    }
                    $menu[$urlbase . $type->type] = $type->typestr;
                }
                if (!is_null($groupname)) {
                    if ($atype == MOD_CLASS_RESOURCE) {
                        $resources[] = array($groupname => $menu);
                    } else {
                        $activities[] = array($groupname => $menu);
                    }
                } else {
                    if ($atype == MOD_CLASS_RESOURCE) {
                        $resources = array_merge($resources, $menu);
                    } else {
                        $activities = array_merge($activities, $menu);
                    }
                }
            }
        } else {
            $archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
            if ($archetype == MOD_ARCHETYPE_RESOURCE) {
                $resources[$urlbase . $modname] = $modnamestr;
            } else {
                // all other archetypes are considered activity
                $activities[$urlbase . $modname] = $modnamestr;
            }
        }
    }
    $straddactivity = get_string('addactivity');
    $straddresource = get_string('addresource');
    $output = '<div class="section_add_menus">';
    if (!$vertical) {
        $output .= '<div class="horizontal">';
    }
    if (!empty($resources)) {
        $select = new url_select($resources, '', array('' => $straddresource), "ressection{$section}");
        $select->set_help_icon('resources');
        $output .= $OUTPUT->render($select);
    }
    if (!empty($activities)) {
        $select = new url_select($activities, '', array('' => $straddactivity), "section{$section}");
        $select->set_help_icon('activities');
        $output .= $OUTPUT->render($select);
    }
    if (!$vertical) {
        $output .= '</div>';
    }
    $output .= '</div>';
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #8
0
ファイル: lib.php プロジェクト: nmicha/moodle
/**
 * Prints the menus to add activities and resources.
 */
function print_section_add_menus($course, $section, $modnames, $vertical = false, $return = false)
{
    global $CFG, $OUTPUT;
    // check to see if user can add menus
    if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
        return false;
    }
    // Retrieve all modules with associated metadata
    $modules = get_module_metadata($course, $modnames);
    // We'll sort resources and activities into two lists
    $resources = array();
    $activities = array();
    // We need to add the section section to the link for each module
    $sectionlink = '&section=' . $section;
    foreach ($modules as $module) {
        if (isset($module->types)) {
            // This module has a subtype
            // NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
            $subtypes = array();
            foreach ($module->types as $subtype) {
                $subtypes[$subtype->link . $sectionlink] = $subtype->title;
            }
            // Sort module subtypes into the list
            if (!empty($module->title)) {
                // This grouping has a name
                if ($module->archetype == MOD_CLASS_RESOURCE) {
                    $resources[] = array($module->title => $subtypes);
                } else {
                    $activities[] = array($module->title => $subtypes);
                }
            } else {
                // This grouping does not have a name
                if ($module->archetype == MOD_CLASS_RESOURCE) {
                    $resources = array_merge($resources, $subtypes);
                } else {
                    $activities = array_merge($activities, $subtypes);
                }
            }
        } else {
            // This module has no subtypes
            if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
                $resources[$module->link . $sectionlink] = $module->title;
            } else {
                if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
                    // System modules cannot be added by user, do not add to dropdown
                } else {
                    $activities[$module->link . $sectionlink] = $module->title;
                }
            }
        }
    }
    $straddactivity = get_string('addactivity');
    $straddresource = get_string('addresource');
    $output = html_writer::start_tag('div', array('class' => 'section_add_menus', 'id' => 'add_menus-section-' . $section));
    if (!$vertical) {
        $output .= html_writer::start_tag('div', array('class' => 'horizontal'));
    }
    if (!empty($resources)) {
        $select = new url_select($resources, '', array('' => $straddresource), "ressection{$section}");
        $select->set_help_icon('resources');
        $output .= $OUTPUT->render($select);
    }
    if (!empty($activities)) {
        $select = new url_select($activities, '', array('' => $straddactivity), "section{$section}");
        $select->set_help_icon('activities');
        $output .= $OUTPUT->render($select);
    }
    if (!$vertical) {
        $output .= html_writer::end_tag('div');
    }
    $output .= html_writer::end_tag('div');
    if (course_ajax_enabled($course)) {
        $straddeither = get_string('addresourceoractivity');
        // The module chooser link
        $modchooser = html_writer::start_tag('div', array('class' => 'mdl-right'));
        $modchooser .= html_writer::start_tag('div', array('class' => 'section-modchooser'));
        $icon = $OUTPUT->pix_icon('t/add', $straddeither);
        $span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));
        $modchooser .= html_writer::link('#', $icon . $span, array('class' => 'section-modchooser-link'));
        $modchooser .= html_writer::end_tag('div');
        $modchooser .= html_writer::end_tag('div');
        // Wrap the normal output in a noscript div
        $usemodchooser = get_user_preferences('usemodchooser', 1);
        if ($usemodchooser) {
            $output = html_writer::tag('div', $output, array('class' => 'hiddenifjs addresourcedropdown'));
            $modchooser = html_writer::tag('div', $modchooser, array('class' => 'visibleifjs addresourcemodchooser'));
        } else {
            $output = html_writer::tag('div', $output, array('class' => 'visibleifjs addresourcedropdown'));
            $modchooser = html_writer::tag('div', $modchooser, array('class' => 'hiddenifjs addresourcemodchooser'));
        }
        $output = $modchooser . $output;
    }
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #9
0
ファイル: renderer.php プロジェクト: bgao-ca/moodle-local_mr
 /**
  * Render mr_file_export
  *
  * @param mr_file_export $export mr_file_export instance
  * @return string
  */
 protected function render_mr_file_export(mr_file_export $export)
 {
     $select = new url_select($export->get_url_select_options(), '');
     $select->set_label(get_string('export', 'local_mr'));
     return html_writer::tag('div', $this->output->render($select), array('class' => 'mr_file_export'));
 }
コード例 #10
0
 /**
  * View the grading table of all submissions for this assignment
  *
  * @return string
  */
 private function view_grading_table()
 {
     global $USER, $CFG;
     // Include grading options form
     require_once $CFG->dirroot . '/mod/assign/gradingoptionsform.php';
     require_once $CFG->dirroot . '/mod/assign/quickgradingform.php';
     require_once $CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php';
     $o = '';
     $links = array();
     if (has_capability('gradereport/grader:view', $this->get_course_context()) && has_capability('moodle/grade:viewall', $this->get_course_context())) {
         $gradebookurl = '/grade/report/grader/index.php?id=' . $this->get_course()->id;
         $links[$gradebookurl] = get_string('viewgradebook', 'assign');
     }
     if ($this->is_any_submission_plugin_enabled()) {
         $downloadurl = '/mod/assign/view.php?id=' . $this->get_course_module()->id . '&action=downloadall';
         $links[$downloadurl] = get_string('downloadall', 'assign');
     }
     $gradingactions = new url_select($links);
     $gradingactions->set_label(get_string('choosegradingaction', 'assign'));
     $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
     $perpage = get_user_preferences('assign_perpage', 10);
     $filter = get_user_preferences('assign_filter', '');
     $controller = $gradingmanager->get_active_controller();
     $showquickgrading = empty($controller);
     if (optional_param('action', '', PARAM_ALPHA) == 'saveoptions') {
         $quickgrading = optional_param('quickgrading', false, PARAM_BOOL);
         set_user_preference('assign_quickgrading', $quickgrading);
     }
     $quickgrading = get_user_preferences('assign_quickgrading', false);
     // print options  for changing the filter and changing the number of results per page
     $gradingoptionsform = new mod_assign_grading_options_form(null, array('cm' => $this->get_course_module()->id, 'contextid' => $this->context->id, 'userid' => $USER->id, 'submissionsenabled' => $this->is_any_submission_plugin_enabled(), 'showquickgrading' => $showquickgrading, 'quickgrading' => $quickgrading), 'post', '', array('class' => 'gradingoptionsform'));
     $gradingbatchoperationsform = new mod_assign_grading_batch_operations_form(null, array('cm' => $this->get_course_module()->id, 'submissiondrafts' => $this->get_instance()->submissiondrafts), 'post', '', array('class' => 'gradingbatchoperationsform'));
     $gradingoptionsdata = new stdClass();
     $gradingoptionsdata->perpage = $perpage;
     $gradingoptionsdata->filter = $filter;
     $gradingoptionsform->set_data($gradingoptionsdata);
     $actionformtext = $this->output->render($gradingactions);
     $o .= $this->output->render(new assign_header($this->get_instance(), $this->get_context(), false, $this->get_course_module()->id, get_string('grading', 'assign'), $actionformtext));
     $o .= groups_print_activity_menu($this->get_course_module(), $CFG->wwwroot . '/mod/assign/view.php?id=' . $this->get_course_module()->id . '&action=grading', true);
     // plagiarism update status apearring in the grading book
     if (!empty($CFG->enableplagiarism)) {
         /** Include plagiarismlib.php */
         require_once $CFG->libdir . '/plagiarismlib.php';
         $o .= plagiarism_update_status($this->get_course(), $this->get_course_module());
     }
     // load and print the table of submissions
     if ($showquickgrading && $quickgrading) {
         $table = $this->output->render(new assign_grading_table($this, $perpage, $filter, 0, true));
         $quickgradingform = new mod_assign_quick_grading_form(null, array('cm' => $this->get_course_module()->id, 'gradingtable' => $table));
         $o .= $this->output->render(new assign_form('quickgradingform', $quickgradingform));
     } else {
         $o .= $this->output->render(new assign_grading_table($this, $perpage, $filter, 0, false));
     }
     $currentgroup = groups_get_activity_group($this->get_course_module(), true);
     $users = array_keys($this->list_participants($currentgroup, true));
     if (count($users) != 0) {
         // if no enrolled user in a course then don't display the batch operations feature
         $o .= $this->output->render(new assign_form('gradingbatchoperationsform', $gradingbatchoperationsform));
     }
     $o .= $this->output->render(new assign_form('gradingoptionsform', $gradingoptionsform, 'M.mod_assign.init_grading_options'));
     return $o;
 }
コード例 #11
0
ファイル: outputrenderers.php プロジェクト: stronk7/moodle
 /**
  * Internal implementation of url_select rendering
  *
  * @param url_select $select
  * @return string HTML fragment
  */
 protected function render_url_select(url_select $select)
 {
     return $this->render_from_template('core/url_select', $select->export_for_template($this));
 }
コード例 #12
0
ファイル: lib.php プロジェクト: sirromas/lms
/**
 * Print grading plugin selection popup form.
 *
 * @param array   $plugin_info An array of plugins containing information for the selector
 * @param boolean $return return as string
 *
 * @return nothing or string if $return true
 */
function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return = false)
{
    global $CFG, $OUTPUT, $PAGE;
    $menu = array();
    $count = 0;
    $active = '';
    //echo "<pre>";
    //print_r($plugin_info);
    //echo "</pre>";
    foreach ($plugin_info as $plugin_type => $plugins) {
        if ($plugin_type == 'strings' || $plugin_type == 'history' || $plugin_type == 'outcomes' || $plugin_type == 'user') {
            continue;
        }
        $first_plugin = reset($plugins);
        $sectionname = $plugin_info['strings'][$plugin_type];
        $section = array();
        //echo "<pre>";
        //print_r($plugins);
        //echo "</pre>";
        foreach ($plugins as $plugin) {
            //echo "$plugin->string: <br>";
            if ($plugin->string != 'Grade history' && $plugin->string != 'Outcomes report' && $plugin->string != 'User report' && $plugin->string != 'Preferences: Grader report' && $plugin->string != 'OpenDocument spreadsheet' && $plugin->string != 'XML file') {
                $link = $plugin->link->out(false);
                $section[$link] = $plugin->string;
                $count++;
                if ($plugin_type === $active_type and $plugin->id === $active_plugin) {
                    $active = $link;
                }
            }
        }
        if ($section) {
            $menu[] = array($sectionname => $section);
        }
    }
    // finally print/return the popup form
    if ($count > 1) {
        $select = new url_select($menu, $active, null, 'choosepluginreport');
        $select->set_label(get_string('gradereport', 'grades'), array('class' => 'accesshide'));
        if ($return) {
            return $OUTPUT->render($select);
        } else {
            echo $OUTPUT->render($select);
        }
    } else {
        // only one option - no plugin selector needed
        return '';
    }
}
コード例 #13
0
/**
 * Get an object with details of individual activity
 * @param $cm
 * @param $urlroot
 * @param $oublog
 * @param $currentgroup
 * @param $context
 * @return an object
 */
function oublog_individual_get_activity_details($cm, $urlroot, $oublog, $currentgroup, $context)
{
    global $CFG, $USER, $SESSION, $OUTPUT;
    if (strpos($urlroot, 'http') !== 0) {
        // Will also work for https
        debugging('oublog_print_individual_activity_menu requires absolute URL for ' . '$urlroot, not <tt>' . s($urlroot) . '</tt>. Example: ' . 'oublog_print_individual_activity_menu($cm, $CFG->wwwroot . \'/mod/mymodule/view.php?id=13\');', DEBUG_DEVELOPER);
    }
    // get groupmode and individualmode
    $groupmode = oublog_get_activity_groupmode($cm);
    $individualmode = $oublog->individual;
    // No individual blogs.
    if ($individualmode == OUBLOG_NO_INDIVIDUAL_BLOGS) {
        return '';
    }
    // If no groups or 'all groups' selection' ($currentgroup == 0).
    if ($groupmode == NOGROUPS || $currentgroup == 0) {
        // Visible individual.
        if ($individualmode == OUBLOG_VISIBLE_INDIVIDUAL_BLOGS) {
            $allowedindividuals = oublog_individual_get_all_users($cm->course, $cm->instance);
        }
        // Separate individual (check capability of present user.
        if ($individualmode == OUBLOG_SEPARATE_INDIVIDUAL_BLOGS) {
            $allowedindividuals = oublog_individual_get_all_users($cm->course, $cm->instance, 0, $context);
        }
    }
    // If a group is selected ($currentgroup > 0).
    if ($currentgroup > 0) {
        // Visible individual.
        if ($individualmode == OUBLOG_VISIBLE_INDIVIDUAL_BLOGS) {
            $allowedindividuals = oublog_individual_get_all_users($cm->course, $cm->instance, $currentgroup);
        }
        // Separate individual.
        if ($individualmode == OUBLOG_SEPARATE_INDIVIDUAL_BLOGS) {
            $allowedindividuals = oublog_individual_get_all_users($cm->course, $cm->instance, $currentgroup, $context);
        }
    }
    $activeindividual = oublog_individual_get_active_user($allowedindividuals, $individualmode, true);
    // Setup the drop-down menu.
    $menu = array();
    if (count($allowedindividuals) > 1) {
        if ($currentgroup > 0) {
            // Selected group.
            $menu[0] = get_string('viewallusersingroup', 'oublog');
        } else {
            // No groups or all groups.
            $menu[0] = get_string('viewallusers', 'oublog');
        }
    }
    if ($allowedindividuals) {
        foreach ($allowedindividuals as $user) {
            $menu[$user->id] = format_string($user->firstname . ' ' . $user->lastname);
        }
    }
    if ($individualmode == OUBLOG_VISIBLE_INDIVIDUAL_BLOGS) {
        $label = get_string('visibleindividual', 'oublog') . '&nbsp;';
    } else {
        $label = get_string('separateindividual', 'oublog') . '&nbsp;';
    }
    $output = "";
    if (count($menu) == 1) {
        $name = reset($menu);
        $output = $label . ':&nbsp;' . $name;
    } else {
        $active = '';
        foreach ($menu as $value => $item) {
            $url = $urlroot . '&amp;individual=' . $value;
            $url = str_replace($CFG->wwwroot, '', $url);
            $url = str_replace('&amp;', '&', $url);
            $urls[$url] = $item;
            if ($activeindividual == $value) {
                $active = $url;
            }
        }
        if (!empty($urls)) {
            $select = new url_select($urls, $active, null, 'selectindividual');
            $select->set_label($label);
            $output = $OUTPUT->render($select);
        }
    }
    $output = '<div class="oublog-individualselector">' . $output . '</div>';
    // Set up the object details needed.
    $individualdetails = new stdClass();
    $individualdetails->display = $output;
    $individualdetails->activeindividual = $activeindividual;
    $individualdetails->mode = $individualmode;
    $individualdetails->userids = array_keys($allowedindividuals);
    $individualdetails->newblogpost = true;
    // Hid the "New blog post" button.
    if ($activeindividual == 0 && !array_key_exists($USER->id, $allowedindividuals) || $activeindividual > 0 && $activeindividual != $USER->id) {
        $individualdetails->newblogpost = false;
    }
    return $individualdetails;
}
コード例 #14
0
}
//Menu for groups
if ($groupmode) {
    groups_print_activity_menu($cm, $groups_url);
}
//Print user selection by submission state
$url_base = $CFG->wwwroot . "/mod/vpl/views/submissionslist.php?id={$id}&sort={$sort}&group={$group}&selection=";
$urlindex = vpl_select_index($url_base, array('all', 'allsubmissions', 'notgraded', 'graded', 'gradedbyuser'));
$urls = array_merge(array($url_base . 'all' => get_string('all')), vpl_select_array($url_base, array('allsubmissions', 'notgraded', 'graded', 'gradedbyuser')));
$url_sel = new url_select($urls, $urlindex[$subselection]);
$url_sel->set_label(get_string('submissionselection', VPL));
echo $OUTPUT->render($url_sel);
if (($gradeable || $vpl->get_instance()->evaluate) && $subselection != 'notgraded') {
    $url_base = $CFG->wwwroot . "/mod/vpl/views/submissionslist.php?id={$id}&sort={$sort}&sortdir={$sortdir}&selection={$subselection}&evaluate=";
    $urls = array(0 => null, 2 => $url_base . '2', '3' => $url_base . '3', 4 => $url_base . '4');
    $url_sel = new url_select(array($urls[2] => get_string('notexecuted', VPL), $urls[3] => get_string('notgraded', VPL), $urls[4] => get_string('all')), $urls[$evaluate]);
    $url_sel->set_label(get_string('evaluate', VPL));
    echo $OUTPUT->render($url_sel);
}
echo '<br />';
@ob_flush();
flush();
echo html_writer::table($table);
if (count($ngrades) > 0) {
    echo '<br />';
    echo html_writer::table($tablegraders);
}
//Generate next info as <div id="submissionid">nextuser</div>
if (count($next_ids)) {
    //Hide info
    echo '<div style="display:none;">';
コード例 #15
0
ファイル: locallib.php プロジェクト: Burick/moodle
    /**
     * View the grading table of all submissions for this assignment.
     *
     * @return string
     */
    protected function view_grading_table() {
        global $USER, $CFG;

        // Include grading options form.
        require_once($CFG->dirroot . '/mod/assign/gradingoptionsform.php');
        require_once($CFG->dirroot . '/mod/assign/quickgradingform.php');
        require_once($CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php');
        $o = '';
        $cmid = $this->get_course_module()->id;

        $links = array();
        if (has_capability('gradereport/grader:view', $this->get_course_context()) &&
                has_capability('moodle/grade:viewall', $this->get_course_context())) {
            $gradebookurl = '/grade/report/grader/index.php?id=' . $this->get_course()->id;
            $links[$gradebookurl] = get_string('viewgradebook', 'assign');
        }
        if ($this->is_any_submission_plugin_enabled() && $this->count_submissions()) {
            $downloadurl = '/mod/assign/view.php?id=' . $cmid . '&action=downloadall';
            $links[$downloadurl] = get_string('downloadall', 'assign');
        }
        if ($this->is_blind_marking() &&
                has_capability('mod/assign:revealidentities', $this->get_context())) {
            $revealidentitiesurl = '/mod/assign/view.php?id=' . $cmid . '&action=revealidentities';
            $links[$revealidentitiesurl] = get_string('revealidentities', 'assign');
        }
        foreach ($this->get_feedback_plugins() as $plugin) {
            if ($plugin->is_enabled() && $plugin->is_visible()) {
                foreach ($plugin->get_grading_actions() as $action => $description) {
                    $url = '/mod/assign/view.php' .
                           '?id=' .  $cmid .
                           '&plugin=' . $plugin->get_type() .
                           '&pluginsubtype=assignfeedback' .
                           '&action=viewpluginpage&pluginaction=' . $action;
                    $links[$url] = $description;
                }
            }
        }

        $gradingactions = new url_select($links);
        $gradingactions->set_label(get_string('choosegradingaction', 'assign'));

        $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');

        $perpage = get_user_preferences('assign_perpage', 10);
        $filter = get_user_preferences('assign_filter', '');
        $controller = $gradingmanager->get_active_controller();
        $showquickgrading = empty($controller);
        if (optional_param('action', '', PARAM_ALPHA) == 'saveoptions') {
            $quickgrading = optional_param('quickgrading', false, PARAM_BOOL);
            set_user_preference('assign_quickgrading', $quickgrading);
        }
        $quickgrading = get_user_preferences('assign_quickgrading', false);

        // Print options for changing the filter and changing the number of results per page.
        $gradingoptionsformparams = array('cm'=>$cmid,
                                          'contextid'=>$this->context->id,
                                          'userid'=>$USER->id,
                                          'submissionsenabled'=>$this->is_any_submission_plugin_enabled(),
                                          'showquickgrading'=>$showquickgrading,
                                          'quickgrading'=>$quickgrading);

        $classoptions = array('class'=>'gradingoptionsform');
        $gradingoptionsform = new mod_assign_grading_options_form(null,
                                                                  $gradingoptionsformparams,
                                                                  'post',
                                                                  '',
                                                                  $classoptions);

        $batchformparams = array('cm'=>$cmid,
                                 'submissiondrafts'=>$this->get_instance()->submissiondrafts,
                                 'duedate'=>$this->get_instance()->duedate,
                                 'feedbackplugins'=>$this->get_feedback_plugins());
        $classoptions = array('class'=>'gradingbatchoperationsform');

        $gradingbatchoperationsform = new mod_assign_grading_batch_operations_form(null,
                                                                                   $batchformparams,
                                                                                   'post',
                                                                                   '',
                                                                                   $classoptions);

        $gradingoptionsdata = new stdClass();
        $gradingoptionsdata->perpage = $perpage;
        $gradingoptionsdata->filter = $filter;
        $gradingoptionsform->set_data($gradingoptionsdata);

        $actionformtext = $this->get_renderer()->render($gradingactions);
        $header = new assign_header($this->get_instance(),
                                    $this->get_context(),
                                    false,
                                    $this->get_course_module()->id,
                                    get_string('grading', 'assign'),
                                    $actionformtext);
        $o .= $this->get_renderer()->render($header);

        $currenturl = $CFG->wwwroot .
                      '/mod/assign/view.php?id=' .
                      $this->get_course_module()->id .
                      '&action=grading';

        $o .= groups_print_activity_menu($this->get_course_module(), $currenturl, true);

        // Plagiarism update status apearring in the grading book.
        if (!empty($CFG->enableplagiarism)) {
            require_once($CFG->libdir . '/plagiarismlib.php');
            $o .= plagiarism_update_status($this->get_course(), $this->get_course_module());
        }

        // Load and print the table of submissions.
        if ($showquickgrading && $quickgrading) {
            $gradingtable = new assign_grading_table($this, $perpage, $filter, 0, true);
            $table = $this->get_renderer()->render($gradingtable);
            $quickformparams = array('cm'=>$this->get_course_module()->id, 'gradingtable'=>$table);
            $quickgradingform = new mod_assign_quick_grading_form(null, $quickformparams);

            $o .= $this->get_renderer()->render(new assign_form('quickgradingform', $quickgradingform));
        } else {
            $gradingtable = new assign_grading_table($this, $perpage, $filter, 0, false);
            $o .= $this->get_renderer()->render($gradingtable);
        }

        $currentgroup = groups_get_activity_group($this->get_course_module(), true);
        $users = array_keys($this->list_participants($currentgroup, true));
        if (count($users) != 0) {
            // If no enrolled user in a course then don't display the batch operations feature.
            $assignform = new assign_form('gradingbatchoperationsform', $gradingbatchoperationsform);
            $o .= $this->get_renderer()->render($assignform);
        }
        $assignform = new assign_form('gradingoptionsform',
                                      $gradingoptionsform,
                                      'M.mod_assign.init_grading_options');
        $o .= $this->get_renderer()->render($assignform);
        return $o;
    }