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);
}
Esempio n. 4
0
function memorization_print_new_verse_box()
{
    global $CFG, $USER;
    print_box_start('add-verse-box generalbox box');
    print_heading(get_string('newverse', 'memorization'));
    $biblebooks = biblebooks_array();
    // create the book selector
    $biblebookoptions = '';
    foreach ($biblebooks as $booknumber => $bookofbible) {
        if ($booknumber == 0) {
            continue;
        }
        $biblebookoptions .= '<option value="' . $booknumber . '">' . $bookofbible . '</option>';
    }
    $startbookid = '<select name="startbookid">' . $biblebookoptions . '</select>';
    $endbookid = '<select name="endbookid">' . $biblebookoptions . '</select>';
    // create the chapter inputs
    $startchapter = '<input type="text" name="startchapter" size="5" />';
    $endchapter = '<input type="text" name="endchapter" size="5"/>';
    // create the verse inputs
    $startverse = '<input type="text" name="startverse" size="5"/>';
    $endverse = '<input type="text" name="endverse" size="5"/>';
    // create the version chooser
    $versions = get_records('memorization_version');
    if (!empty($versions)) {
        $versionselect = '<select name="versionid">';
        $lastversionid = get_field_sql("SELECT versionid FROM {$CFG->prefix}memorization_verse WHERE userid={$USER->id} ORDER BY id DESC");
        foreach ($versions as $versionid => $version) {
            $selected = $versionid == $lastversionid ? ' SELECTED="selected" ' : '';
            $versionselect .= '<option ' . $selected . ' value="' . $versionid . '">' . $version->value . '</option>';
        }
        $versionselect .= '</select>';
    }
    $currenturl = new moodle_url(qualified_me());
    echo '<form method="POST" action="addverse.php?' . $currenturl->get_query_string() . '">
          <input type="hidden" name="sesskey" value="' . sesskey() . '">
          <table>
            <tr>
              <td>' . get_string('fromverse', 'memorization') . '</td>
              <td>' . $startbookid . ' ' . $startchapter . ':' . $startverse . '</td>
            </tr>

            <tr>
              <td>' . get_string('toverse', 'memorization') . '</td>
              <td>' . $endbookid . ' ' . $endchapter . ':' . $endverse . '</td>
            </tr>

            <tr>
              <td>' . get_string('version', 'memorization') . '</td>
              <td>' . $versionselect . '</td>
            </tr>
          </table>
          <input type="submit">
          </form>';
    print_box_end();
}
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);
}
Esempio n. 7
0
/**
 * Print a message along with "Ok" link for the user to continue and "Cancel" link to close window.
 *
 * @param string $message The text to display
 * @param string $linkok The link to take the user to if they choose "Ok"
 * TODO Document remaining arguments
 */
function notice_okcancel($message, $linkok, $optionsok = NULL, $methodok = 'post')
{
    global $CFG;
    $message = clean_text($message);
    $linkok = clean_text($linkok);
    print_box_start('generalbox', 'notice');
    echo '<p>' . $message . '</p>';
    echo '<div class="buttons">';
    print_single_button($linkok, $optionsok, get_string('ok'), $methodok, $CFG->framename);
    close_window_button('cancel');
    echo '</div>';
    print_box_end();
}
Esempio n. 8
0
 function print_form()
 {
     if ($this->path == 'all') {
         $sports = $this->sql_sports;
     } else {
         $sports = array($this->sql_sports[$this->path]);
     }
     print_box_start();
     echo '<form method="POST">
             ' . array_reduce($sports, array($this, 'reduce_sport'), '') . '
             <input type="hidden" name="type" value="' . $this->type . '">
             <input type="hidden" name="path" value="' . $this->path . '">
             <input type="hidden" name="userid" value="' . $this->userid . '">
             <input type="submit" value="' . get_string('submit') . '">
           </form>';
     print_box_end();
 }
function sloodle_display_config_form($sloodleauthid, $auth_obj)
{
    //--------------------------------------------------------
    // SETUP
    // No setup to do
    //--------------------------------------------------------
    // FORM
    // Get the current object configuration
    $settings = SloodleController::get_object_configuration($sloodleauthid);
    // Setup our default values
    $sloodlerefreshtime = (int) sloodle_get_value($settings, 'sloodlerefreshtime', 600);
    ///// GENERAL CONFIGURATION /////
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>';
    // 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 /////
    // No access levels needed
}
Esempio n. 10
0
/**
 * Outputs the standard form elements for access levels in object configuration.
 * Each part can be optionally hidden, and default values can be provided.
 * (Note: the server access level must be communicated from the object back to Moodle... rubbish implementation, but it works!)
 * @param array $current_config An associative array of setting names to values, containing defaults. (Ignored if null).
 * @param bool $show_use_object Determines whether or not the "Use Object" setting is shown
 * @param bool $show_control_object Determines whether or not the "Control Object" setting is shown
 * @param bool $show_server Determines whether or not the server access setting is shown
 * @return void
 */
function sloodle_print_access_level_options($current_config, $show_use_object = true, $show_control_object = true, $show_server = true)
{
    // Quick-escape: if everything is being suppressed, then do nothing
    if (!($show_use_object || $show_control_object || $show_server)) {
        return;
    }
    // Fetch default values from the configuration, if possible
    $sloodleobjectaccessleveluse = sloodle_get_value($current_config, 'sloodleobjectaccessleveluse', SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC);
    $sloodleobjectaccesslevelctrl = sloodle_get_value($current_config, 'sloodleobjectaccesslevelctrl', SLOODLE_OBJECT_ACCESS_LEVEL_OWNER);
    $sloodleserveraccesslevel = sloodle_get_value($current_config, 'sloodleserveraccesslevel', SLOODLE_SERVER_ACCESS_LEVEL_PUBLIC);
    // Define our object access level array
    $object_access_levels = array(SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC => get_string('accesslevel:public', 'sloodle'), SLOODLE_OBJECT_ACCESS_LEVEL_GROUP => get_string('accesslevel:group', 'sloodle'), SLOODLE_OBJECT_ACCESS_LEVEL_OWNER => get_string('accesslevel:owner', 'sloodle'));
    // Define our server access level array
    $server_access_levels = array(SLOODLE_SERVER_ACCESS_LEVEL_PUBLIC => get_string('accesslevel:public', 'sloodle'), SLOODLE_SERVER_ACCESS_LEVEL_COURSE => get_string('accesslevel:course', 'sloodle'), SLOODLE_SERVER_ACCESS_LEVEL_SITE => get_string('accesslevel:site', 'sloodle'), SLOODLE_SERVER_ACCESS_LEVEL_STAFF => get_string('accesslevel:staff', 'sloodle'));
    // Display box and a heading
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('accesslevel', 'sloodle') . '</h3>';
    // Print the object settings
    if ($show_use_object || $show_control_object) {
        // Object access
        echo '<b>' . get_string('accesslevelobject', 'sloodle') . '</b><br><i>' . get_string('accesslevelobject:desc', 'sloodle') . '</i><br><br>';
        // Use object
        if ($show_use_object) {
            echo get_string('accesslevelobject:use', 'sloodle') . ': ';
            choose_from_menu($object_access_levels, 'sloodleobjectaccessleveluse', $sloodleobjectaccessleveluse, '');
            echo '<br><br>';
        }
        // Control object
        if ($show_control_object) {
            echo get_string('accesslevelobject:control', 'sloodle') . ': ';
            choose_from_menu($object_access_levels, 'sloodleobjectaccesslevelctrl', $sloodleobjectaccesslevelctrl, '');
            echo '<br><br>';
        }
    }
    // Print the server settings
    if ($show_server) {
        // Server access
        echo '<b>' . get_string('accesslevelserver', 'sloodle') . '</b><br><i>' . get_string('accesslevelserver:desc', 'sloodle') . '</i><br><br>';
        echo get_string('accesslevel', 'sloodle') . ': ';
        choose_from_menu($server_access_levels, 'sloodleserveraccesslevel', $sloodleserveraccesslevel, '');
        echo '<br>';
    }
    print_box_end();
}
Esempio n. 11
0
/**
 * Shows the question bank editing interface.
 *
 * The function also processes a number of actions:
 *
 * Actions affecting the question pool:
 * move           Moves a question to a different category
 * deleteselected Deletes the selected questions from the category
 * Other actions:
 * category      Chooses the category
 * displayoptions Sets display options
 *
 * @author Martin Dougiamas and many others. This has recently been extensively
 *         rewritten by Gustav Delius and other members of the Serving Mathematics project
 *         {@link http://maths.york.ac.uk/serving_maths}
 * @param moodle_url $pageurl object representing this pages url.
 */
function question_showbank($tabname, $contexts, $pageurl, $cm, $page, $perpage, $sortorder, $sortorderdecoded, $cat, $recurse, $showhidden, $showquestiontext)
{
    global $COURSE;
    if (optional_param('deleteselected', false, PARAM_BOOL)) {
        // teacher still has to confirm
        // make a list of all the questions that are selected
        $rawquestions = $_REQUEST;
        // This code is called by both POST forms and GET links, so cannot use data_submitted.
        $questionlist = '';
        // comma separated list of ids of questions to be deleted
        $questionnames = '';
        // string with names of questions separated by <br /> with
        // an asterix in front of those that are in use
        $inuse = false;
        // set to true if at least one of the questions is in use
        foreach ($rawquestions as $key => $value) {
            // Parse input for question ids
            if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
                $key = $matches[1];
                $questionlist .= $key . ',';
                question_require_capability_on($key, 'edit');
                if (record_exists('quiz_question_instances', 'question', $key)) {
                    $questionnames .= '* ';
                    $inuse = true;
                }
                $questionnames .= get_field('question', 'name', 'id', $key) . '<br />';
            }
        }
        if (!$questionlist) {
            // no questions were selected
            redirect($pageurl->out());
        }
        $questionlist = rtrim($questionlist, ',');
        // Add an explanation about questions in use
        if ($inuse) {
            $questionnames .= '<br />' . get_string('questionsinuse', 'quiz');
        }
        notice_yesno(get_string("deletequestionscheck", "quiz", $questionnames), $pageurl->out_action(), $pageurl->out(true), array('deleteselected' => $questionlist, 'confirm' => md5($questionlist)), $pageurl->params(), 'post', 'get');
        echo '</td></tr>';
        echo '</table>';
        print_footer($COURSE);
        exit;
    }
    // starts with category selection form
    print_box_start('generalbox questionbank');
    print_heading(get_string('questionbank', 'question'), '', 2);
    question_category_form($contexts->having_one_edit_tab_cap($tabname), $pageurl, $cat, $recurse, $showhidden, $showquestiontext);
    // continues with list of questions
    question_list($contexts->having_one_edit_tab_cap($tabname), $pageurl, $cat, isset($cm) ? $cm : null, $recurse, $page, $perpage, $showhidden, $sortorder, $sortorderdecoded, $showquestiontext, $contexts->having_cap('moodle/question:add'));
    print_box_end();
}
Esempio n. 12
0
    function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false)
    {
        $align = get_string('thisdirection') == 'ltr' ? 'left' : 'right';
        //get the range
        $range_from_to = explode('|', $item->presentation);
        //get the min-value
        $range_from = isset($range_from_to[0]) ? intval($range_from_to[0]) : 0;
        //get the max-value
        $range_to = isset($range_from_to[1]) ? intval($range_from_to[1]) : 0;
        if ($highlightrequire and !$this->check_value($value, $item)) {
            $highlight = 'bgcolor="#FFAAAA" class="missingrequire"';
        } else {
            $highlight = '';
        }
        $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : '';
        ?>
        <td <?php 
        echo $highlight;
        ?>
 valign="top" align="<?php 
        echo $align;
        ?>
">
            <?php 
        echo format_text(stripslashes_safe($item->name) . $requiredmark, true, false, false);
        switch (true) {
            case $range_from === 0 and $range_to > 0:
                echo ' (' . get_string('maximal', 'feedback') . ': ' . $range_to . ')';
                break;
            case $range_from > 0 and $range_to === 0:
                echo ' (' . get_string('minimal', 'feedback') . ': ' . $range_from . ')';
                break;
            case $range_from === 0 and $range_to === 0:
                break;
            default:
                echo ' (' . $range_from . '-' . $range_to . ')';
                break;
        }
        ?>
        </td>
        <td valign="top" align="<?php 
        echo $align;
        ?>
">
    <?php 
        if ($readonly) {
            // print_simple_box_start($align);
            print_box_start('generalbox boxalign' . $align);
            echo $value ? $value : '&nbsp;';
            // print_simple_box_end();
            print_box_end();
        } else {
            ?>
            <input type="text" name="<?php 
            echo $item->typ . '_' . $item->id;
            ?>
"
                                    size="10"
                                    maxlength="10"
                                    value="<?php 
            echo $value ? $value : '';
            ?>
" />
    <?php 
        }
        ?>
        </td>
    <?php 
    }
Esempio n. 13
0
/** 
 *  print some errors to inform users about this.
 *  @return void
 */
function feedback_print_errors()
{
    global $SESSION;
    if (empty($SESSION->feedback->errors)) {
        return;
    }
    // print_simple_box_start("center", "60%", "#FFAAAA", 20, "noticebox");
    print_box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
    print_heading(get_string('handling_error', 'feedback'));
    echo '<p align="center"><b><font color="black"><pre>';
    print_r($SESSION->feedback->errors) . "\n";
    echo '</pre></font></b></p>';
    // print_simple_box_end();
    print_box_end();
    echo '<br /><br />';
    $SESSION->feedback->errors = array();
    //remove errors
}
    function view()
    {
        global $USER;
        //echo "beginning of view";
        $edit = optional_param('edit', 0, PARAM_BOOL);
        $saved = optional_param('saved', 0, PARAM_BOOL);
        $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
        require_capability('mod/problemstatement:view', $context);
        $submission = $this->get_submission();
        //var_dump($this->problemstatement);
        //Guest can not submit nor edit an problemstatement (bug: 4604)
        if (!has_capability('mod/problemstatement:submit', $context)) {
            $editable = null;
        } else {
            $editable = $this->isopen() && (!$submission || $this->problemstatement->allowresubmit || !$submission->timemarked);
        }
        $editmode = ($editable and $edit);
        if ($editmode) {
            //guest can not edit or submit problemstatement
            if (!has_capability('mod/problemstatement:submit', $context)) {
                print_error('guestnosubmit', 'problemstatement');
            }
        }
        add_to_log($this->course->id, "problemstatement", "view", "view.php?id={$this->cm->id}", $this->problemstatement->id, $this->cm->id);
        /// prepare form and process submitted data
        $mform = new mod_problemstatement_online_edit_form();
        $defaults = new object();
        $defaults->id = $this->cm->id;
        if (!empty($submission)) {
            $defaults->programtext = $submission->programtext;
            $defaults->langid = $submission->langid;
        }
        /*if (!empty($submission)) {
                    if ($this->usehtmleditor) {
                        $options = new object();
                        $options->smiley = false;
                        $options->filter = false;
        
                        //$defaults->text   = format_text($submission->data1, $submission->data2, $options);
                        $defaults->text   = $submission->programtext;
                        //$defaults->format = FORMAT_TEXT;
                    } else {
                        $defaults->text   = $submission->programtext;
                        //$defaults->format = 0;
                    }
                }*/
        $mform->set_data($defaults);
        if ($mform->is_cancelled()) {
            redirect('view.php?id=' . $this->cm->id);
        }
        if ($data = $mform->get_data()) {
            // No incoming data?
            if ($editable && $this->update_submission($data)) {
                //TODO fix log actions - needs db upgrade
                $submission = $this->get_submission();
                add_to_log($this->course->id, 'problemstatement', 'upload', 'view.php?a=' . $this->problemstatement->id, $this->problemstatement->id, $this->cm->id);
                //$this->email_teachers($submission);
                //redirect to get updated submission date and word count
                redirect('view.php?id=' . $this->cm->id . '&saved=1');
            } else {
                // TODO: add better error message
                notify(get_string("error"));
                //submitting not allowed!
            }
        }
        /// print header, etc. and display form if needed
        if ($editmode) {
            $this->view_header(get_string('editmysubmission', 'problemstatement'));
        } else {
            $this->view_header();
        }
        if ($editmode) {
            echo '
<script language="javascript" type="text/javascript" src="editarea/edit_area/edit_area_compressor.php?plugins"></script>
<script language="javascript" type="text/javascript">
var _onload=null;

function change_style(sender)
{
	val=sender.options[sender.selectedIndex].value;
	lang="";

	if (val=="1") lang="pas"; else
	if (val=="0") lang="cpp"; else
	if (val=="2") lang="java"; else
	if (val=="3") lang="python"; else
	if (val=="4") lang="cpp"
	editAreaLoader.execCommand(\'id_programtext\',"change_syntax",lang);
	return lang;
};
function add_onchange()
{
	sel=document.getElementById(\'id_langid\')
	sel.onchange=function(){change_style(this)};
	lang=change_style(sel)
editAreaLoader.init({
        id : "id_programtext"        // textarea id
        ,syntax: lang          // syntax to be uses for highlight mode on start-up
        ,start_highlight: true  // to display with highlight mode on start-up
});
	if (_onload!=null) _onload();
};
_onload=window.onload;
window.onload=add_onchange;
</script>
';
        }
        $this->view_intro();
        $this->view_dates();
        if ($saved) {
            notify(get_string('submissionsaved', 'problemstatement'), 'notifysuccess');
        }
        if (has_capability('mod/problemstatement:submit', $context)) {
            if ($editmode) {
                print_box_start('generalbox', 'online');
                $mform->display();
            } else {
                print_box_start('generalbox boxwidthwide boxaligncenter', 'online');
                if ($submission) {
                    echo highlight_syntax($submission->programtext, $submission->langid);
                    $msg = "";
                    switch ($submission->processed) {
                        case "0":
                            $msg .= get_string("unprocessed", "problemstatement");
                            break;
                        case "1":
                            switch ($submission->succeeded) {
                                case "0":
                                    $msg .= get_string("unsuccess", "problemstatement");
                                    break;
                                case "1":
                                    $msg .= get_string("success", "problemstatement");
                                    break;
                                case "2":
                                    $msg .= get_string("compilationerror", "problemstatement") . "\n" . $submission->submissioncomment;
                                    break;
                                case "3":
                                    $msg .= get_string("internalerror", "problemstatement");
                                    break;
                                case "4":
                                    $msg .= get_string("timeout", "problemstatement");
                                    break;
                                case "5":
                                    $msg .= get_string("memoryout", "problemstatement");
                                    break;
                                case "6":
                                    $msg .= get_string("runtimeerror", "problemstatement") . "\n" . $submission->submissioncomment;
                                    break;
                            }
                            break;
                        case "2":
                            $msg .= get_string("inprocess", "problemstatement");
                            break;
                    }
                    echo "<div style='text-align:left'>" . nl2br($msg) . "</div>";
                    //echo format_text($submission->programtext, 0);//$submission->data2);
                } else {
                    if (!has_capability('mod/problemstatement:submit', $context)) {
                        //fix for #4604
                        echo '<div style="text-align:center">' . get_string('guestnosubmit', 'problemstatement') . '</div>';
                    } else {
                        if ($this->isopen()) {
                            //fix for #4206
                            echo '<div style="text-align:center">' . get_string('emptysubmission', 'problemstatement') . '</div>';
                        }
                    }
                }
            }
            print_box_end();
            if (!$editmode && $editable) {
                echo "<div style='text-align:center'>";
                print_single_button('view.php', array('id' => $this->cm->id, 'edit' => '1'), get_string('editmysubmission', 'problemstatement'));
                echo "</div>";
            }
        }
        $this->view_feedback();
        $this->view_footer();
        //echo "end of view";
    }
Esempio n. 15
0
/**
 * Prints a maintenance message from /maintenance.html
 */
function print_maintenance_message()
{
    global $CFG, $SITE;
    $PAGE->set_pagetype('maintenance-message');
    print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home');
    print_box_start();
    print_heading(get_string('sitemaintenance', 'admin'));
    @(include $CFG->dataroot . '/1/maintenance.html');
    print_box_end();
    print_footer();
}
Esempio n. 16
0
function prepareQuizAttempt($q)
{
    global $DB;
    if ($id) {
        if (!($cm = get_coursemodule_from_id('quiz', $id))) {
            print_error('invalidcoursemodule');
        }
        if (!($course = $DB->get_record('course', array('id' => $cm->course)))) {
            print_error('coursemisconf');
        }
        if (!($quiz = $DB->get_record('quiz', array('id' => $cm->instance)))) {
            print_error('invalidcoursemodule');
        }
    } else {
        if (!($quiz = $DB->get_record('quiz', array('id' => $q)))) {
            print_error('invalidquizid', 'quiz');
        }
        if (!($course = $DB->get_record('course', array('id' => $quiz->course)))) {
            print_error('invalidcourseid');
        }
        if (!($cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id))) {
            print_error('invalidcoursemodule');
        }
    }
    /// Check login and get context.
    require_login($course->id, false, $cm);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    require_capability('mod/quiz:view', $context);
    /// Cache some other capabilites we use several times.
    $canattempt = has_capability('mod/quiz:attempt', $context);
    $canreviewmine = has_capability('mod/quiz:reviewmyattempts', $context);
    $canpreview = has_capability('mod/quiz:preview', $context);
    /// Create an object to manage all the other (non-roles) access rules.
    $timenow = time();
    $accessmanager = new quiz_access_manager(new quiz($quiz, $cm, $course), $timenow, has_capability('mod/quiz:ignoretimelimits', $context, NULL, false));
    /// Print information about the student's best score for this quiz if possible.
    $moreattempts = $unfinished || !$accessmanager->is_finished($numattempts, $lastfinishedattempt);
    /// Determine if we should be showing a start/continue attempt button,
    /// or a button to go back to the course page.
    print_box_start('quizattempt');
    $buttontext = '';
    // This will be set something if as start/continue attempt button should appear.
    if (!$quiz->questions) {
        print_heading(get_string("noquestions", "quiz"));
    } else {
        if ($unfinished) {
            if ($canattempt) {
                $buttontext = get_string('continueattemptquiz', 'quiz');
            } else {
                if ($canpreview) {
                    $buttontext = get_string('continuepreview', 'quiz');
                }
            }
        } else {
            if ($canattempt) {
                $messages = $accessmanager->prevent_new_attempt($numattempts, $lastfinishedattempt);
                if ($messages) {
                    $accessmanager->print_messages($messages);
                } else {
                    if ($numattempts == 0) {
                        $buttontext = get_string('attemptquiznow', 'quiz');
                    } else {
                        $buttontext = get_string('reattemptquiz', 'quiz');
                    }
                }
            } else {
                if ($canpreview) {
                    $buttontext = get_string('previewquiznow', 'quiz');
                }
            }
        }
        // If, so far, we think a button should be printed, so check if they will be allowed to access it.
        if ($buttontext) {
            if (!$moreattempts) {
                $buttontext = '';
            } else {
                if ($canattempt && ($messages = $accessmanager->prevent_access())) {
                    $accessmanager->print_messages($messages);
                    $buttontext = '';
                }
            }
        }
    }
    /// Now actually print the appropriate button.
    if ($buttontext) {
        $accessmanager->print_start_attempt_button($canpreview, $buttontext, $unfinished);
    } else {
        print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id);
    }
    print_box_end();
}
Esempio n. 17
0
/**
 * Create grade item for given quiz
 *
 * @param object $quiz object with extra cmidnumber
 * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
 * @return int 0 if ok, error code otherwise
 */
function quiz_grade_item_update($quiz, $grades = NULL)
{
    global $CFG;
    if (!function_exists('grade_update')) {
        //workaround for buggy PHP versions
        require_once $CFG->libdir . '/gradelib.php';
    }
    if (array_key_exists('cmidnumber', $quiz)) {
        //it may not be always present
        $params = array('itemname' => $quiz->name, 'idnumber' => $quiz->cmidnumber);
    } else {
        $params = array('itemname' => $quiz->name);
    }
    if ($quiz->grade > 0) {
        $params['gradetype'] = GRADE_TYPE_VALUE;
        $params['grademax'] = $quiz->grade;
        $params['grademin'] = 0;
    } else {
        $params['gradetype'] = GRADE_TYPE_NONE;
    }
    /* description by TJ:
    1/ If the quiz is set to not show scores while the quiz is still open, and is set to show scores after
       the quiz is closed, then create the grade_item with a show-after date that is the quiz close date.
    2/ If the quiz is set to not show scores at either of those times, create the grade_item as hidden.
    3/ If the quiz is set to show scores, create the grade_item visible.
    */
    if (!($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED) and !($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN)) {
        $params['hidden'] = 1;
    } else {
        if ($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED and !($quiz->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN)) {
            if ($quiz->timeclose) {
                $params['hidden'] = $quiz->timeclose;
            } else {
                $params['hidden'] = 1;
            }
        } else {
            // a) both open and closed enabled
            // b) open enabled, closed disabled - we can not "hide after", grades are kept visible even after closing
            $params['hidden'] = 0;
        }
    }
    if ($grades === 'reset') {
        $params['reset'] = true;
        $grades = NULL;
    }
    $gradebook_grades = grade_get_grades($quiz->course, 'mod', 'quiz', $quiz->id);
    if (!empty($gradebook_grades->items)) {
        $grade_item = $gradebook_grades->items[0];
        if ($grade_item->locked) {
            $confirm_regrade = optional_param('confirm_regrade', 0, PARAM_INT);
            if (!$confirm_regrade) {
                $message = get_string('gradeitemislocked', 'grades');
                $back_link = $CFG->wwwroot . '/mod/quiz/report.php?q=' . $quiz->id . '&amp;mode=overview';
                $regrade_link = qualified_me() . '&amp;confirm_regrade=1';
                print_box_start('generalbox', 'notice');
                echo '<p>' . $message . '</p>';
                echo '<div class="buttons">';
                print_single_button($regrade_link, null, get_string('regradeanyway', 'grades'), 'post', $CFG->framename);
                print_single_button($back_link, null, get_string('cancel'), 'post', $CFG->framename);
                echo '</div>';
                print_box_end();
                return GRADE_UPDATE_ITEM_LOCKED;
            }
        }
    }
    return grade_update('mod/quiz', $quiz->course, 'mod', 'quiz', $quiz->id, 0, $grades, $params);
}
Esempio n. 18
0
    function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false)
    {
        $align = get_string('thisdirection') == 'ltr' ? 'left' : 'right';
        $presentation = explode("|", $item->presentation);
        if ($highlightrequire and $item->required and strval($value) == '') {
            $highlight = 'bgcolor="#FFAAAA" class="missingrequire"';
        } else {
            $highlight = '';
        }
        $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : '';
        ?>
        <td <?php 
        echo $highlight;
        ?>
 valign="top" align="<?php 
        echo $align;
        ?>
">
        <?php 
        if ($edit or $readonly) {
            echo '(' . $item->label . ') ';
        }
        echo format_text($item->name . $requiredmark, true, false, false);
        ?>
        </td>
        <td valign="top" align="<?php 
        echo $align;
        ?>
">
    <?php 
        if ($readonly) {
            // print_simple_box_start($align);
            print_box_start('generalbox boxalign' . $align);
            echo $value ? str_replace("\n", '<br />', $value) : '&nbsp;';
            // print_simple_box_end();
            print_box_end();
        } else {
            ?>
            <textarea name="<?php 
            echo $item->typ . '_' . $item->id;
            ?>
"
                        cols="<?php 
            echo $presentation[0];
            ?>
"
                        rows="<?php 
            echo $presentation[1];
            ?>
"><?php 
            echo $value ? htmlspecialchars($value) : '';
            ?>
</textarea>
    <?php 
        }
        ?>
        </td>
    <?php 
    }
Esempio n. 19
0
 /**
  * Render the Edit mode of the Presenter (lists all the slides and allows re-ordering).
  * Called from with the {@link render()} function when necessary.
  */
 function render_edit()
 {
     //display any feedback
     if (!empty($this->feedback)) {
         echo $this->feedback;
     }
     global $CFG;
     $streditpresenter = get_string('presenter:edit', 'sloodle');
     $strviewanddelete = get_string('presenter:viewanddelete', 'sloodle');
     $strnoentries = get_string('noentries', 'sloodle');
     $strnoslides = get_string('presenter:empty', 'sloodle');
     $strdelete = get_string('delete', 'sloodle');
     $stradd = get_string('presenter:add', 'sloodle');
     $straddatend = get_string('presenter:addatend', 'sloodle');
     $straddbefore = get_string('presenter:addbefore', 'sloodle');
     $strtype = get_string('type', 'sloodle');
     $strurl = get_string('url', 'sloodle');
     $strname = get_string('name', 'sloodle');
     $stryes = get_string('yes');
     $strno = get_string('no');
     $strmove = get_string('move');
     $stredit = get_string('edit', 'sloodle');
     $strview = get_string('view', 'sloodle');
     $strdelete = get_string('delete');
     $strmoveslide = get_string('presenter:moveslide', 'sloodle');
     $streditslide = get_string('presenter:editslide', 'sloodle');
     $strviewslide = get_string('presenter:viewslide', 'sloodle');
     $strdeleteslide = get_string('presenter:deleteslide', 'sloodle');
     // Get a list of entry URLs
     $entries = $this->presenter->get_slides();
     if (!is_array($entries)) {
         $entries = array();
     }
     $numentries = count($entries);
     // Any images to display?
     if ($entries === false || count($entries) == 0) {
         echo '<h4>' . $strnoslides . '</h4>';
         echo '<h4><a href="' . SLOODLE_WWWROOT . '/view.php?id=' . $this->cm->id . '&amp;mode=addslide">' . $stradd . '</a></h4><br>';
     } else {
         // Are we being asked to confirm the deletion of a slide?
         if ($this->presenter_mode == 'confirmdeleteslide') {
             // Make sure the session key is specified and valid
             if (required_param('sesskey') != sesskey()) {
                 error('Invalid session key');
                 exit;
             }
             // Determine which slide is being deleted
             $entryid = (int) required_param('entry', PARAM_INT);
             // Make sure the specified entry is recognised
             if (isset($entries[$entryid])) {
                 // Construct our links
                 $linkYes = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}&amp;mode=deleteslide&amp;entry={$entryid}&amp;sesskey=" . sesskey();
                 $linkNo = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}&amp;mode=edit";
                 // Output our confirmation form
                 notice_yesno(get_string('presenter:confirmdelete', 'sloodle', $entries[$entryid]->name), $linkYes, $linkNo);
                 echo "<br/>";
             }
         }
         // Are we being asked to confirm the deletion of multiple slides?
         $deletingentries = array();
         if ($this->presenter_mode == 'confirmdeletemultiple') {
             // Make sure the session key is specified and valid
             if (required_param('sesskey') != sesskey()) {
                 error('Invalid session key');
                 exit;
             }
             // Grab the array of entries to be deleted
             if (isset($_REQUEST['entries'])) {
                 $deletingentries = $_REQUEST['entries'];
             }
             if (is_array($deletingentries) && count($deletingentries) > 0) {
                 // Construct our links
                 $entriesparam = '';
                 foreach ($deletingentries as $de) {
                     $entriesparam .= "entries[]={$de}&amp;";
                 }
                 $linkYes = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}&amp;mode=deletemultiple&amp;{$entriesparam}sesskey=" . sesskey();
                 $linkNo = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}&amp;mode=edit";
                 // Output our confirmation form
                 notice_yesno(get_string('presenter:confirmdeletemultiple', 'sloodle', count($deletingentries)), $linkYes, $linkNo);
                 echo "<br/>";
             } else {
                 // No slides selected.
                 // Inform the user to select slides first, and then click the button again.
                 notify(get_string('presenter:noslidesfordeletion', 'sloodle'));
             }
         }
         // Are we currently moving a slide?
         if ($this->presenter_mode == 'moveslide') {
             $linkCancel = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}&amp;mode=edit";
             $strcancel = get_string('cancel');
             // Display a message and an optional 'cancel' link
             print_box_start('generalbox', 'notice');
             echo "<p>", get_string('presenter:movingslide', 'sloodle', $entries[$this->movingentryid]->name), "</p>\n";
             echo "<p>(<a href=\"{$linkCancel}\">{$strcancel}</a>)</p>\n";
             print_box_end();
         }
         // Setup a table object to display Presenter entries
         $entriesTable = new stdClass();
         $entriesTable->head = array(get_string('position', 'sloodle'), '<div id="selectboxes"><a href="#"><div style=\'text-align:center;\' id="selectall">' . get_string('selectall', 'sloodle') . '</div></a></div>', get_string('name', 'sloodle'), get_string('type', 'sloodle'), get_string('actions', 'sloodle'));
         $entriesTable->align = array('center', 'center', 'left', 'left', 'center');
         $entriesTable->size = array('5%', '5%', '30%', '20%', '30%');
         // Go through each entry
         $numentries = count($entries);
         foreach ($entries as $entryid => $entry) {
             // Create a new row for the table
             $row = array();
             // Extract the entry data
             $slideplugin = $this->_session->plugins->get_plugin('presenter-slide', $entry->type);
             if (is_object($slideplugin)) {
                 $entrytypename = $slideplugin->get_plugin_name();
             } else {
                 $entrytypename = '(unknown type)';
             }
             // Construct the link to the entry source
             $entrylink = "<a href=\"{$entry->source}\" title=\"{$entry->source}\">{$entry->name}</a>";
             // If this is the slide being moved, then completely ignore it
             if ($this->movingentryid == $entryid) {
                 continue;
             }
             // If we are in move mode, then add a 'move here' row before this slide
             if ($this->presenter_mode == 'moveslide') {
                 $movelink = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}&amp;mode=setslideposition&amp;entry={$this->movingentryid}&amp;position={$entry->slideposition}";
                 $movebutton = "<a href=\"{$movelink}\" title=\"{$strmove}\"><img src=\"{$CFG->pixpath}/movehere.gif\" class=\"\" alt=\"{$strmove}\" /></a>\n";
                 $entriesTable->data[] = array('', '', $movebutton, '', '', '');
                 // If the current row belongs to the slide being moved, then emphasise it, and append (moving) to the end
                 if ($entryid == $this->movingentryid) {
                     $entrylink = "<strong>{$entrylink}</strong> <em>(" . get_string('moving', 'sloodle') . ')</em>';
                 }
             }
             // Define our action links
             $actionBaseLink = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}";
             $actionLinkMove = $actionBaseLink . "&amp;mode=moveslide&amp;entry={$entryid}";
             $actionLinkEdit = $actionBaseLink . "&amp;mode=editslide&amp;entry={$entryid}";
             $actionLinkView = $actionBaseLink . "&amp;mode=view&amp;sloodledisplayentry={$entry->slideposition}#slide";
             $actionLinkDelete = $actionBaseLink . "&amp;mode=confirmdeleteslide&amp;entry={$entryid}&amp;sesskey=" . sesskey();
             // Prepare the add buttons separately
             $actionLinkAdd = $actionBaseLink . "&amp;mode=addslide&amp;sloodleentryposition={$entry->slideposition}";
             $addButtons = "<a href=\"{$actionLinkAdd}\" title=\"{$straddbefore}\"><img src=\"" . SLOODLE_WWWROOT . "/lib/media/add.png\" alt=\"{$stradd}\" /></a>\n";
             // Construct our list of action buttons
             $actionButtons = '';
             $actionButtons .= "<a href=\"{$actionLinkMove}\" title=\"{$strmoveslide}\"><img src=\"{$CFG->pixpath}/t/move.gif\" class=\"iconsmall\" alt=\"{$strmove}\" /></a>\n";
             $actionButtons .= "<a href=\"{$actionLinkEdit}\" title=\"{$streditslide}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" class=\"iconsmall\" alt=\"{$stredit}\" /></a>\n";
             $actionButtons .= "<a href=\"{$actionLinkView}\" title=\"{$strviewslide}\"><img src=\"{$CFG->pixpath}/t/preview.gif\" class=\"iconsmall\" alt=\"{$strview}\" /></a>\n";
             $actionButtons .= "<a href=\"{$actionLinkDelete}\" title=\"{$strdeleteslide}\"><img src=\"{$CFG->pixpath}/t/delete.gif\" class=\"iconsmall\" alt=\"{$strdelete}\" /></a>\n";
             $actionButtons .= $addButtons;
             //create checkbox for multiple edit functions
             $checked = '';
             if (in_array($entryid, $deletingentries)) {
                 $checked = "checked=\"checked\"";
             }
             $checkbox = "<div style='text-align:center;'><input  type=\"checkbox\" name=\"entries[]\" {$checked} value=\"{$entryid}\" /></div>";
             // Add each item of data to our table row.
             // The first item is a check box for multiple deletes
             // The second items are the position and the name of the entry, hyperlinked to the resource.
             // The next is the name of the entry type.
             // The last is a list of action buttons -- move, edit, view, and delete.
             $row[] = $entry->slideposition;
             $row[] = $checkbox;
             $row[] = $entrylink;
             $row[] = $entrytypename;
             $row[] = $actionButtons;
             // Add the row to our table
             $entriesTable->data[] = $row;
         }
         // If we are in move mode, then add a final 'move here' row at the bottom
         // We need to add a final row at the bottom
         // Prepare the action link for this row
         $endentrynum = $entry->slideposition + 1;
         $actionLinkAdd = $actionBaseLink . "&amp;mode=addslide&amp;sloodleentryposition={$endentrynum}";
         $addButtons = "<a href=\"{$actionLinkAdd}\" title=\"{$straddatend}\"><img src=\"" . SLOODLE_WWWROOT . "/lib/media/add.png\" alt=\"{$stradd}\" /></a>\n";
         $sloodleInsert = get_string("presenter:sloodleinsert", "sloodle");
         // It will contain a last 'add' button, and possibly a 'move here' button too (if we are in move mode)
         $movebutton = '';
         if ($this->presenter_mode == 'moveslide') {
             $movelink = SLOODLE_WWWROOT . "/view.php?id={$this->cm->id}&amp;mode=setslideposition&amp;entry={$this->movingentryid}&amp;position={$endentrynum}";
             $movebutton = "<a href=\"{$movelink}\" title=\"{$strmove}\"><img src=\"{$CFG->pixpath}/movehere.gif\" class=\"\" alt=\"{$strmove}\" /></a>\n";
         }
         // Add a button to delete all selected slides
         $deleteButton = '<input type="submit" value="' . get_string('deleteselected', 'sloodle') . '" />';
         $entriesTable->data[] = array('', ' <div id="selectboxes2"><a href="#"><div style=\'text-align:center;\' id="selectall2">' . get_string('selectall', 'sloodle') . '</div></a></div>', $movebutton, '', $deleteButton . '&nbsp;&nbsp;' . $addButtons);
         // Put our table inside a form to allow us to delete multiple slides based on the checkboxes
         echo '<form action="" method="get" id="editform" name="editform">';
         echo "<input type=\"hidden\" name=\"id\" value=\"{$this->cm->id}\" />\n";
         // Course module ID so that the request comes to the right places
         echo "<input type=\"hidden\" name=\"mode\" value=\"confirmdeletemultiple\" />\n";
         // The operation being conducted
         print_table($entriesTable);
         echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />\n";
         // Session key to ensure unauthorised deletions are not possible (e.g. using XSS)
         echo '</form>';
     }
 }
Esempio n. 20
0
    function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false)
    {
        global $USER, $DB;
        $align = get_string('thisdirection') == 'ltr' ? 'left' : 'right';
        $presentation = $item->presentation;
        if ($highlightrequire and $item->required and strval($value) == '') {
            $highlight = 'bgcolor="#FFAAAA" class="missingrequire"';
        } else {
            $highlight = '';
        }
        $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : '';
        ?>
        <td <?php 
        echo $highlight;
        ?>
 valign="top" align="<?php 
        echo $align;
        ?>
">
        <?php 
        if ($edit or $readonly) {
            echo '(' . $item->label . ') ';
        }
        echo format_text($item->name . $requiredmark, true, false, false);
        ?>
        </td>
        <td valign="top" align="<?php 
        echo $align;
        ?>
">
    <?php 
        if ($readonly) {
            // print_simple_box_start($align);
            print_box_start('generalbox boxalign' . $align);
            echo $value ? UserDate($value) : '&nbsp;';
            // print_simple_box_end();
            print_box_end();
        } else {
            $feedback = $DB->get_record('feedback', array('id' => $item->feedback));
            $course = $DB->get_record('course', array('id' => $feedback->course));
            $coursecategory = $DB->get_record('course_categories', array('id' => $course->category));
            switch ($presentation) {
                case 1:
                    $itemvalue = time();
                    $itemshowvalue = UserDate($itemvalue);
                    break;
                case 2:
                    $itemvalue = $course->shortname;
                    $itemshowvalue = $itemvalue;
                    break;
                case 3:
                    $itemvalue = $coursecategory->name;
                    $itemshowvalue = $itemvalue;
                    break;
            }
            ?>
            <input type="hidden" name="<?php 
            echo $item->typ . '_' . $item->id;
            ?>
"
                                    value="<?php 
            echo $itemvalue;
            ?>
" />
            <span><?php 
            echo $itemshowvalue;
            ?>
</span>
    <?php 
        }
        ?>
        </td>
    <?php 
    }
function sloodle_display_config_form($sloodleauthid, $auth_obj)
{
    //--------------------------------------------------------
    // SETUP
    // Determine which course is being accessed
    $courseid = $auth_obj->course->get_course_id();
    // If your object is going to link into an existing module in Moodle, e.g. chatrooms, then you need to get a list all such module instances in the course.
    // We will be using chatrooms for this example.
    // First, we need to figure out what the ID number for the 'chat' type is.
    $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) {
        // No visible chatrooms -- output an error message
        error(get_string('nochatrooms', 'sloodle'));
        // This comes from the SLOODLE language pack
        exit;
    }
    // Go through each chatroom we were given
    $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);
    // We now have an alphabetically-sorted array, associating course module instance IDs with chatroom names.
    // We can use that to let the user know what chatrooms are available.
    //--------------------------------------------------------
    // FORM
    // If the object is already configured, then we need to get its current configuration.
    // This function will grab an array of configuration settings from the database.
    $settings = SloodleController::get_object_configuration($sloodleauthid);
    // Use the "sloodle_get_value" function to extract specific settings from the array.
    // The second argument names the parameter, and the 3rd gives the default initial value.
    $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0);
    $sloodlerandomtext = sloodle_get_value($settings, 'sloodlerandomtext', 'foobar');
    $sloodleshowhovertext = (int) sloodle_get_value($settings, 'sloodleshowhovertext', 1);
    ///// GENERAL CONFIGURATION /////
    // We will now display the configuration form.
    // Create a new section box for general configuration options
    print_box_start('generalbox boxaligncenter');
    echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>';
    // Display a drop-down menu (using a Moodle function) to let the user choose the module.
    // In this case, we are showing them a list of chatrooms.
    // This is a very common part of the configuration form.
    echo get_string('selectchatroom', 'sloodle') . ': ';
    choose_from_menu($chatrooms, 'sloodlemoduleid', $sloodlemoduleid, '');
    echo "<br><br>\n";
    // Display a text box for some random text
    echo 'Enter some text: ';
    // Ideally this should be replaced by "get_string(...)"
    echo '<input type="text" name="sloodlerandomtext" id="sloodlerandomtext" value="' . $sloodlerandomtext . '" size="20" maxlength="20" />';
    echo "<br><br>\n";
    // Display a yes/no drop down menu.
    // NOTE: we can't use checkboxes! Yes/no responses must be done as drop-down menus.
    echo 'Show hover text? ';
    // Ideally this should be replaced by "get_string(...)"
    choose_from_menu_yesno('sloodleshowhovertext', $sloodleshowhovertext);
    echo "<br>\n";
    // Close the general section
    print_box_end();
    ///// ACCESS LEVELS /////
    // This is common to nearly all objects, although variations are possible.
    // There are 3 access settings, in two categories:
    //  In-world: use and control
    //  Server: access
    //
    // The in-world 'use' setting determines who can generally use the object, whether it is public, limited to an SL group, or owner-only. (Public by default)
    // The in-world 'control' setting determines who has authority to control the object, which can similarly be public, group, or owner-only. (Owner-only by default)
    // The server access lets you limit usage to avatars which are registered or enrolled, or to members of staff. By default though, it is public.
    //
    // The following function displays the appropriate form data.
    // We pass in the existing settings so that it can setup defaults.
    // The subsequent 3 parameters determine if each type of access setting should be visible, in the order specified above.
    // They are optional, and all default to true if not specified.
    sloodle_print_access_level_options($settings, true, true, true);
}
Esempio n. 22
0
 function output_html($data, $query = '')
 {
     global $CFG;
     $strname = get_string('name');
     $strhide = get_string('disable');
     $strshow = get_string('enable');
     $strhideshow = "{$strhide}/{$strshow}";
     $strsettings = get_string('settings');
     $strup = get_string('up');
     $strdown = get_string('down');
     $strupdown = "{$strup}/{$strdown}";
     // get a list of possible filters (and translate name if possible)
     // note filters can be in the dedicated filters area OR in their
     // associated modules
     $installedfilters = array();
     $filtersettings_new = array();
     $filtersettings_old = array();
     $filterlocations = array('mod', 'filter');
     foreach ($filterlocations as $filterlocation) {
         $plugins = get_list_of_plugins($filterlocation);
         foreach ($plugins as $plugin) {
             $pluginpath = "{$CFG->dirroot}/{$filterlocation}/{$plugin}/filter.php";
             $settingspath_new = "{$CFG->dirroot}/{$filterlocation}/{$plugin}/filtersettings.php";
             $settingspath_old = "{$CFG->dirroot}/{$filterlocation}/{$plugin}/filterconfig.html";
             if (is_readable($pluginpath)) {
                 $name = trim(get_string("filtername", $plugin));
                 if (empty($name) or $name == '[[filtername]]') {
                     $textlib = textlib_get_instance();
                     $name = $textlib->strtotitle($plugin);
                 }
                 $installedfilters["{$filterlocation}/{$plugin}"] = $name;
                 if (is_readable($settingspath_new)) {
                     $filtersettings_new[] = "{$filterlocation}/{$plugin}";
                 } else {
                     if (is_readable($settingspath_old)) {
                         $filtersettings_old[] = "{$filterlocation}/{$plugin}";
                     }
                 }
             }
         }
     }
     // get all the currently selected filters
     if (!empty($CFG->textfilters)) {
         $oldactivefilters = explode(',', $CFG->textfilters);
         $oldactivefilters = array_unique($oldactivefilters);
     } else {
         $oldactivefilters = array();
     }
     // take this opportunity to clean up filters
     $activefilters = array();
     foreach ($oldactivefilters as $oldactivefilter) {
         if (!empty($oldactivefilter) and array_key_exists($oldactivefilter, $installedfilters)) {
             $activefilters[] = $oldactivefilter;
         }
     }
     // construct the display array with installed filters
     // at the top in the right order
     $displayfilters = array();
     foreach ($activefilters as $activefilter) {
         $name = $installedfilters[$activefilter];
         $displayfilters[$activefilter] = $name;
     }
     foreach ($installedfilters as $key => $filter) {
         if (!array_key_exists($key, $displayfilters)) {
             $displayfilters[$key] = $filter;
         }
     }
     $return = print_heading(get_string('actfilterhdr', 'filters'), '', 3, 'main', true);
     $return .= print_box_start('generalbox filtersui', '', true);
     $table = new object();
     $table->head = array($strname, $strhideshow, $strupdown, $strsettings);
     $table->align = array('left', 'center', 'center', 'center');
     $table->width = '90%';
     $table->data = array();
     $filtersurl = "{$CFG->wwwroot}/{$CFG->admin}/filters.php?sesskey=" . sesskey();
     $imgurl = "{$CFG->pixpath}/t";
     // iterate through filters adding to display table
     $updowncount = 1;
     $activefilterscount = count($activefilters);
     foreach ($displayfilters as $path => $name) {
         $upath = urlencode($path);
         // get hide/show link
         if (in_array($path, $activefilters)) {
             $hideshow = "<a href=\"{$filtersurl}&amp;action=hide&amp;filterpath={$upath}\">";
             $hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"{$strhide}\" /></a>";
             $hidden = false;
             $displayname = "<span>{$name}</span>";
         } else {
             $hideshow = "<a href=\"{$filtersurl}&amp;action=show&amp;filterpath={$upath}\">";
             $hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"{$strshow}\" /></a>";
             $hidden = true;
             $displayname = "<span class=\"dimmed_text\">{$name}</span>";
         }
         // get up/down link (only if not hidden)
         $updown = '';
         if (!$hidden) {
             if ($updowncount > 1) {
                 $updown .= "<a href=\"{$filtersurl}&amp;action=up&amp;filterpath={$upath}\">";
                 $updown .= "<img src=\"{$imgurl}/up.gif\" alt=\"{$strup}\" /></a>&nbsp;";
             } else {
                 $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />&nbsp;";
             }
             if ($updowncount < $activefilterscount) {
                 $updown .= "<a href=\"{$filtersurl}&amp;action=down&amp;filterpath={$upath}\">";
                 $updown .= "<img src=\"{$imgurl}/down.gif\" alt=\"{$strdown}\" /></a>";
             } else {
                 $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />";
             }
             ++$updowncount;
         }
         // settings link (if defined)
         $settings = '';
         if (in_array($path, $filtersettings_new)) {
             $settings = "<a href=\"settings.php?section=filtersetting" . str_replace('/', '', $path) . "\">{$strsettings}</a>";
         } else {
             if (in_array($path, $filtersettings_old)) {
                 $settings = "<a href=\"filter.php?filter=" . urlencode($path) . "\">{$strsettings}</a>";
             }
         }
         // write data into the table object
         $table->data[] = array($displayname, $hideshow, $updown, $settings);
     }
     $return .= print_table($table, true);
     $return .= get_string('tablenosave', 'filters');
     $return .= print_box_end(true);
     return highlight($query, $return);
 }
Esempio n. 23
0
/**
 * Prints a menu for jumping from page to page
 *
 * @return void
 **/
function page_print_jump_menu()
{
    global $PAGE;
    if ($pages = page_get_all_pages($PAGE->get_id(), 'flat')) {
        $current = $PAGE->get_formatpage();
        $options = array();
        foreach ($pages as $page) {
            $options[$page->id] = page_name_menu($page->nameone, $page->depth);
        }
        print_box_start('centerpara pagejump');
        popup_form($PAGE->url_build('page'), $options, 'editpage', $current->id, get_string('choosepagetoedit', 'format_page'));
        print_box_end();
    }
}
Esempio n. 24
0
/**
 * Abstracted version of box_end() / print_box_end() to work with Moodle 1.8 through 2.0
 *
 * @param boolean Return the output or print it to screen directly
 * @return string the HTML to output.
 */
function turnitintool_box_end($return = false)
{
    global $OUTPUT;
    if (is_callable(array($OUTPUT, 'box_end')) and !$return) {
        echo $OUTPUT->box_end();
    } else {
        if (is_callable(array($OUTPUT, 'box_end'))) {
            return $OUTPUT->box_end();
        } else {
            return print_box_end($return);
        }
    }
}
Esempio n. 25
0
/**
 * Prints an individual user box
 *
 * @param $user user object (contains the following fields: id, firstname, lastname and picture)
 * @param $return if true return html string
 */
function tag_print_user_box($user, $return = false)
{
    global $CFG;
    $textlib = textlib_get_instance();
    $usercontext = get_context_instance(CONTEXT_USER, $user->id);
    $profilelink = '';
    if (has_capability('moodle/user:viewdetails', $usercontext) || isteacherinanycourse($user->id)) {
        $profilelink = $CFG->wwwroot . '/user/view.php?id=' . $user->id;
    }
    $output = print_box_start('user-box', 'user' . $user->id, true);
    $fullname = fullname($user);
    $alt = '';
    if (!empty($profilelink)) {
        $output .= '<a href="' . $profilelink . '">';
        $alt = $fullname;
    }
    //print user image - if image is only content of link it needs ALT text!
    if ($user->picture) {
        $output .= '<img alt="' . $alt . '" class="user-image" src="' . $CFG->wwwroot . '/user/pix.php/' . $user->id . '/f1.jpg" />';
    } else {
        $output .= '<img alt="' . $alt . '" class="user-image" src="' . $CFG->wwwroot . '/pix/u/f1.png" />';
    }
    $output .= '<br />';
    if (!empty($profilelink)) {
        $output .= '</a>';
    }
    //truncate name if it's too big
    if ($textlib->strlen($fullname) > 26) {
        $fullname = $textlib->substr($fullname, 0, 26) . '...';
    }
    $output .= '<strong>' . $fullname . '</strong>';
    $output .= print_box_end(true);
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Esempio n. 26
0
 function output_quiz_info_table($course, $cm, $quiz, $quizstats, $usingattemptsstring, $currentgroup, $groupstudents, $useallattempts, $download, $reporturl, $everything)
 {
     global $DB;
     // Print information on the number of existing attempts
     $quizinformationtablehtml = print_heading(get_string('quizinformation', 'quiz_statistics'), '', 2, 'main', true);
     $quizinformationtable = new object();
     $quizinformationtable->align = array('center', 'center');
     $quizinformationtable->width = '60%';
     $quizinformationtable->class = 'generaltable titlesleft';
     $quizinformationtable->data = array();
     $quizinformationtable->data[] = array(get_string('quizname', 'quiz_statistics'), $quiz->name);
     $quizinformationtable->data[] = array(get_string('coursename', 'quiz_statistics'), $course->fullname);
     if ($cm->idnumber) {
         $quizinformationtable->data[] = array(get_string('idnumbermod'), $cm->idnumber);
     }
     if ($quiz->timeopen) {
         $quizinformationtable->data[] = array(get_string('quizopen', 'quiz'), userdate($quiz->timeopen));
     }
     if ($quiz->timeclose) {
         $quizinformationtable->data[] = array(get_string('quizclose', 'quiz'), userdate($quiz->timeclose));
     }
     if ($quiz->timeopen && $quiz->timeclose) {
         $quizinformationtable->data[] = array(get_string('duration', 'quiz_statistics'), format_time($quiz->timeclose - $quiz->timeopen));
     }
     $format = array('firstattemptscount' => '', 'allattemptscount' => '', 'firstattemptsavg' => 'sumgrades_as_percentage', 'allattemptsavg' => 'sumgrades_as_percentage', 'median' => 'sumgrades_as_percentage', 'standarddeviation' => 'sumgrades_as_percentage', 'skewness' => '', 'kurtosis' => '', 'cic' => 'number_format', 'errorratio' => 'number_format', 'standarderror' => 'sumgrades_as_percentage');
     foreach ($quizstats as $property => $value) {
         if (!isset($format[$property])) {
             continue;
         }
         if (!is_null($value)) {
             switch ($format[$property]) {
                 case 'sumgrades_as_percentage':
                     $formattedvalue = quiz_report_scale_sumgrades_as_percentage($value, $quiz);
                     break;
                 case 'number_format':
                     $formattedvalue = quiz_format_grade($quiz, $value) . '%';
                     break;
                 default:
                     $formattedvalue = $value;
             }
             $quizinformationtable->data[] = array(get_string($property, 'quiz_statistics', $usingattemptsstring), $formattedvalue);
         }
     }
     if (!$this->table->is_downloading()) {
         if (isset($quizstats->timemodified)) {
             list($fromqa, $whereqa, $qaparams) = quiz_report_attempts_sql($quiz->id, $currentgroup, $groupstudents, $useallattempts);
             $sql = 'SELECT COUNT(1) ' . 'FROM ' . $fromqa . ' ' . 'WHERE ' . $whereqa . ' AND qa.timefinish > :time';
             $a = new object();
             $a->lastcalculated = format_time(time() - $quizstats->timemodified);
             if (!($a->count = $DB->count_records_sql($sql, array('time' => $quizstats->timemodified) + $qaparams))) {
                 $a->count = 0;
             }
             $quizinformationtablehtml .= print_box_start('boxaligncenter generalbox boxwidthnormal mdl-align', '', true);
             $quizinformationtablehtml .= get_string('lastcalculated', 'quiz_statistics', $a);
             $quizinformationtablehtml .= print_single_button($reporturl->out(true), $reporturl->params() + array('recalculate' => 1), get_string('recalculatenow', 'quiz_statistics'), 'post', '', true);
             $quizinformationtablehtml .= print_box_end(true);
         }
         $downloadoptions = $this->table->get_download_menu();
         $quizinformationtablehtml .= '<form action="' . $this->table->baseurl . '" method="post">';
         $quizinformationtablehtml .= '<div class="mdl-align">';
         $quizinformationtablehtml .= '<input type="hidden" name="everything" value="1"/>';
         $quizinformationtablehtml .= '<input type="submit" value="' . get_string('downloadeverything', 'quiz_statistics') . '"/>';
         $quizinformationtablehtml .= choose_from_menu($downloadoptions, 'download', $this->table->defaultdownloadformat, '', '', '', true);
         $quizinformationtablehtml .= helpbutton('tableexportformats', get_string('tableexportformats', 'table'), 'moodle', true, false, '', true);
         $quizinformationtablehtml .= '</div></form>';
     }
     $quizinformationtablehtml .= print_table($quizinformationtable, true);
     if (!$this->table->is_downloading()) {
         echo $quizinformationtablehtml;
     } elseif ($everything) {
         $exportclass =& $this->table->export_class_instance();
         if ($download == 'xhtml') {
             echo $quizinformationtablehtml;
         } else {
             $exportclass->start_table(get_string('quizinformation', 'quiz_statistics'));
             $headers = array();
             $row = array();
             foreach ($quizinformationtable->data as $data) {
                 $headers[] = $data[0];
                 $row[] = $data[1];
             }
             $exportclass->output_headers($headers);
             $exportclass->add_data($row);
             $exportclass->finish_table();
         }
     }
 }
Esempio n. 27
0
    function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false)
    {
        $info = $this->get_info($item);
        $align = get_string('thisdirection') == 'ltr' ? 'left' : 'right';
        $presentation = explode(FEEDBACK_MULTICHOICE_LINE_SEP, stripslashes_safe($info->presentation));
        //test if required and no value is set so we have to mark this item
        //we have to differ check and the other subtypes
        if ($info->subtype == 'c') {
            if (is_array($value)) {
                $values = $value;
            } else {
                $values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
            }
            if ($highlightrequire and $item->required and $values[0] == '') {
                $highlight = 'bgcolor="#FFAAAA" class="missingrequire"';
            } else {
                $highlight = '';
            }
            $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : '';
            echo '<td ' . $highlight . ' valign="top" align="' . $align . '">' . format_text(stripslashes_safe($item->name) . $requiredmark, true, false, false) . '</td>';
            echo '<td valign="top" align="' . $align . '">';
        } else {
            if ($highlightrequire and $item->required and intval($value) <= 0) {
                $highlight = 'bgcolor="#FFAAAA" class="missingrequire"';
            } else {
                $highlight = '';
            }
            $requiredmark = $item->required == 1 ? '<span class="feedback_required_mark">*</span>' : '';
            ?>
                <td <?php 
            echo $highlight;
            ?>
 valign="top" align="<?php 
            echo $align;
            ?>
"><?php 
            echo format_text(stripslashes_safe($item->name) . $requiredmark, true, false, false);
            ?>
</td>
                <td valign="top" align="<?php 
            echo $align;
            ?>
">
            <?php 
        }
        $index = 1;
        $checked = '';
        if ($readonly) {
            if ($info->subtype == 'c') {
                print_box_start('generalbox boxalign' . $align);
                foreach ($presentation as $pres) {
                    foreach ($values as $val) {
                        if ($val == $index) {
                            echo text_to_html($pres . '<br />', true, false, false);
                            break;
                        }
                    }
                    $index++;
                }
                // print_simple_box_end();
                print_box_end();
            } else {
                foreach ($presentation as $pres) {
                    if ($value == $index) {
                        // print_simple_box_start($align);
                        print_box_start('generalbox boxalign' . $align);
                        echo text_to_html($pres, true, false, false);
                        // print_simple_box_end();
                        print_box_end();
                        break;
                    }
                    $index++;
                }
            }
        } else {
            //print the "not_selected" item on radiobuttons
            if ($info->subtype == 'r') {
                ?>
                <table><tr>
                <td valign="top" align="<?php 
                echo $align;
                ?>
"><input type="radio"
                        name="<?php 
                echo $item->typ . '_' . $item->id;
                ?>
"
                        id="<?php 
                echo $item->typ . '_' . $item->id . '_xxx';
                ?>
"
                        value="" <?php 
                echo $value ? '' : 'checked="checked"';
                ?>
 />
                </td>
                <td align="<?php 
                echo $align;
                ?>
">
                    <label for="<?php 
                echo $item->typ . '_' . $item->id . '_xxx';
                ?>
"><?php 
                print_string('not_selected', 'feedback');
                ?>
&nbsp;</label>
                </td>
                </tr></table>
    <?php 
            }
            if ($info->subtype != 'd') {
                if ($info->horizontal) {
                    echo '<table><tr>';
                }
            }
            switch ($info->subtype) {
                case 'r':
                    $this->print_item_radio($presentation, $item, $value, $info, $align);
                    break;
                case 'c':
                    $this->print_item_check($presentation, $item, $value, $info, $align);
                    break;
                case 'd':
                    $this->print_item_dropdown($presentation, $item, $value, $info, $align);
                    break;
            }
            if ($info->subtype != 'd') {
                if ($info->horizontal) {
                    echo '</tr></table>';
                }
            }
            /*
            if($item->required == 1) {
                echo '<input type="hidden" name="'.$item->typ . '_' . $item->id.'" value="1" />';
            }
            */
        }
        ?>
        </td>
    <?php 
    }
Esempio n. 28
0
/**
 * Prints a maintenance message from /maintenance.html
 */
function print_maintenance_message()
{
    global $CFG, $SITE;
    $CFG->pagepath = "index.php";
    print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home');
    print_box_start();
    print_heading(get_string('sitemaintenance', 'admin'));
    @(include $CFG->dataroot . '/' . SITEID . '/maintenance.html');
    print_box_end();
    print_footer();
}
Esempio n. 29
0
                         print_courses(0);
                     }
                 }
                 break;
             case FRONTPAGECATEGORYNAMES:
                 print_heading_block(get_string('categories'));
                 print_box_start('generalbox categorybox');
                 print_whole_category_list(NULL, NULL, NULL, -1, false);
                 print_box_end();
                 print_course_search('', false, 'short');
                 break;
             case FRONTPAGECATEGORYCOMBO:
                 print_heading_block(get_string('categories'));
                 print_box_start('generalbox categorybox');
                 print_whole_category_list(NULL, NULL, NULL, -1, true);
                 print_box_end();
                 print_course_search('', false, 'short');
                 break;
             case FRONTPAGETOPICONLY:
                 // Do nothing!!  :-)
                 break;
         }
         echo '<br />';
     }
     print_container_end();
     echo '</td>';
     break;
 case 'right':
     // The right column
     if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing || $PAGE->user_allowed_editing()) {
         echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
Esempio n. 30
0
 protected function print_choose_category_message($categoryandcontext)
 {
     print_box_start('generalbox questionbank');
     $this->display_category_form($this->contexts->having_one_edit_tab_cap('edit'), $this->baseurl, $categoryandcontext);
     echo "<p style=\"text-align:center;\"><b>";
     print_string('selectcategoryabove', 'quiz');
     echo "</b></p>";
     print_box_end();
 }