Beispiel #1
0
/**
 * Callback function called from question_list() function (which is called from showbank())
 */
function module_specific_controls($totalnumber, $recurse, $category, $cmid)
{
    global $QTYPES;
    $out = '';
    $catcontext = get_context_instance_by_id($category->contextid);
    if (has_capability('moodle/question:useall', $catcontext)) {
        $randomusablequestions = $QTYPES['random']->get_usable_questions_from_category($category->id, $recurse, '0');
        $maxrand = count($randomusablequestions);
        if ($maxrand > 0) {
            for ($i = 1; $i <= min(10, $maxrand); $i++) {
                $randomcount[$i] = $i;
            }
            for ($i = 20; $i <= min(100, $maxrand); $i += 10) {
                $randomcount[$i] = $i;
            }
            $out .= '<br />';
            $out .= get_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true));
            $out .= '<input type="hidden" name="recurse" value="' . $recurse . '" />';
            $out .= '<input type="hidden" name="categoryid" value="' . $category->id . '" />';
            $out .= ' <input type="submit" name="addrandom" value="' . get_string('add') . '" />';
            $out .= helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, '', true);
        }
    }
    return $out;
}
 function display_search_field($content = '')
 {
     global $CFG;
     $varcharcontent = sql_compare_text('content', 255);
     $sql = "SELECT DISTINCT {$varcharcontent} AS content\n                  FROM {$CFG->prefix}data_content\n                 WHERE fieldid={$this->field->id} AND content IS NOT NULL";
     $usedoptions = array();
     if ($used = get_records_sql($sql)) {
         foreach ($used as $data) {
             $value = $data->content;
             if ($value === '') {
                 continue;
             }
             $usedoptions[$value] = $value;
         }
     }
     $options = array();
     foreach (explode("\n", $this->field->param1) as $option) {
         $option = trim($option);
         if (!isset($usedoptions[$option])) {
             continue;
         }
         $options[$option] = $option;
     }
     if (!$options) {
         // oh, nothing to search for
         return '';
     }
     return choose_from_menu($options, 'f_' . $this->field->id, stripslashes($content), 'choose', '', 0, true);
 }
 function display_add_field($recordid = 0)
 {
     global $CFG;
     $text = '';
     $format = 0;
     if ($recordid) {
         if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
             $text = $content->content;
             $format = $content->content1;
         }
     }
     $str = '<div title="' . $this->field->description . '">';
     if (can_use_richtext_editor()) {
         // Show a rich text html editor.
         $str .= $this->gen_textarea(true, $text);
         $str .= helpbutton("richtext", get_string("helprichtext"), 'moodle', true, true, '', true);
         $str .= '<input type="hidden" name="field_' . $this->field->id . '_content1' . '" value="' . FORMAT_HTML . '" />';
     } else {
         // Show a normal textarea. Also let the user specify the format to be used.
         $str .= $this->gen_textarea(false, $text);
         // Get the available text formats for this field.
         $formatsForField = format_text_menu();
         $str .= '<br />';
         $str .= choose_from_menu($formatsForField, 'field_' . $this->field->id . '_content1', $format, 'choose', '', '', true);
         $str .= helpbutton('textformat', get_string('helpformatting'), 'moodle', true, false, '', true);
     }
     $str .= '</div>';
     return $str;
 }
 function view($editable, $issueid = 0)
 {
     $this->getvalue($issueid);
     // loads $this->value with current value for this issue
     if ($editable) {
         if (!empty($this->options)) {
             foreach ($this->options as $option) {
                 $optionsmenu[$option->id] = format_string($option->description);
             }
             choose_from_menu($optionsmenu, "element{$this->name}", $this->value, 'choose');
         } else {
             echo "\t\t" . get_string('nooptions', 'tracker');
         }
     } else {
         if (isset($this->options)) {
             $optionstrs = array();
             foreach ($this->options as $option) {
                 if ($this->value != null) {
                     if ($this->value == $option->id) {
                         $optionstrs[] = format_string($option->description);
                     }
                 }
             }
             echo implode(', ', $optionstrs);
         }
     }
 }
 public function display($discussion)
 {
     // Obtain list of other forums in this course where the user has the
     // 'move discussion' feature
     $modinfo = get_fast_modinfo($discussion->get_forum()->get_course());
     $results = array();
     foreach ($modinfo->instances['forumng'] as $other) {
         // Don't let user move discussion to its current forum
         if ($other->instance == $discussion->get_forum()->get_id() || $other->id == $discussion->get_forum()->get_course_module_id()) {
             continue;
         }
         $othercontext = get_context_instance(CONTEXT_MODULE, $other->id);
         if (has_capability('mod/forumng:movediscussions', $othercontext)) {
             $results[$other->id] = $other->name;
         }
     }
     if (count($results) == 0) {
         return '';
     }
     // Make list alphabetical
     uasort($results, array('move_forum_feature', 'sort_ignore_case'));
     // Build select using the list
     $select = choose_from_menu($results, 'target', '', get_string('movethisdiscussionto', 'forumng'), '', 0, true);
     return '<form method="post" action="feature/move/move.php"><div>' . $discussion->get_link_params(forum::PARAM_FORM) . $select . '<input class="forumng-zero-disable" ' . 'type="submit" value="' . get_string('move') . '" /></div></form>';
 }
 function display_search_field($content = '')
 {
     global $CFG, $DB;
     $usedoptions = array();
     $sql = "SELECT DISTINCT content\n                  FROM {data_content}\n                 WHERE fieldid=: AND content IS NOT NULL";
     if ($used = $DB->get_records_sql($sql, array($this->field->id))) {
         foreach ($used as $data) {
             $value = $data->content;
             if ($value === '') {
                 continue;
             }
             $usedoptions[$value] = $value;
         }
     }
     $options = array();
     foreach (explode("\n", $this->field->param1) as $option) {
         $option = trim($option);
         if (!isset($usedoptions[$option])) {
             continue;
         }
         $options[$option] = $option;
     }
     if (!$options) {
         // oh, nothing to search for
         return '';
     }
     return choose_from_menu($options, 'f_' . $this->field->id, $content, '&nbsp;', '', 0, true);
 }
function sloodle_display_config_form($sloodleauthid, $auth_obj)
{
    //--------------------------------------------------------
    // SETUP
    // Determine which course is being accessed
    $courseid = $auth_obj->course->get_course_id();
    // We need to fetch a list of visible choices on the course
    // Get the ID of the choice type
    $rec = get_record('modules', 'name', 'choice');
    if (!$rec) {
        sloodle_debug("Failed to get choice module type.");
        exit;
    }
    $choicemoduleid = $rec->id;
    // Get all visible choices in the current course
    $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$choicemoduleid} AND visible = 1");
    if (!$recs) {
        error(get_string('nochoices', 'sloodle'));
        exit;
    }
    $choices = array();
    foreach ($recs as $cm) {
        // Fetch the choice instance
        $inst = get_record('choice', 'id', $cm->instance);
        if (!$inst) {
            continue;
        }
        // Store the choice details
        $choices[$cm->id] = $inst->name;
    }
    // Sort the list by name
    natcasesort($choices);
    //--------------------------------------------------------
    // FORM
    // Get the current object configuration
    $settings = SloodleController::get_object_configuration($sloodleauthid);
    // Setup our default values
    $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0);
    $sloodlerefreshtime = (int) sloodle_get_value($settings, 'sloodlerefreshtime', 600);
    $sloodlerelative = (int) sloodle_get_value($settings, 'sloodlerelative', 0);
    ///// GENERAL CONFIGURATION /////
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>';
    // Ask the user to select a choice
    echo get_string('selectchoice', 'sloodle') . ': ';
    choose_from_menu($choices, 'sloodlemoduleid', $sloodlemoduleid, '');
    echo "<br><br>\n";
    // Ask the user for a refresh period (# seconds between automatic updates)
    echo get_string('refreshtimeseconds', 'sloodle') . ': ';
    echo '<input type="text" name="sloodlerefreshtime" value="' . $sloodlerefreshtime . '" size="8" maxlength="8" />';
    echo "<br><br>\n";
    // Show relative results
    echo get_string('relativeresults', 'sloodle') . ': ';
    choose_from_menu_yesno('sloodlerelative', $sloodlerelative);
    echo "<br>\n";
    print_box_end();
    ///// ACCESS LEVELS /////
    sloodle_print_access_level_options($settings, true, false, true);
}
function sloodle_display_config_form($sloodleauthid, $auth_obj)
{
    //--------------------------------------------------------
    // SETUP
    // Determine which course is being accessed
    $courseid = $auth_obj->course->get_course_id();
    // We need to fetch a list of visible chatrooms on the course
    // Get the ID of the chat type
    $rec = get_record('modules', 'name', 'chat');
    if (!$rec) {
        sloodle_debug("Failed to get chatroom module type.");
        exit;
    }
    $chatmoduleid = $rec->id;
    // Get all visible chatrooms in the current course
    $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$chatmoduleid} AND visible = 1");
    if (!$recs) {
        error(get_string('nochatrooms', 'sloodle'));
        exit;
    }
    $chatrooms = array();
    foreach ($recs as $cm) {
        // Fetch the chatroom instance
        $inst = get_record('chat', 'id', $cm->instance);
        if (!$inst) {
            continue;
        }
        // Store the chatroom details
        $chatrooms[$cm->id] = $inst->name;
    }
    // Sort the list by name
    natcasesort($chatrooms);
    //--------------------------------------------------------
    // FORM
    // Get the current object configuration
    $settings = SloodleController::get_object_configuration($sloodleauthid);
    // Setup our default values
    $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0);
    $sloodlelistentoobjects = (int) sloodle_get_value($settings, 'sloodlelistentoobjects', 0);
    $sloodleautodeactivate = (int) sloodle_get_value($settings, 'sloodleautodeactivate', 1);
    ///// GENERAL CONFIGURATION /////
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>';
    // Ask the user to select a chatroom
    echo get_string('selectchatroom', 'sloodle') . ': ';
    choose_from_menu($chatrooms, 'sloodlemoduleid', $sloodlemoduleid, '');
    echo "<br><br>\n";
    // Listening to object chat
    echo get_string('listentoobjects', 'sloodle') . ': ';
    choose_from_menu_yesno('sloodlelistentoobjects', $sloodlelistentoobjects);
    echo "<br><br>\n";
    // Allowing auto-deactivation
    echo get_string('allowautodeactivation', 'sloodle') . ': ';
    choose_from_menu_yesno('sloodleautodeactivate', $sloodleautodeactivate);
    echo "<br>\n";
    print_box_end();
    ///// ACCESS LEVELS /////
    sloodle_print_access_level_options($settings);
}
function sloodle_display_config_form($sloodleauthid, $auth_obj)
{
    //--------------------------------------------------------
    // SETUP
    // Determine which course is being accessed
    $courseid = $auth_obj->course->get_course_id();
    // We need to fetch a list of visible Sloodle Object assignments on the course
    // Get the ID of the assignment type
    $rec = get_record('modules', 'name', 'assignment');
    if (!$rec) {
        sloodle_debug("Failed to get assignment module type.");
        exit;
    }
    $assignmentmoduleid = $rec->id;
    // Get all visible assignments in the current course
    $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$assignmentmoduleid} AND visible = 1");
    if (!$recs) {
        error(get_string('noassignments', 'sloodle'));
        exit;
    }
    $assignments = array();
    foreach ($recs as $cm) {
        // Fetch the assignment instance
        $inst = get_record('assignment', 'id', $cm->instance);
        if (!$inst) {
            continue;
        }
        // Ignore anything except Sloodle Object assignments
        if ($inst->assignmenttype != 'sloodleobject') {
            continue;
        }
        // Store the assignment details
        $assignments[$cm->id] = $inst->name;
    }
    // Make sure that we got some Sloodle Object assignments
    if (count($assignments) == 0) {
        error(get_string('nosloodleassignments', 'sloodle'));
        exit;
    }
    // Sort the list by name
    natcasesort($assignments);
    //--------------------------------------------------------
    // FORM
    // Get the current object configuration
    $settings = SloodleController::get_object_configuration($sloodleauthid);
    // Setup our default values
    $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0);
    ///// GENERAL CONFIGURATION /////
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>';
    // Ask the user to select an assignment
    echo get_string('selectassignment', 'sloodle') . ': ';
    choose_from_menu($assignments, 'sloodlemoduleid', $sloodlemoduleid, '');
    echo "<br>\n";
    print_box_end();
    ///// ACCESS LEVELS /////
    sloodle_print_access_level_options($settings);
}
function sloodle_display_config_form($sloodleauthid, $auth_obj)
{
    //--------------------------------------------------------
    // SETUP
    // Determine which course is being accessed
    $courseid = $auth_obj->course->get_course_id();
    // We need to fetch a list of visible distributors on the course
    // Get the ID of the Sloodle type
    $rec = get_record('modules', 'name', 'sloodle');
    if (!$rec) {
        sloodle_debug("Failed to get Sloodle module type.");
        exit;
    }
    // Get all visible Sloodle modules in the current course
    $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$rec->id} AND visible = 1");
    if (!is_array($recs)) {
        $recs = array();
    }
    $distributors = array();
    foreach ($recs as $cm) {
        // Fetch the distributor instance
        $inst = get_record('sloodle', 'id', $cm->instance, 'type', SLOODLE_TYPE_DISTRIB);
        if (!$inst) {
            continue;
        }
        // Store the distributor details
        $distributors[$cm->id] = $inst->name;
    }
    // Sort the list by name
    natcasesort($distributors);
    //--------------------------------------------------------
    // FORM
    // Get the current object configuration
    $settings = SloodleController::get_object_configuration($sloodleauthid);
    // Setup our default values
    $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0);
    $sloodlerefreshtime = (int) sloodle_get_value($settings, 'sloodlerefreshtime', 3600);
    ///// GENERAL CONFIGURATION /////
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>';
    // Ask the user to select a distributor
    echo get_string('selectdistributor', 'sloodle') . ': ';
    choose_from_menu($distributors, 'sloodlemoduleid', $sloodlemoduleid, '<i>(' . get_string('nodistributorinterface', 'sloodle') . ')</i>', '', 0);
    echo "<br><br>\n";
    // Ask the user for a refresh period (# seconds between automatic updates)
    echo get_string('refreshtimeseconds', 'sloodle') . ': ';
    echo '<input type="text" name="sloodlerefreshtime" value="' . $sloodlerefreshtime . '" size="8" maxlength="8" />';
    echo "<br><br>\n";
    print_box_end();
    ///// ACCESS LEVELS /////
    // There is no need for server access controls, as users cannot access the server through the object
    // (server access is entirely done through Moodle for this one)
    sloodle_print_access_level_options($settings, true, true, false);
}
function sloodle_display_config_form($sloodleauthid, $auth_obj)
{
    //--------------------------------------------------------
    // SETUP
    // Determine which course is being accessed
    $courseid = $auth_obj->course->get_course_id();
    // We need to fetch a list of visible presenters on the course
    // Get the ID of the chat type
    $rec = get_record('modules', 'name', 'sloodle');
    if (!$rec) {
        sloodle_debug("Failed to get Sloodle module type.");
        exit;
    }
    $sloodlemoduleid = $rec->id;
    // Get all visible presenters in the current course
    $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$sloodlemoduleid} AND visible = 1");
    $presenters = array();
    foreach ($recs as $cm) {
        // Fetch the Sloodle instance
        $inst = get_record('sloodle', 'id', $cm->instance, 'type', SLOODLE_TYPE_PRESENTER);
        if (!$inst) {
            continue;
        }
        // Store the Sloodle details
        $presenters[$cm->id] = $inst->name;
    }
    // Make sure there are some presenters to be had
    if (count($presenters) < 1) {
        error(get_string('nopresenters', 'sloodle'));
        exit;
    }
    // Sort the list by name
    natcasesort($presenters);
    //--------------------------------------------------------
    // FORM
    // Get the current object configuration
    $settings = SloodleController::get_object_configuration($sloodleauthid);
    // Setup our default values
    $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0);
    $sloodlelistentoobjects = (int) sloodle_get_value($settings, 'sloodlelistentoobjects', 0);
    $sloodleautodeactivate = (int) sloodle_get_value($settings, 'sloodleautodeactivate', 1);
    ///// GENERAL CONFIGURATION /////
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>';
    // Ask the user to select a Slideshow
    echo get_string('selectpresenter', 'sloodle') . ': ';
    choose_from_menu($presenters, 'sloodlemoduleid', $sloodlemoduleid, '');
    echo "<br><br>\n";
    print_box_end();
    ///// ACCESS LEVELS /////
    sloodle_print_access_level_options($settings, false, true, false);
}
 function display_search_field($value = '')
 {
     global $CFG;
     $varcharlat = sql_compare_text('content');
     $varcharlong = sql_compare_text('content1');
     $latlongsrs = get_recordset_sql("SELECT DISTINCT {$varcharlat} AS la, {$varcharlong} AS lo\n              FROM {$CFG->prefix}data_content\n             WHERE fieldid = {$this->field->id}\n             ORDER BY {$varcharlat}, {$varcharlong}");
     $options = array();
     while ($latlong = rs_fetch_next_record($latlongsrs)) {
         $options[$latlong->la . ',' . $latlong->lo] = $latlong->la . ',' . $latlong->lo;
     }
     rs_close($latlongsrs);
     return choose_from_menu($options, 'f_' . $this->field->id, $value, 'choose', '', 0, true);
 }
 function display_search_field($value = '')
 {
     global $CFG;
     $varcharcontent = sql_compare_text('content', 255);
     $used = get_records_sql("SELECT DISTINCT {$varcharcontent} AS content\n               FROM {$CFG->prefix}data_content\n              WHERE fieldid={$this->field->id}\n             ORDER BY {$varcharcontent}");
     $options = array();
     if (!empty($used)) {
         foreach ($used as $rec) {
             $options[$rec->content] = $rec->content;
             //Build following indicies from the sql.
         }
     }
     return choose_from_menu($options, 'f_' . $this->field->id, $value, 'choose', '', 0, true);
 }
Beispiel #14
0
 function display_search_field($value = '')
 {
     global $CFG;
     $temp = get_records_sql_menu('SELECT id, content from ' . $CFG->prefix . 'data_content WHERE fieldid=' . $this->field->id . ' GROUP BY content ORDER BY content');
     $options = array();
     if (!empty($temp)) {
         $options[''] = '';
         //Make first index blank.
         foreach ($temp as $key) {
             $options[$key] = $key;
             //Build following indicies from the sql.
         }
     }
     return choose_from_menu($options, 'f_' . $this->field->id, $value, 'choose', '', 0, true);
 }
Beispiel #15
0
 function display_search_field($value = '')
 {
     global $CFG;
     $lats = get_records_sql_menu('SELECT id, content from ' . $CFG->prefix . 'data_content WHERE fieldid=' . $this->field->id . ' GROUP BY content ORDER BY content');
     $longs = get_records_sql_menu('SELECT id, content1 from ' . $CFG->prefix . 'data_content WHERE fieldid=' . $this->field->id . ' GROUP BY content ORDER BY content');
     $options = array();
     if (!empty($lats) && !empty($longs)) {
         $options[''] = '';
         // Make first index blank.
         foreach ($lats as $key => $temp) {
             $options[$temp . ',' . $longs[$key]] = $temp . ',' . $longs[$key];
         }
     }
     return choose_from_menu($options, 'f_' . $this->field->id, $value, 'choose', '', 0, true);
 }
Beispiel #16
0
 function display_add_field($recordid = 0)
 {
     if ($recordid) {
         $content = get_field('data_content', 'content', 'fieldid', $this->field->id, 'recordid', $recordid);
         $content = trim($content);
     } else {
         $content = '';
     }
     $str = '<div title="' . s($this->field->description) . '">';
     $rawoptions = explode("\n", $this->field->param1);
     foreach ($rawoptions as $option) {
         $option = trim($option);
         if ($option) {
             $options[$option] = $option;
         }
     }
     $str .= choose_from_menu($options, 'field_' . $this->field->id, $content, get_string('menuchoose', 'data'), '', '', true, false, 0, 'field_' . $this->field->id);
     $str .= '</div>';
     return $str;
 }
Beispiel #17
0
/**
 * Callback function called from question_list() function (which is called from showbank())
 */
function module_specific_controls($totalnumber, $recurse, $category, $cmid)
{
    $catcontext = get_context_instance_by_id($category->contextid);
    if (has_capability('moodle/question:useall', $catcontext)) {
        for ($i = 1; $i <= min(10, $totalnumber); $i++) {
            $randomcount[$i] = $i;
        }
        for ($i = 20; $i <= min(100, $totalnumber); $i += 10) {
            $randomcount[$i] = $i;
        }
        $out = '<br />';
        $out .= get_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true));
        $out .= '<input type="hidden" name="recurse" value="' . $recurse . '" />';
        $out .= "<input type=\"hidden\" name=\"categoryid\" value=\"{$category->id}\" />";
        $out .= ' <input type="submit" name="addrandom" value="' . get_string('add') . '" />';
        $out .= helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, '', true);
    } else {
        $out = '';
    }
    return $out;
}
function moodle_ewiki_page_wiki_dump($id = 0, $data = 0, $action = 0)
{
    global $userid, $groupid, $cm, $wikipage, $wiki, $course, $CFG;
    #-- return legacy page
    $cont = true;
    if (!empty($_REQUEST["wikiexport"])) {
        $binaries = $_REQUEST["exportbinaries"];
        if (!$wiki->ewikiacceptbinary) {
            $binaries = 0;
        }
        $exportformats = $_REQUEST["exportformats"];
        if ($wiki->htmlmode == 2) {
            $exportformats = 1;
        }
        $cont = ewiki_page_wiki_dump_send($binaries, $exportformats, $_REQUEST["withvirtualpages"], $_REQUEST["exportdestinations"]);
    }
    if ($cont === false) {
        die;
    }
    $url = ewiki_script("", "WikiExport");
    $ret = ewiki_make_title($id, ewiki_t($id), 2);
    $ret .= $cont && $cont !== true ? $cont . "<br /><br />\n" : "";
    $ret .= get_string("wikiexportcomment", "wiki");
    // removing name="form" from the following form as it does not validate
    // and is not referenced. MDL-7861
    $ret .= "<br /><br />\n" . '<FORM method="post" action="view.php">' . "\n" . "<div class=\"wikiexportbox\">\n" . '<INPUT type="hidden" name="page" value="WikiExport" />' . "\n" . '<INPUT type="hidden" name="userid" value="' . $userid . '" />' . "\n" . '<INPUT type="hidden" name="groupid" value="' . $groupid . '" />' . "\n" . '<INPUT type="hidden" name="id" value="' . $cm->id . '" />' . "\n" . '<INPUT type="hidden" name="wikipage" value="' . $wikipage . '" />' . "\n";
    // Export binaries too ?
    if (!$wiki->ewikiacceptbinary) {
        $ret .= '<INPUT type="hidden" name="exportbinaries" value="0" />' . $exportdestinations[0] . "\n";
    } else {
        $ret .= '<INPUT type="hidden" name="exportbinaries" value="0" />' . "\n";
    }
    $ret .= "<TABLE cellpadding=\"5\">\n";
    if ($wiki->ewikiacceptbinary) {
        $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("withbinaries", "wiki") . ":</TD>\n" . "    <TD>\n" . '      <input type="checkbox" name="exportbinaries" value="1"' . ($_REQUEST["exportbinaries"] == 1 ? " checked" : "") . " />\n" . "    </TD>\n" . "  </TR>\n";
    }
    $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("withvirtualpages", "wiki") . ":</TD>\n" . "    <TD>\n" . '      <input type="checkbox" name="withvirtualpages" value="1"' . ($_REQUEST["withvirtualpages"] == 1 ? " checked" : "") . " />\n" . "    </TD>\n" . "  </TR>\n";
    $exportformats = array("0" => get_string("plaintext", "wiki"), "1" => get_string("html", "wiki"));
    /// Formats
    $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("exportformats", "wiki") . ":</TD>\n" . "    <TD>\n";
    if ($wiki->htmlmode != 2) {
        $ret .= choose_from_menu($exportformats, "exportformats", $_REQUEST["exportformats"], "", "", "", true) . "\n";
    } else {
        $ret .= '<INPUT type="hidden" name="exportformats" value="1" />' . get_string("html", "wiki");
    }
    $ret .= "    </TD>\n" . "  </TR>\n";
    /// Destination
    $exportdestinations = array("0" => get_string("downloadaszip", "wiki"));
    if (wiki_is_teacher($wiki)) {
        // Get Directory List
        $rawdirs = get_directory_list("{$CFG->dataroot}/{$course->id}", 'moddata', true, true, false);
        foreach ($rawdirs as $rawdir) {
            $exportdestinations[$rawdir] = get_string("moduledirectory", "wiki") . ": " . $rawdir;
        }
    }
    $ret .= "  <TR valign=\"top\">\n" . '    <TD align="right">' . get_string("exportto", "wiki") . ":</TD>\n" . "    <TD>\n";
    if (count($exportdestinations) == 1) {
        $ret .= '<INPUT type="hidden" name="exportdestinations" value="0" />' . $exportdestinations[0] . "\n";
    } else {
        $ret .= choose_from_menu($exportdestinations, "exportdestinations", $_REQUEST["exportdestinations"], "", "", "", true) . "\n";
    }
    $ret .= "    </TD>\n" . "  </TR>\n" . "</TABLE>\n" . '  <input type="submit" name="wikiexport" value= "' . get_string("export", "wiki") . '" />' . "\n" . "</div>\n";
    "</FORM>\n";
    return $ret;
}
Beispiel #19
0
 function print_options_form($quiz, $cm, $attempts, $lowlimit = 0, $pagesize = 10)
 {
     global $CFG, $USER;
     echo '<div class="controls">';
     echo '<form id="options" action="report.php" method="post">';
     echo '<fieldset class="invisiblefieldset">';
     echo '<p class="quiz-report-options">' . get_string('analysisoptions', 'quiz') . ': </p>';
     echo '<input type="hidden" name="id" value="' . $cm->id . '" />';
     echo '<input type="hidden" name="q" value="' . $quiz->id . '" />';
     echo '<input type="hidden" name="mode" value="analysis" />';
     echo '<p><label for="menuattemptselection">' . get_string('attemptselection', 'quiz_analysis') . '</label> ';
     $options = array(QUIZ_ALLATTEMPTS => get_string("attemptsall", 'quiz_analysis'), QUIZ_HIGHESTATTEMPT => get_string("attemptshighest", 'quiz_analysis'), QUIZ_FIRSTATTEMPT => get_string("attemptsfirst", 'quiz_analysis'), QUIZ_LASTATTEMPT => get_string("attemptslast", 'quiz_analysis'));
     choose_from_menu($options, "attemptselection", "{$attempts}", "");
     echo '</p>';
     echo '<p><label for="lowmarklimit">' . get_string('lowmarkslimit', 'quiz_analysis') . '</label> ';
     echo '<input type="text" id="lowmarklimit" name="lowmarklimit" size="1" value="' . $lowlimit . '" /> % </p>';
     echo '<p><label for="pagesize">' . get_string('pagesize', 'quiz_analysis') . '</label> ';
     echo '<input type="text" id="pagesize" name="pagesize" size="1" value="' . $pagesize . '" /></p>';
     echo '<p><input type="submit" value="' . get_string('go') . '" />';
     helpbutton("analysisoptions", get_string("analysisoptions", 'quiz_analysis'), 'quiz');
     echo '</p>';
     echo '</fieldset>';
     echo '</form>';
     echo '</div>';
     echo "\n";
     echo '<table class="boxaligncenter"><tr>';
     $options = array();
     $options["id"] = "{$cm->id}";
     $options["q"] = "{$quiz->id}";
     $options["mode"] = "analysis";
     $options['sesskey'] = $USER->sesskey;
     $options["noheader"] = "yes";
     echo '<td>';
     $options["download"] = "ODS";
     print_single_button("report.php", $options, get_string("downloadods"));
     echo "</td>\n";
     echo '<td>';
     $options["download"] = "Excel";
     print_single_button("report.php", $options, get_string("downloadexcel"));
     echo "</td>\n";
     if (file_exists("{$CFG->libdir}/phpdocwriter/lib/include.php")) {
         echo '<td>';
         $options["download"] = "OOo";
         print_single_button("report.php", $options, get_string("downloadooo", "quiz_analysis"));
         echo "</td>\n";
     }
     echo '<td>';
     $options["download"] = "CSV";
     print_single_button('report.php', $options, get_string("downloadtext"));
     echo "</td>\n";
     echo "<td>";
     helpbutton('analysisdownload', get_string('analysisdownload', 'quiz_analysis'), 'quiz');
     echo "</td>\n";
     echo '</tr></table>';
 }
echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
$state_names = note_get_state_names();
// the first time list hack
if (empty($users)) {
    foreach ($_POST as $k => $v) {
        if (preg_match('/^user(\\d+)$/', $k, $m)) {
            $users[] = $m[1];
        }
    }
}
$strpublishstate = get_string('publishstate', 'notes');
$userlist = array();
foreach ($users as $k => $v) {
    if (!($user = get_record('user', 'id', $v))) {
        continue;
    }
    echo '<input type="hidden" name="userid[' . $k . ']" value="' . $v . '" />';
    $userlist[] = fullname($user, true);
}
echo '<p>';
echo get_string('users') . ': ' . implode(', ', $userlist) . '.';
echo '</p>';
echo '<p>' . get_string('content', 'notes');
helpbutton('writing', get_string('helpwriting'));
echo '<br /><textarea name="content" rows="5" cols="50">' . strip_tags(@$content) . '</textarea></p>';
echo '<p>' . $strpublishstate;
helpbutton('status', $strpublishstate, 'notes');
choose_from_menu($state_names, 'state', empty($state) ? NOTES_STATE_PUBLIC : $state, '');
echo '</p>';
echo '<input type="submit" value="' . get_string('savechanges') . '" /></div></form>';
print_footer($course);
Beispiel #21
0
function calendar_print_month_selector($name, $selected)
{
    $months = array();
    for ($i = 1; $i <= 12; $i++) {
        $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), '%B');
    }
    choose_from_menu($months, $name, $selected, '');
}
Beispiel #22
0
        $default = '';
    }
    $table->data[$name] = array($name, $enable, $default, '<a href="enrol_config.php?enrol=' . $module . '">' . $str->edit . '</a>');
}
asort($table->data);
print_table($table);
echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"" . get_string("savechanges") . "\" /></div>\n";
echo "</div>";
echo "</form>";
echo '<hr />';
$yesnooptions = array(0 => get_string('no'), 1 => get_string('yes'));
echo '<form ' . $CFG->frametarget . ' id="adminsettings" method="post" action="enrol.php">';
echo '<div class="settingsform clearfix">';
print_heading(get_string('commonsettings', 'admin'));
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
echo '<input type="hidden" name="savesettings" value="1" />';
echo '<fieldset>';
echo '<div class="form-item clearfix" id="admin-sendcoursewelcomemessage">';
echo '<div class="form-label"><label for = "menusendcoursewelcomemessage">' . get_string('sendcoursewelcomemessage', 'admin');
echo '<span class="form-shortname">sendcoursewelcomemessage</span>';
echo '</label></div>';
echo '<div class="form-setting"><div class="form-checkbox defaultsnext">';
choose_from_menu($yesnooptions, 'sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, '');
echo '</div><div class="form-defaultinfo">' . get_string('defaultsettinginfo', 'admin', get_string('yes')) . '</div></div>';
echo '<div class="form-description">' . get_string('configsendcoursewelcomemessage', 'admin') . '</div>';
echo '</div>';
echo '</fieldset>';
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges', 'admin') . '" /></div>';
echo '</div>';
echo '</form>';
admin_externalpage_print_footer();
Beispiel #23
0
 /**
  *  Display all the submissions ready for grading
  */
 function display_submissions($message = '')
 {
     global $CFG, $db, $USER;
     require_once $CFG->libdir . '/gradelib.php';
     /* first we check to see if the form has just been submitted
      * to request user_preference updates
      */
     if (isset($_POST['updatepref'])) {
         $perpage = optional_param('perpage', 10, PARAM_INT);
         $perpage = $perpage <= 0 ? 10 : $perpage;
         set_user_preference('assignment_perpage', $perpage);
         set_user_preference('assignment_quickgrade', optional_param('quickgrade', 0, PARAM_BOOL));
     }
     /* next we get perpage and quickgrade (allow quick grade) params
      * from database
      */
     $perpage = get_user_preferences('assignment_perpage', 10);
     $quickgrade = get_user_preferences('assignment_quickgrade', 0);
     $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id);
     if (!empty($CFG->enableoutcomes) and !empty($grading_info->outcomes)) {
         $uses_outcomes = true;
     } else {
         $uses_outcomes = false;
     }
     $teacherattempts = true;
     /// Temporary measure
     $page = optional_param('page', 0, PARAM_INT);
     $strsaveallfeedback = get_string('saveallfeedback', 'assignment');
     /// Some shortcuts to make the code read better
     $course = $this->course;
     $assignment = $this->assignment;
     $cm = $this->cm;
     $tabindex = 1;
     //tabindex for quick grading tabbing; Not working for dropdowns yet
     add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
     $navlinks = array();
     $navlinks[] = array('name' => $this->strassignments, 'link' => "index.php?id={$course->id}", 'type' => 'activity');
     $navlinks[] = array('name' => format_string($this->assignment->name, true), 'link' => "view.php?a={$this->assignment->id}", 'type' => 'activityinstance');
     $navlinks[] = array('name' => $this->strsubmissions, 'link' => '', 'type' => 'title');
     $navigation = build_navigation($navlinks);
     print_header_simple(format_string($this->assignment->name, true), "", $navigation, '', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm));
     if (!empty($message)) {
         echo $message;
         // display messages here if any
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// find out current groups mode
     $groupmode = groups_get_activity_groupmode($cm);
     $currentgroup = groups_get_activity_group($cm, true);
     groups_print_activity_menu($cm, 'submissions.php?id=' . $this->cm->id);
     /// Get all ppl that are allowed to submit assignments
     $users = get_users_by_capability($context, 'mod/assignment:submit', '', '', '', '', $currentgroup, '', false);
     $users = array_keys($users);
     if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
         $groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id');
         $users = array_intersect($users, array_keys($groupingusers));
     }
     $tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade');
     if ($uses_outcomes) {
         $tablecolumns[] = 'outcome';
         // no sorting based on outcomes column
     }
     $tableheaders = array('', get_string('fullname'), get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified') . ' (' . $course->student . ')', get_string('lastmodified') . ' (' . $course->teacher . ')', get_string('status'), get_string('finalgrade', 'grades'));
     if ($uses_outcomes) {
         $tableheaders[] = get_string('outcome', 'grades');
     }
     require_once $CFG->libdir . '/tablelib.php';
     $table = new flexible_table('mod-assignment-submissions');
     $table->define_columns($tablecolumns);
     $table->define_headers($tableheaders);
     $table->define_baseurl($CFG->wwwroot . '/mod/assignment/submissions.php?id=' . $this->cm->id . '&amp;currentgroup=' . $currentgroup);
     $table->sortable(true, 'lastname');
     //sorted by lastname by default
     $table->collapsible(true);
     $table->initialbars(true);
     $table->column_suppress('picture');
     $table->column_suppress('fullname');
     $table->column_class('picture', 'picture');
     $table->column_class('fullname', 'fullname');
     $table->column_class('grade', 'grade');
     $table->column_class('submissioncomment', 'comment');
     $table->column_class('timemodified', 'timemodified');
     $table->column_class('timemarked', 'timemarked');
     $table->column_class('status', 'status');
     $table->column_class('finalgrade', 'finalgrade');
     if ($uses_outcomes) {
         $table->column_class('outcome', 'outcome');
     }
     $table->set_attribute('cellspacing', '0');
     $table->set_attribute('id', 'attempts');
     $table->set_attribute('class', 'submissions');
     $table->set_attribute('width', '90%');
     //$table->set_attribute('align', 'center');
     $table->no_sorting('finalgrade');
     $table->no_sorting('outcome');
     // Start working -- this is necessary as soon as the niceties are over
     $table->setup();
     /// Check to see if groups are being used in this assignment
     if (!$teacherattempts) {
         $teachers = get_course_teachers($course->id);
         if (!empty($teachers)) {
             $keys = array_keys($teachers);
         }
         foreach ($keys as $key) {
             unset($users[$key]);
         }
     }
     if (empty($users)) {
         print_heading(get_string('noattempts', 'assignment'));
         return true;
     }
     /// Construct the SQL
     if ($where = $table->get_sql_where()) {
         $where .= ' AND ';
     }
     if ($sort = $table->get_sql_sort()) {
         $sort = ' ORDER BY ' . $sort;
     }
     $select = 'SELECT u.id, u.firstname, u.lastname, u.picture,
                       s.id AS submissionid, s.grade, s.submissioncomment,
                       s.timemodified, s.timemarked,
                       COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ';
     $sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'assignment_submissions s ON u.id = s.userid
                                                               AND s.assignment = ' . $this->assignment->id . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
     $table->pagesize($perpage, count($users));
     ///offset used to calculate index of student in that particular query, needed for the pop up to know who's next
     $offset = $page * $perpage;
     $strupdate = get_string('update');
     $strgrade = get_string('grade');
     $grademenu = make_grades_menu($this->assignment->grade);
     if (($ausers = get_records_sql($select . $sql . $sort, $table->get_page_start(), $table->get_page_size())) !== false) {
         $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
         foreach ($ausers as $auser) {
             $final_grade = $grading_info->items[0]->grades[$auser->id];
             /// Calculate user status
             $auser->status = $auser->timemarked > 0 && $auser->timemarked >= $auser->timemodified;
             $picture = print_user_picture($auser->id, $course->id, $auser->picture, false, true);
             if (empty($auser->submissionid)) {
                 $auser->grade = -1;
                 //no submission yet
             }
             if (!empty($auser->submissionid)) {
                 ///Prints student answer and student modified date
                 ///attach file or print link to student answer, depending on the type of the assignment.
                 ///Refer to print_student_answer in inherited classes.
                 if ($auser->timemodified > 0) {
                     $studentmodified = '<div id="ts' . $auser->id . '">' . $this->print_student_answer($auser->id) . userdate($auser->timemodified) . '</div>';
                 } else {
                     $studentmodified = '<div id="ts' . $auser->id . '">&nbsp;</div>';
                 }
                 ///Print grade, dropdown or text
                 if ($auser->timemarked > 0) {
                     $teachermodified = '<div id="tt' . $auser->id . '">' . userdate($auser->timemarked) . '</div>';
                     if ($final_grade->locked or $final_grade->overridden) {
                         $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++);
                             $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                         } else {
                             $grade = '<div id="g' . $auser->id . '">' . $this->display_grade($auser->grade) . '</div>';
                         }
                     }
                 } else {
                     $teachermodified = '<div id="tt' . $auser->id . '">&nbsp;</div>';
                     if ($final_grade->locked or $final_grade->overridden) {
                         $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++);
                             $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                         } else {
                             $grade = '<div id="g' . $auser->id . '">' . $this->display_grade($auser->grade) . '</div>';
                         }
                     }
                 }
                 ///Print Comment
                 if ($final_grade->locked or $final_grade->overridden) {
                     $comment = '<div id="com' . $auser->id . '">' . shorten_text(strip_tags($final_grade->str_feedback), 15) . '</div>';
                 } else {
                     if ($quickgrade) {
                         $comment = '<div id="com' . $auser->id . '">' . '<textarea tabindex="' . $tabindex++ . '" name="submissioncomment[' . $auser->id . ']" id="submissioncomment' . $auser->id . '" rows="2" cols="20">' . $auser->submissioncomment . '</textarea></div>';
                     } else {
                         $comment = '<div id="com' . $auser->id . '">' . shorten_text(strip_tags($auser->submissioncomment), 15) . '</div>';
                     }
                 }
             } else {
                 $studentmodified = '<div id="ts' . $auser->id . '">&nbsp;</div>';
                 $teachermodified = '<div id="tt' . $auser->id . '">&nbsp;</div>';
                 $status = '<div id="st' . $auser->id . '">&nbsp;</div>';
                 if ($final_grade->locked or $final_grade->overridden) {
                     $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
                 } else {
                     if ($quickgrade) {
                         // allow editing
                         $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++);
                         $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                     } else {
                         $grade = '<div id="g' . $auser->id . '">-</div>';
                     }
                 }
                 if ($final_grade->locked or $final_grade->overridden) {
                     $comment = '<div id="com' . $auser->id . '">' . $final_grade->str_feedback . '</div>';
                 } else {
                     if ($quickgrade) {
                         $comment = '<div id="com' . $auser->id . '">' . '<textarea tabindex="' . $tabindex++ . '" name="submissioncomment[' . $auser->id . ']" id="submissioncomment' . $auser->id . '" rows="2" cols="20">' . $auser->submissioncomment . '</textarea></div>';
                     } else {
                         $comment = '<div id="com' . $auser->id . '">&nbsp;</div>';
                     }
                 }
             }
             if (empty($auser->status)) {
                 /// Confirm we have exclusively 0 or 1
                 $auser->status = 0;
             } else {
                 $auser->status = 1;
             }
             $buttontext = $auser->status == 1 ? $strupdate : $strgrade;
             ///No more buttons, we use popups ;-).
             $popup_url = '/mod/assignment/submissions.php?id=' . $this->cm->id . '&amp;userid=' . $auser->id . '&amp;mode=single' . '&amp;offset=' . $offset++;
             $button = link_to_popup_window($popup_url, 'grade' . $auser->id, $buttontext, 600, 780, $buttontext, 'none', true, 'button' . $auser->id);
             $status = '<div id="up' . $auser->id . '" class="s' . $auser->status . '">' . $button . '</div>';
             $finalgrade = '<span id="finalgrade_' . $auser->id . '">' . $final_grade->str_grade . '</span>';
             $outcomes = '';
             if ($uses_outcomes) {
                 foreach ($grading_info->outcomes as $n => $outcome) {
                     $outcomes .= '<div class="outcome"><label>' . $outcome->name . '</label>';
                     $options = make_grades_menu(-$outcome->scaleid);
                     if ($outcome->grades[$auser->id]->locked or !$quickgrade) {
                         $options[0] = get_string('nooutcome', 'grades');
                         $outcomes .= ': <span id="outcome_' . $n . '_' . $auser->id . '">' . $options[$outcome->grades[$auser->id]->grade] . '</span>';
                     } else {
                         $outcomes .= ' ';
                         $outcomes .= choose_from_menu($options, 'outcome_' . $n . '[' . $auser->id . ']', $outcome->grades[$auser->id]->grade, get_string('nooutcome', 'grades'), '', 0, true, false, 0, 'outcome_' . $n . '_' . $auser->id);
                     }
                     $outcomes .= '</div>';
                 }
             }
             $row = array($picture, fullname($auser), $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade);
             if ($uses_outcomes) {
                 $row[] = $outcomes;
             }
             $table->add_data($row);
         }
     }
     /// Print quickgrade form around the table
     if ($quickgrade) {
         echo '<form action="submissions.php" id="fastg" method="post">';
         echo '<div>';
         echo '<input type="hidden" name="id" value="' . $this->cm->id . '" />';
         echo '<input type="hidden" name="mode" value="fastgrade" />';
         echo '<input type="hidden" name="page" value="' . $page . '" />';
         echo '</div>';
         //echo '<div style="text-align:center"><input type="submit" name="fastg" value="'.get_string('saveallfeedback', 'assignment').'" /></div>';
     }
     $table->print_html();
     /// Print the whole table
     if ($quickgrade) {
         echo '<div style="text-align:center"><input type="submit" name="fastg" value="' . get_string('saveallfeedback', 'assignment') . '" /></div>';
         echo '</form>';
     }
     /// End of fast grading form
     /// Mini form for setting user preference
     echo '<br />';
     echo '<form id="options" action="submissions.php?id=' . $this->cm->id . '" method="post">';
     echo '<div>';
     echo '<input type="hidden" id="updatepref" name="updatepref" value="1" />';
     echo '<table id="optiontable" align="right">';
     echo '<tr align="right"><td>';
     echo '<label for="perpage">' . get_string('pagesize', 'assignment') . '</label>';
     echo ':</td>';
     echo '<td>';
     echo '<input type="text" id="perpage" name="perpage" size="1" value="' . $perpage . '" />';
     helpbutton('pagesize', get_string('pagesize', 'assignment'), 'assignment');
     echo '</td></tr>';
     echo '<tr align="right">';
     echo '<td>';
     print_string('quickgrade', 'assignment');
     echo ':</td>';
     echo '<td>';
     if ($quickgrade) {
         echo '<input type="checkbox" name="quickgrade" value="1" checked="checked" />';
     } else {
         echo '<input type="checkbox" name="quickgrade" value="1" />';
     }
     helpbutton('quickgrade', get_string('quickgrade', 'assignment'), 'assignment') . '</p></div>';
     echo '</td></tr>';
     echo '<tr>';
     echo '<td colspan="2" align="right">';
     echo '<input type="submit" value="' . get_string('savepreferences') . '" />';
     echo '</td></tr></table>';
     echo '</div>';
     echo '</form>';
     ///End of mini form
     print_footer($this->course);
 }
Beispiel #24
0
function displaydir($wdir)
{
    //  $wdir == / or /a or /a/b/c/d  etc
    global $basedir;
    global $usecheckboxes;
    global $id;
    global $USER, $CFG;
    $fullpath = $basedir . $wdir;
    $directory = opendir($fullpath);
    // Find all files
    while (false !== ($file = readdir($directory))) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (is_dir($fullpath . "/" . $file)) {
            $dirlist[] = $file;
        } else {
            $filelist[] = $file;
        }
    }
    closedir($directory);
    $strfile = get_string("file");
    $strname = get_string("name");
    $strsize = get_string("size");
    $strmodified = get_string("modified");
    $straction = get_string("action");
    $strmakeafolder = get_string("makeafolder");
    $struploadafile = get_string("uploadafile");
    $strwithchosenfiles = get_string("withchosenfiles");
    $strmovetoanotherfolder = get_string("movetoanotherfolder");
    $strmovefilestohere = get_string("movefilestohere");
    $strdeletecompletely = get_string("deletecompletely");
    $strcreateziparchive = get_string("createziparchive");
    $strrename = get_string("rename");
    $stredit = get_string("edit");
    $strunzip = get_string("unzip");
    $strlist = get_string("list");
    $strchoose = get_string("choose");
    echo "<form action=\"coursefiles.php\" method=\"post\" name=\"dirform\">\n";
    echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\n";
    if ($wdir == "/") {
        $wdir = "";
    } else {
        $bdir = str_replace("/" . basename($wdir), "", $wdir);
        if ($bdir == "/") {
            $bdir = "";
        }
        print "<tr>\n<td colspan=\"5\">";
        print "<a href=\"coursefiles.php?id={$id}&amp;wdir={$bdir}&amp;usecheckboxes={$usecheckboxes}\" onclick=\"return reset_value();\">";
        print "<img src=\"{$CFG->wwwroot}/lib/editor/htmlarea/images/folderup.gif\" height=\"14\" width=\"24\" border=\"0\" alt=\"" . get_string('parentfolder') . "\" />";
        print "</a></td>\n</tr>\n";
    }
    $count = 0;
    if (!empty($dirlist)) {
        asort($dirlist);
        foreach ($dirlist as $dir) {
            $count++;
            $filename = $fullpath . "/" . $dir;
            $fileurl = $wdir . "/" . $dir;
            $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
            echo "<tr>";
            if ($usecheckboxes) {
                print_cell("center", "<input type=\"checkbox\" name=\"file{$count}\" value=\"{$fileurl}\" onclick=\"return set_rename('{$dir}');\" />");
            }
            print_cell("left", "<a href=\"coursefiles.php?id={$id}&amp;wdir={$fileurl}\" onclick=\"return reset_value();\"><img src=\"{$CFG->pixpath}/f/folder.gif\" class=\"icon\" alt=\"" . get_string('folder') . "\" /></a> <a href=\"coursefiles.php?id={$id}&amp;wdir={$fileurl}&amp;usecheckboxes={$usecheckboxes}\" onclick=\"return reset_value();\">" . htmlspecialchars($dir) . "</a>");
            print_cell("right", "&nbsp;");
            print_cell("right", $filedate);
            echo "</tr>";
        }
    }
    if (!empty($filelist)) {
        asort($filelist);
        foreach ($filelist as $file) {
            $icon = mimeinfo("icon", $file);
            $imgtype = mimeinfo("type", $file);
            $count++;
            $filename = $fullpath . "/" . $file;
            $fileurl = "{$wdir}/{$file}";
            $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
            $dimensions = get_image_size($filename);
            if ($dimensions) {
                $imgwidth = $dimensions[0];
                $imgheight = $dimensions[1];
            } else {
                $imgwidth = "Unknown";
                $imgheight = "Unknown";
            }
            unset($dimensions);
            echo "<tr>\n";
            if ($usecheckboxes) {
                print_cell("center", "<input type=\"checkbox\" name=\"file{$count}\" value=\"{$fileurl}\" onclick=\";return set_rename('{$file}');\" />");
            }
            echo "<td align=\"left\" nowrap=\"nowrap\">";
            $ffurl = get_file_url($id . $fileurl);
            link_to_popup_window($ffurl, "display", "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfile}\" />", 480, 640);
            $file_size = filesize($filename);
            echo "<a onclick=\"return set_value(info = {url: '" . $ffurl . "',";
            echo " isize: '" . $file_size . "', itype: '" . $imgtype . "', iwidth: '" . $imgwidth . "',";
            echo " iheight: '" . $imgheight . "', imodified: '" . $filedate . "' })\" href=\"#\">{$file}</a>";
            echo "</td>\n";
            if ($icon == "zip.gif") {
                $edittext = "<a href=\"coursefiles.php?id={$id}&amp;wdir={$wdir}&amp;file={$fileurl}&amp;action=unzip&amp;sesskey={$USER->sesskey}\">{$strunzip}</a>&nbsp;";
                $edittext .= "<a href=\"coursefiles.php?id={$id}&amp;wdir={$wdir}&amp;file={$fileurl}&amp;action=listzip&amp;sesskey={$USER->sesskey}\">{$strlist}</a> ";
            } else {
                $edittext = "&nbsp;";
            }
            print_cell("right", "{$edittext} ");
            print_cell("right", $filedate);
            echo "</tr>\n";
        }
    }
    echo "</table>\n";
    if (empty($wdir)) {
        $wdir = "/";
    }
    echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n";
    echo "<tr>\n<td>";
    echo "<input type=\"hidden\" name=\"id\" value=\"{$id}\" />\n";
    echo "<input type=\"hidden\" name=\"wdir\" value=\"{$wdir}\" />\n";
    echo "<input type=\"hidden\" name=\"sesskey\" value=\"{$USER->sesskey}\" />\n";
    $options = array("move" => "{$strmovetoanotherfolder}", "delete" => "{$strdeletecompletely}", "zip" => "{$strcreateziparchive}");
    if (!empty($count)) {
        choose_from_menu($options, "action", "", "{$strwithchosenfiles}...", "javascript:getElementById('dirform').submit()");
    }
    if (!empty($USER->fileop) and $USER->fileop == "move" and $USER->filesource != $wdir) {
        echo "<form action=\"coursefiles.php\" method=\"get\">\n";
        echo " <input type=\"hidden\" name=\"id\" value=\"{$id}\" />\n";
        echo " <input type=\"hidden\" name=\"wdir\" value=\"{$wdir}\" />\n";
        echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />\n";
        echo " <input type=\"hidden\" name=\"sesskey\" value=\"{$USER->sesskey}\" />\n";
        echo " <input type=\"submit\" value=\"{$strmovefilestohere}\" />\n";
        echo "</form>";
    }
    echo "</td></tr>\n";
    echo "</table>\n";
    echo "</form>\n";
}
     echo ' : ';
     make_grading_menu($brainstorm, 'feedback', @$gradeset->feedback, false);
 }
 // print a final feedback form
 echo '<br/><br/><table width="80%"><tr valign="top"><td><b>' . get_string('feedback') . ':</b></td><td>';
 $usehtmleditor = can_use_html_editor();
 print_textarea($usehtmleditor, 20, 50, 680, 400, 'teacherfeedback', @$report->feedback);
 if (!$usehtmleditor) {
     echo '<p align="right">';
     helpbutton('textformat', get_string('formattexttype'));
     print_string('formattexttype');
     echo ":&nbsp;";
     if (empty($report->feedbackformat)) {
         $report->feedbackformat = FORMAT_MOODLE;
     }
     choose_from_menu(format_text_menu(), 'feedbackformat', $report->feedbackformat, '');
 } else {
     $htmleditorneeded = 1;
 }
 echo '</td></tr></table>';
 // if single grading, print a single grade scale
 if ($brainstorm->singlegrade) {
     echo '<br/>';
     print_string('grade');
     echo ' : ';
     make_grading_menu($brainstorm, 'grade', @$gradeset->single, false);
 }
 /// print the submit button
 echo '<br/><center>';
 echo "<br/><input type=\"submit\" name=\"go_btn\" value=\"" . get_string('update') . '" />';
 /// end form
Beispiel #26
0
if ($bulkoperations) {
    echo '<br /><div class="buttons">';
    echo '<input type="button" onclick="checkall()" value="' . get_string('selectall') . '" /> ';
    echo '<input type="button" onclick="checknone()" value="' . get_string('deselectall') . '" /> ';
    $displaylist = array();
    $displaylist['messageselect.php'] = get_string('messageselectadd');
    if (!empty($CFG->enablenotes) && has_capability('moodle/notes:manage', $context) && $context->id != $frontpagectx->id) {
        $displaylist['addnote.php'] = get_string('addnewnote', 'notes');
        $displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'notes');
    }
    if ($context->id != $frontpagectx->id) {
        $displaylist['extendenrol.php'] = get_string('extendenrol');
        $displaylist['groupextendenrol.php'] = get_string('groupextendenrol');
    }
    helpbutton("participantswithselectedusers", get_string("withselectedusers"));
    choose_from_menu($displaylist, "formaction", "", get_string("withselectedusers"), "if(checksubmit(this.form))this.form.submit();", "");
    echo '<input type="hidden" name="id" value="' . $course->id . '" />';
    echo '<div id="noscriptparticipantsform" style="display: inline;">';
    echo '<input type="submit" value="' . get_string('ok') . '" /></div>';
    echo '<script type="text/javascript">' . "\n//<![CDATA[\n" . 'document.getElementById("noscriptparticipantsform").style.display = "none";' . "\n//]]>\n" . '</script>';
    echo '</div>';
    echo '</div>';
    echo '</form>';
}
if ($bulkoperations && $totalcount > $perpage * 3) {
    echo '<form action="index.php" class="searchform"><div><input type="hidden" name="id" value="' . $course->id . '" />' . get_string('search') . ':&nbsp;' . "\n";
    echo '<input type="text" name="search" value="' . s($search) . '" />&nbsp;<input type="submit" value="' . get_string('search') . '" /></div></form>' . "\n";
}
$perpageurl = preg_replace('/&amp;perpage=\\d*/', '', $baseurl);
if ($perpage == SHOW_ALL_PAGE_SIZE) {
    echo '<div id="showall"><a href="' . $perpageurl . '&amp;perpage=' . DEFAULT_PAGE_SIZE . '">' . get_string('showperpage', '', DEFAULT_PAGE_SIZE) . '</a></div>';
Beispiel #27
0
/**
* Prints the table of questions in a category with interactions
*
* @param object $course   The course object
* @param int $categoryid  The id of the question category to be displayed
* @param int $quizid      The quiz id if we are in the context of a particular quiz, 0 otherwise
* @param int $recurse     This is 1 if subcategories should be included, 0 otherwise
* @param int $page        The number of the page to be displayed
* @param int $perpage     Number of questions to show per page
* @param boolean $showhidden   True if also hidden questions should be displayed
* @param boolean $showquestiontext whether the text of each question should be shown in the list
*/
function question_list($course, $categoryid, $quizid = 0, $recurse = 1, $page = 0, $perpage = 100, $showhidden = false, $sortorder = 'qtype, name ASC', $showquestiontext = false)
{
    global $USER, $CFG, $THEME;
    $qtypemenu = question_type_menu();
    if ($rqp_types = get_records('question_rqp_types')) {
        foreach ($rqp_types as $type) {
            $qtypemenu['rqp_' . $type->id] = $type->name;
        }
    }
    $strcategory = get_string("category", "quiz");
    $strquestion = get_string("question", "quiz");
    $straddquestions = get_string("addquestions", "quiz");
    $strimportquestions = get_string("importquestions", "quiz");
    $strexportquestions = get_string("exportquestions", "quiz");
    $strnoquestions = get_string("noquestions", "quiz");
    $strselect = get_string("select", "quiz");
    $strselectall = get_string("selectall", "quiz");
    $strselectnone = get_string("selectnone", "quiz");
    $strcreatenewquestion = get_string("createnewquestion", "quiz");
    $strquestionname = get_string("questionname", "quiz");
    $strdelete = get_string("delete");
    $stredit = get_string("edit");
    $straction = get_string("action");
    $strrestore = get_string('restore');
    $straddtoquiz = get_string("addtoquiz", "quiz");
    $strtype = get_string("type", "quiz");
    $strcreatemultiple = get_string("createmultiple", "quiz");
    $strpreview = get_string("preview", "quiz");
    if (!$categoryid) {
        echo "<p style=\"text-align:center;\"><b>";
        print_string("selectcategoryabove", "quiz");
        echo "</b></p>";
        if ($quizid) {
            echo "<p>";
            print_string("addingquestions", "quiz");
            echo "</p>";
        }
        return;
    }
    if (!($category = get_record('question_categories', 'id', $categoryid))) {
        notify('Category not found!');
        return;
    }
    $canedit = has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $category->course));
    $editingquiz = false;
    if ($quizid) {
        $cm = get_coursemodule_from_instance('quiz', $quizid);
        $editingquiz = has_capability('mod/quiz:manage', get_context_instance(CONTEXT_MODULE, $cm->id));
    }
    echo '<div class="boxaligncenter">';
    $formatoptions = new stdClass();
    $formatoptions->noclean = true;
    echo format_text($category->info, FORMAT_MOODLE, $formatoptions, $course->id);
    echo '<table><tr>';
    // check if editing questions in this category is allowed
    if ($canedit) {
        echo "<td valign=\"top\"><b>{$strcreatenewquestion}:</b></td>";
        echo '<td valign="top" align="right">';
        popup_form("{$CFG->wwwroot}/question/question.php?category={$category->id}&amp;qtype=", $qtypemenu, "addquestion", "", "choose", "", "", false, "self");
        echo '</td><td valign="top" align="right">';
        helpbutton("questiontypes", $strcreatenewquestion, "quiz");
        echo '</td>';
    } else {
        echo '<td>';
        print_string("publishedit", "quiz");
        echo '</td>';
    }
    echo '</tr></table>';
    echo '</div>';
    $categorylist = $recurse ? question_categorylist($category->id) : $category->id;
    // hide-feature
    $showhidden = $showhidden ? '' : " AND hidden = '0'";
    if (!($totalnumber = count_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}"))) {
        echo "<p style=\"text-align:center;\">";
        print_string("noquestions", "quiz");
        echo "</p>";
        return;
    }
    if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorder, '*', $page * $perpage, $perpage))) {
        // There are no questions on the requested page.
        $page = 0;
        if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorder, '*', 0, $perpage))) {
            // There are no questions at all
            echo "<p style=\"text-align:center;\">";
            print_string("noquestions", "quiz");
            echo "</p>";
            return;
        }
    }
    print_paging_bar($totalnumber, $page, $perpage, "edit.php?courseid={$course->id}&amp;perpage={$perpage}&amp;");
    echo '<form method="post" action="edit.php?courseid=' . $course->id . '">';
    echo '<fieldset class="invisiblefieldset" style="display: block;">';
    echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
    echo '<table id="categoryquestions" style="width: 100%"><tr>';
    echo "<th style=\"white-space:nowrap;\" class=\"header\" scope=\"col\">{$straction}</th>";
    $sortoptions = array('name, qtype ASC' => get_string("sortalpha", "quiz"), 'qtype, name ASC' => get_string("sorttypealpha", "quiz"), 'id ASC' => get_string("sortage", "quiz"));
    $orderselect = choose_from_menu($sortoptions, 'sortorder', $sortorder, false, 'this.form.submit();', '0', true);
    $orderselect .= '<noscript><div><input type="submit" value="' . get_string("sortsubmit", "quiz") . '" /></div></noscript>';
    echo "<th style=\"white-space:nowrap; text-align: left;\" class=\"header\" scope=\"col\">{$strquestionname} {$orderselect}</th>\n    <th style=\"white-space:nowrap; text-align: right;\" class=\"header\" scope=\"col\">{$strtype}</th>";
    echo "</tr>\n";
    foreach ($questions as $question) {
        $nameclass = '';
        $textclass = '';
        if ($question->hidden) {
            $nameclass = 'dimmed_text';
            $textclass = 'dimmed_text';
        }
        if ($showquestiontext) {
            $nameclass .= ' header';
        }
        if ($nameclass) {
            $nameclass = 'class="' . $nameclass . '"';
        }
        if ($textclass) {
            $textclass = 'class="' . $textclass . '"';
        }
        echo "<tr>\n<td style=\"white-space:nowrap;\" {$nameclass}>\n";
        // add to quiz
        if ($editingquiz) {
            echo "<a title=\"{$straddtoquiz}\" href=\"edit.php?addquestion={$question->id}&amp;quizid={$quizid}&amp;sesskey={$USER->sesskey}\"><img\n                  src=\"{$CFG->pixpath}/t/moveleft.gif\" alt=\"{$straddtoquiz}\" /></a>&nbsp;";
        }
        // preview
        link_to_popup_window('/question/preview.php?id=' . $question->id . '&amp;quizid=' . $quizid, 'questionpreview', "<img src=\"{$CFG->pixpath}/t/preview.gif\" class=\"iconsmall\" alt=\"{$strpreview}\" />", 0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS);
        // edit, hide, delete question, using question capabilities, not quiz capabilieies
        if ($canedit) {
            echo "<a title=\"{$stredit}\" href=\"{$CFG->wwwroot}/question/question.php?id={$question->id}\"><img\n                    src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"{$stredit}\" /></a>&nbsp;";
            // hide-feature
            if ($question->hidden) {
                echo "<a title=\"{$strrestore}\" href=\"edit.php?courseid={$course->id}&amp;unhide={$question->id}&amp;sesskey={$USER->sesskey}\"><img\n                        src=\"{$CFG->pixpath}/t/restore.gif\" alt=\"{$strrestore}\" /></a>";
            } else {
                echo "<a title=\"{$strdelete}\" href=\"edit.php?courseid={$course->id}&amp;deleteselected={$question->id}&amp;q{$question->id}=1\"><img\n                        src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"{$strdelete}\" /></a>";
            }
        }
        echo "&nbsp;<input title=\"{$strselect}\" type=\"checkbox\" name=\"q{$question->id}\" value=\"1\" />";
        echo "</td>\n";
        echo "<td {$nameclass}>" . format_string($question->name) . "</td>\n";
        echo "<td {$nameclass} style='text-align: right'>\n";
        print_question_icon($question);
        echo "</td>\n";
        echo "</tr>\n";
        if ($showquestiontext) {
            echo '<tr><td colspan="3" ' . $textclass . '>';
            $formatoptions = new stdClass();
            $formatoptions->noclean = true;
            $formatoptions->para = false;
            echo format_text($question->questiontext, $question->questiontextformat, $formatoptions, $course->id);
            echo "</td></tr>\n";
        }
    }
    echo "</table>\n";
    $paging = print_paging_bar($totalnumber, $page, $perpage, "edit.php?courseid={$course->id}&amp;perpage={$perpage}&amp;", 'page', false, true);
    if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) {
        if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) {
            $showall = '<a href="edit.php?courseid=' . $course->id . '&amp;perpage=1000">' . get_string('showall', 'moodle', $totalnumber) . '</a>';
        } else {
            $showall = '<a href="edit.php?courseid=' . $course->id . '&amp;perpage=' . DEFAULT_QUESTIONS_PER_PAGE . '">' . get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE) . '</a>';
        }
        if ($paging) {
            $paging = substr($paging, 0, strrpos($paging, '</div>'));
            $paging .= "<br />{$showall}</div>";
        } else {
            $paging = "<div class='paging'>{$showall}</div>";
        }
    }
    echo $paging;
    echo '<table class="quiz-edit-selected"><tr><td colspan="2">';
    echo '<a href="javascript:select_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectall . '</a> /' . ' <a href="javascript:deselect_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectnone . '</a>' . '</td><td align="right"><b>&nbsp;' . get_string('withselected', 'quiz') . ':</b></td></tr><tr><td>';
    if ($editingquiz) {
        echo "<input type=\"submit\" name=\"add\" value=\"{$THEME->larrow} {$straddtoquiz}\" />\n";
        echo '</td><td>';
    }
    // print delete and move selected question
    if ($canedit) {
        echo '<input type="submit" name="deleteselected" value="' . $strdelete . "\" /></td><td>\n";
        echo '<input type="submit" name="move" value="' . get_string('moveto', 'quiz') . "\" />\n";
        question_category_select_menu($course->id, false, true, $category->id);
    }
    echo "</td></tr></table>";
    // add random question
    if ($editingquiz) {
        for ($i = 1; $i <= min(10, $totalnumber); $i++) {
            $randomcount[$i] = $i;
        }
        for ($i = 20; $i <= min(100, $totalnumber); $i += 10) {
            $randomcount[$i] = $i;
        }
        echo '<br />';
        print_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true));
        echo '<input type="hidden" name="recurse" value="' . $recurse . '" />';
        echo "<input type=\"hidden\" name=\"categoryid\" value=\"{$category->id}\" />";
        echo ' <input type="submit" name="addrandom" value="' . get_string('add') . '" />';
        helpbutton('random', get_string('random', 'quiz'), 'quiz');
    }
    echo '</fieldset>';
    echo "</form>\n";
}
Beispiel #28
0
function scorm_view_display($user, $scorm, $action, $cm, $boxwidth = '')
{
    global $CFG;
    if ($scorm->updatefreq == UPDATE_EVERYTIME) {
        require_once $CFG->dirroot . '/mod/scorm/lib.php';
        $scorm->instance = $scorm->id;
        scorm_update_instance($scorm);
    }
    $organization = optional_param('organization', '', PARAM_INT);
    print_simple_box_start('center', $boxwidth);
    ?>
        <div class="structurehead"><?php 
    print_string('contents', 'scorm');
    ?>
</div>
<?php 
    if (empty($organization)) {
        $organization = $scorm->launch;
    }
    if ($orgs = get_records_select_menu('scorm_scoes', "scorm='{$scorm->id}' AND organization='' AND launch=''", 'id', 'id,title')) {
        if (count($orgs) > 1) {
            ?>
            <div class='scorm-center'>
                <?php 
            print_string('organizations', 'scorm');
            ?>
                <form id='changeorg' method='post' action='<?php 
            echo $action;
            ?>
'>
                    <?php 
            choose_from_menu($orgs, 'organization', "{$organization}", '', 'submit()');
            ?>
                </form>
            </div>
<?php 
        }
    }
    $orgidentifier = '';
    if ($sco = scorm_get_sco($organization, SCO_ONLY)) {
        if ($sco->organization == '' && $sco->launch == '') {
            $orgidentifier = $sco->identifier;
        } else {
            $orgidentifier = $sco->organization;
        }
    }
    /*
     $orgidentifier = '';
        if ($org = get_record('scorm_scoes','id',$organization)) {
            if (($org->organization == '') && ($org->launch == '')) {
                $orgidentifier = $org->identifier;
            } else {
                $orgidentifier = $org->organization;
            }
        }*/
    $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR));
    // Just to be safe
    if (!file_exists($CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php')) {
        $scorm->version = 'scorm_12';
    }
    require_once $CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php';
    $result = scorm_get_toc($user, $scorm, 'structlist', $orgidentifier);
    $incomplete = $result->incomplete;
    echo $result->toc;
    print_simple_box_end();
    ?>
            <div class="scorm-center">
               <form id="theform" method="post" action="<?php 
    echo $CFG->wwwroot;
    ?>
/mod/scorm/player.php">
              <?php 
    if ($scorm->hidebrowse == 0) {
        print_string('mode', 'scorm');
        echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">' . get_string('browse', 'scorm') . '</label>' . "\n";
        echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">' . get_string('normal', 'scorm') . "</label>\n";
    } else {
        echo '<input type="hidden" name="mode" value="normal" />' . "\n";
    }
    if ($incomplete === false && ($result->attemptleft > 0 || $scorm->maxattempt == 0)) {
        ?>
                  <br />
                  <input type="checkbox" id="a" name="newattempt" />
                  <label for="a"><?php 
        print_string('newattempt', 'scorm');
        ?>
</label>
<?php 
    }
    ?>
              <br />
              <input type="hidden" name="scoid"/>
              <input type="hidden" name="id" value="<?php 
    echo $cm->id;
    ?>
"/>
              <input type="hidden" name="currentorg" value="<?php 
    echo $orgidentifier;
    ?>
" />
              <input type="submit" value="<?php 
    print_string('enter', 'scorm');
    ?>
" />
              </form>
          </div>
<?php 
}
Beispiel #29
0
function print_log_selector_form($course, $selecteduser = 0, $selecteddate = 'today', $modname = "", $modid = 0, $modaction = '', $selectedgroup = -1, $showcourses = 0, $showusers = 0, $logformat = 'showashtml')
{
    global $USER, $CFG;
    // first check to see if we can override showcourses and showusers
    $numcourses = count_records_select("course", "", "COUNT(id)");
    if ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && !$showcourses) {
        $showcourses = 1;
    }
    $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    /// Setup for group handling.
    if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
        $selectedgroup = get_current_group($course->id);
        $showgroups = false;
    } else {
        if ($course->groupmode) {
            $selectedgroup = $selectedgroup == -1 ? get_current_group($course->id) : $selectedgroup;
            $showgroups = true;
        } else {
            $selectedgroup = 0;
            $showgroups = false;
        }
    }
    // Get all the possible users
    $users = array();
    if ($course->id != SITEID) {
        if ($selectedgroup) {
            // If using a group, only get users in that group.
            $courseusers = get_group_users($selectedgroup, 'u.lastname ASC', '', 'u.id, u.firstname, u.lastname, u.idnumber');
        } else {
            $courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname, u.idnumber');
        }
    } else {
        $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname, u.idnumber");
    }
    if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
        $showusers = 1;
    }
    if ($showusers) {
        if ($courseusers) {
            foreach ($courseusers as $courseuser) {
                $users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
            }
        }
        if ($guest = get_guest()) {
            $users[$guest->id] = fullname($guest);
        }
    }
    if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
        if ($ccc = get_records("course", "", "", "fullname", "id,fullname,category")) {
            foreach ($ccc as $cc) {
                if ($cc->category) {
                    $courses["{$cc->id}"] = format_string($cc->fullname);
                } else {
                    $courses["{$cc->id}"] = format_string($cc->fullname) . ' (Site)';
                }
            }
        }
        asort($courses);
    }
    $activities = array();
    $selectedactivity = "";
    /// Casting $course->modinfo to string prevents one notice when the field is null
    if ($modinfo = unserialize((string) $course->modinfo)) {
        $section = 0;
        if ($course->format == 'weeks') {
            // Bodgy
            $strsection = get_string("week");
        } else {
            $strsection = get_string("topic");
        }
        foreach ($modinfo as $mod) {
            if ($mod->mod == "label") {
                continue;
            }
            if ($mod->section > 0 and $section != $mod->section) {
                $activities["section/{$mod->section}"] = "-------------- {$strsection} {$mod->section} --------------";
            }
            $section = $mod->section;
            $mod->name = strip_tags(format_string(urldecode($mod->name), true));
            if (strlen($mod->name) > 55) {
                $mod->name = substr($mod->name, 0, 50) . "...";
            }
            if (!$mod->visible) {
                $mod->name = "(" . $mod->name . ")";
            }
            $activities["{$mod->cm}"] = $mod->name;
            if ($mod->cm == $modid) {
                $selectedactivity = "{$mod->cm}";
            }
        }
    }
    if (has_capability('moodle/site:viewreports', $sitecontext) && $course->id == SITEID) {
        $activities["site_errors"] = get_string("siteerrors");
        if ($modid === "site_errors") {
            $selectedactivity = "site_errors";
        }
    }
    $strftimedate = get_string("strftimedate");
    $strftimedaydate = get_string("strftimedaydate");
    asort($users);
    // Prepare the list of action options.
    $actions = array('view' => get_string('view'), 'add' => get_string('add'), 'update' => get_string('update'), 'delete' => get_string('delete'), '-view' => get_string('allchanges'));
    // Get all the possible dates
    // Note that we are keeping track of real (GMT) time and user time
    // User time is only used in displays - all calcs and passing is GMT
    $timenow = time();
    // GMT
    // What day is it now for the user, and when is midnight that day (in GMT).
    $timemidnight = $today = usergetmidnight($timenow);
    // Put today up the top of the list
    $dates = array("{$timemidnight}" => get_string("today") . ", " . userdate($timenow, $strftimedate));
    if (!$course->startdate or $course->startdate > $timenow) {
        $course->startdate = $course->timecreated;
    }
    $numdates = 1;
    while ($timemidnight > $course->startdate and $numdates < 365) {
        $timemidnight = $timemidnight - 86400;
        $timenow = $timenow - 86400;
        $dates["{$timemidnight}"] = userdate($timenow, $strftimedaydate);
        $numdates++;
    }
    if ($selecteddate == "today") {
        $selecteddate = $today;
    }
    echo "<form class=\"logselectform\" action=\"{$CFG->wwwroot}/course/report/log/index.php\" method=\"get\">\n";
    echo "<div>\n";
    echo "<input type=\"hidden\" name=\"chooselog\" value=\"1\" />\n";
    echo "<input type=\"hidden\" name=\"showusers\" value=\"{$showusers}\" />\n";
    echo "<input type=\"hidden\" name=\"showcourses\" value=\"{$showcourses}\" />\n";
    if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
        choose_from_menu($courses, "id", $course->id, "");
    } else {
        //        echo '<input type="hidden" name="id" value="'.$course->id.'" />';
        $courses = array();
        $courses[$course->id] = $course->fullname . ($course->id == SITEID ? ' (' . get_string('site') . ') ' : '');
        choose_from_menu($courses, "id", $course->id, false);
        if (has_capability('moodle/site:viewreports', $sitecontext)) {
            $a = new object();
            $a->url = "{$CFG->wwwroot}/course/report/log/index.php?chooselog=0&group={$selectedgroup}&user={$selecteduser}" . "&id={$course->id}&date={$selecteddate}&modid={$selectedactivity}&showcourses=1&showusers={$showusers}";
            print_string('logtoomanycourses', 'moodle', $a);
        }
    }
    if ($showgroups) {
        if ($cgroups = groups_get_all_groups($course->id)) {
            foreach ($cgroups as $cgroup) {
                $groups[$cgroup->id] = $cgroup->name;
            }
        } else {
            $groups = array();
        }
        choose_from_menu($groups, "group", $selectedgroup, get_string("allgroups"));
    }
    if ($showusers) {
        choose_from_menu($users, "user", $selecteduser, get_string("allparticipants"));
    } else {
        $users = array();
        if (!empty($selecteduser)) {
            $user = get_record('user', 'id', $selecteduser);
            $users[$selecteduser] = fullname($user);
        } else {
            $users[0] = get_string('allparticipants');
        }
        choose_from_menu($users, 'user', $selecteduser, false);
        $a = new object();
        $a->url = "{$CFG->wwwroot}/course/report/log/index.php?chooselog=0&group={$selectedgroup}&user={$selecteduser}" . "&id={$course->id}&date={$selecteddate}&modid={$selectedactivity}&showusers=1&showcourses={$showcourses}";
        print_string('logtoomanyusers', 'moodle', $a);
    }
    choose_from_menu($dates, "date", $selecteddate, get_string("alldays"));
    choose_from_menu($activities, "modid", $selectedactivity, get_string("allactivities"), "", "");
    choose_from_menu($actions, 'modaction', $modaction, get_string("allactions"));
    $logformats = array('showashtml' => get_string('displayonpage'), 'downloadascsv' => get_string('downloadtext'), 'downloadasods' => get_string('downloadods'), 'downloadasexcel' => get_string('downloadexcel'));
    choose_from_menu($logformats, 'logformat', $logformat, false);
    echo '<input type="submit" value="' . get_string('gettheselogs') . '" />';
    echo '</div>';
    echo '</form>';
}
 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     /// Set own core attributes
     $this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB, $db;
     /// Do the job, setting result as needed
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
     /// Get the correct dirs
     if (!empty($XMLDB->dbdirs)) {
         $dbdir =& $XMLDB->dbdirs[$dirpath];
     } else {
         return false;
     }
     if (!empty($XMLDB->editeddirs)) {
         $editeddir =& $XMLDB->editeddirs[$dirpath];
         $structure =& $editeddir->xml_file->getStructure();
     }
     /// ADD YOUR CODE HERE
     $tableparam = optional_param('table', NULL, PARAM_CLEAN);
     $typeparam = optional_param('type', NULL, PARAM_CLEAN);
     /// If no table or type, show form
     if (!$tableparam || !$typeparam) {
         /// No postaction here
         $this->postaction = NULL;
         /// Get list of tables
         $dbtables = $db->MetaTables('TABLES');
         $selecttables = array();
         foreach ($dbtables as $dbtable) {
             $dbtable = str_replace($CFG->prefix, '', $dbtable);
             $selecttables[$dbtable] = $dbtable;
         }
         /// Get list of statement types
         $typeoptions = array(XMLDB_STATEMENT_INSERT => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_INSERT), XMLDB_STATEMENT_UPDATE => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_UPDATE), XMLDB_STATEMENT_DELETE => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_DELETE), XMLDB_STATEMENT_CUSTOM => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_CUSTOM));
         if (!$selecttables) {
             $this->errormsg = 'No tables available to create statements';
             return false;
         }
         /// Now build the form
         $o = '<form id="form" action="index.php" method="post">';
         $o .= '<div>';
         $o .= '    <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />';
         $o .= '    <input type="hidden" name ="action" value="new_statement" />';
         $o .= '    <input type="hidden" name ="postaction" value="edit_statement" />';
         $o .= '    <input type="hidden" name ="sesskey" value="' . sesskey() . '" />';
         $o .= '    <table id="formelements" class="boxaligncenter" cellpadding="5">';
         $o .= '      <tr><td><label for="type" accesskey="t">' . $this->str['statementtype'] . ' </label>' . choose_from_menu($typeoptions, 'type', '', 'choose', '', 0, true) . '<label for="table" accesskey="a">' . $this->str['statementtable'] . ' </label>' . choose_from_menu($selecttables, 'table', '', 'choose', '', 0, true) . '</td></tr>';
         $o .= '      <tr><td colspan="2" align="center"><input type="submit" value="' . $this->str['create'] . '" /></td></tr>';
         $o .= '      <tr><td colspan="2" align="center"><a href="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a></td></tr>';
         $o .= '    </table>';
         $o .= '</div></form>';
         $this->output = $o;
         /// If table, retrofit information and, if everything works,
         /// go to the table edit action
     } else {
         /// Get some params (table is mandatory here)
         $tableparam = required_param('table', PARAM_CLEAN);
         $typeparam = required_param('type', PARAM_CLEAN);
         /// Only insert is allowed :-/
         if ($typeparam != XMLDB_STATEMENT_INSERT) {
             $this->errormsg = 'Only insert of records is supported';
             return false;
         }
         /// Calculate the name of the statement
         $typename = XMLDBStatement::getXMLDBStatementName($typeparam);
         $name = trim(strtolower($typename . ' ' . $tableparam));
         /// Check that this Statement hasn't been created before
         if ($structure->getStatement($name)) {
             $this->errormsg = 'The statement "' . $name . '" already exists, please use it to add more sentences';
             return false;
         }
         /// Create one new XMLDBStatement
         $statement = new XMLDBStatement($name);
         $statement->setType($typeparam);
         $statement->setTable($tableparam);
         $statement->setComment('Initial ' . $typename . ' of records on table ' . $tableparam);
         /// Finally, add the whole retroffited table to the structure
         /// in the place specified
         $structure->addStatement($statement);
     }
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }