Ejemplo n.º 1
0
 function display_search_field($content = '')
 {
     global $CFG, $DB, $OUTPUT;
     $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 $OUTPUT->select(html_select::make($options, 'f_' . $this->field->id, $content, ' '));
 }
Ejemplo n.º 2
0
 function display_search_field($value = '')
 {
     global $CFG, $DB, $OUTPUT;
     $lats = $DB->get_records_sql_menu('SELECT id, content FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
     $longs = $DB->get_records_sql_menu('SELECT id, content1 FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
     $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 $OUTPUT->select(html_select::make($options, 'f_' . $this->field->id, $value));
 }
Ejemplo n.º 3
0
 function display_search_field($value = '')
 {
     global $CFG, $DB, $OUTPUT;
     $temp = $DB->get_records_sql_menu('SELECT id, content FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
     $options = array();
     if (!empty($temp)) {
         $options[''] = '';
         //Make first index blank.
         foreach ($temp as $key) {
             $options[$key] = $key;
             //Build following indicies from the sql.
         }
     }
     return $OUTPUT->select(html_select::make($options, 'f_' . $this->field->id, $value));
 }
Ejemplo n.º 4
0
 function output_quiz_info_table($course, $cm, $quiz, $quizstats, $usingattemptsstring, $currentgroup, $groupstudents, $useallattempts, $download, $reporturl, $everything)
 {
     global $DB, $OUTPUT;
     // Print information on the number of existing attempts
     $quizinformationtablehtml = $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'), 2, 'main');
     $quizinformationtable = new html_table();
     $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 .= $OUTPUT->box_start('boxaligncenter generalbox boxwidthnormal mdl-align');
             $quizinformationtablehtml .= get_string('lastcalculated', 'quiz_statistics', $a);
             $quizinformationtablehtml .= $OUTPUT->button(html_form::make_button($reporturl->out(true), $reporturl->params() + array('recalculate' => 1), get_string('recalculatenow', 'quiz_statistics')));
             $quizinformationtablehtml .= $OUTPUT->box_end();
         }
         $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') . '"/>';
         $select = html_select::make($downloadoptions, 'download', $this->table->defaultdownloadformat, false);
         $select->nothingvalue = '';
         $quizinformationtablehtml .= $OUTPUT->select($select);
         $quizinformationtablehtml .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table')));
         $quizinformationtablehtml .= '</div></form>';
     }
     $quizinformationtablehtml .= $OUTPUT->table($quizinformationtable);
     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();
         }
     }
 }
Ejemplo n.º 5
0
function hotpot_print_report_selector(&$course, &$hotpot, &$formdata)
{
    global $CFG, $DB, $OUTPUT;
    $reports = hotpot_get_report_names('overview,simplestat,fullstat');
    print '<form method="post" action="' . "{$CFG->wwwroot}/mod/hotpot/report.php?hp={$hotpot->id}" . '">';
    print '<table cellpadding="2" align="center">';
    $menus = array();
    $menus['mode'] = array();
    foreach ($reports as $name) {
        if ($name == 'overview' || $name == 'simplestat' || $name == 'fullstat') {
            $module = "quiz";
            // standard reports
        } else {
            if ($name == 'click' && empty($hotpot->clickreporting)) {
                $module = "";
                // clickreporting is disabled
            } else {
                $module = "hotpot";
                // custom reports
            }
        }
        if ($module) {
            $menus['mode'][$name] = get_string("report{$name}", $module);
        }
    }
    $menus['reportusers'] = array('allusers' => get_string('allusers', 'hotpot'), 'allparticipants' => get_string('allparticipants'));
    // groups
    if ($groups = groups_get_all_groups($course->id)) {
        foreach ($groups as $gid => $group) {
            $menus['reportusers']["group{$gid}"] = get_string('group') . ': ' . format_string($group->name);
        }
    }
    // get users who have ever atetmpted this HotPot
    $users = $DB->get_records_sql("\n        SELECT \n            u.id, u.firstname, u.lastname\n        FROM \n            {user} u,\n            {hotpot_attempts} ha\n        WHERE\n            u.id = ha.userid AND ha.hotpot=?\n        ORDER BY\n            u.lastname\n    ", array($hotpot->id));
    if (!empty($users)) {
        // get context
        $cm = get_coursemodule_from_instance('hotpot', $hotpot->id);
        $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
        $teachers = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:viewreport');
        $students = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:attempt');
        // current students
        if (!empty($students)) {
            $firsttime = true;
            foreach ($users as $user) {
                if (array_key_exists($user->id, $teachers)) {
                    continue;
                    // skip teachers
                }
                if (array_key_exists($user->id, $students)) {
                    if ($firsttime) {
                        $firsttime = false;
                        // so we only do this once
                        $menus['reportusers']['existingstudents'] = get_string('existingstudents');
                        $menus['reportusers'][] = '------';
                    }
                    $menus['reportusers']["{$user->id}"] = fullname($user);
                    unset($users[$user->id]);
                }
            }
            unset($students);
        }
        // others (former students, teachers, admins, course creators)
        $firsttime = true;
        foreach ($users as $user) {
            if ($firsttime) {
                $firsttime = false;
                // so we only do this once
                $menus['reportusers'][] = '======';
            }
            $menus['reportusers']["{$user->id}"] = fullname($user);
        }
    }
    $menus['reportattempts'] = array('all' => get_string('attemptsall', 'hotpot'), 'best' => get_string('attemptsbest', 'hotpot'), 'first' => get_string('attemptsfirst', 'hotpot'), 'last' => get_string('attemptslast', 'hotpot'));
    print '<tr><td>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('reportcontent', get_string('reportcontent', 'hotpot'), 'hotpot'));
    print '</td><th align="right" scope="col">' . get_string('reportcontent', 'hotpot') . ':</th><td colspan="7">';
    foreach ($menus as $name => $options) {
        $value = $formdata[$name];
        print $OUTPUT->select(html_select::make($options, $name, $value, false));
    }
    print '<input type="submit" value="' . get_string('reportbutton', 'hotpot') . '" /></td></tr>';
    $menus = array();
    $menus['reportformat'] = array();
    $menus['reportformat']['htm'] = get_string('reportformathtml', 'hotpot');
    if (file_exists("{$CFG->libdir}/excel") || file_exists("{$CFG->libdir}/excellib.class.php")) {
        $menus['reportformat']['xls'] = get_string('reportformatexcel', 'hotpot');
    }
    $menus['reportformat']['txt'] = get_string('reportformattext', 'hotpot');
    if (trim($CFG->hotpot_excelencodings)) {
        $menus['reportencoding'] = array(get_string('none') => '');
        $encodings = explode(',', $CFG->hotpot_excelencodings);
        foreach ($encodings as $encoding) {
            $encoding = trim($encoding);
            if ($encoding) {
                $menus['reportencoding'][$encoding] = $encoding;
            }
        }
    }
    $menus['reportwrapdata'] = array('1' => get_string('yes'), '0' => get_string('no'));
    $menus['reportshowlegend'] = array('1' => get_string('yes'), '0' => get_string('no'));
    print '<tr><td>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('reportformat', get_string('reportformat', 'hotpot'), 'hotpot'));
    print '</td>';
    foreach ($menus as $name => $options) {
        $value = $formdata[$name];
        print '<th align="right" scope="col">' . get_string($name, 'hotpot') . ':</th><td>' . $OUTPUT->select(html_select::make($options, $name, $value, false)) . '</td>';
    }
    print '</tr>';
    print '</table>';
    print '<hr size="1" noshade="noshade" />';
    print '</form>' . "\n";
}
Ejemplo n.º 6
0
 /**
  * Builds and return the HTML rows of the table (grades headed by student).
  * @return string HTML
  */
 public function get_studentshtml()
 {
     global $CFG, $USER, $DB, $OUTPUT;
     $studentshtml = '';
     $strfeedback = $this->get_lang_string("feedback");
     $strgrade = $this->get_lang_string('grade');
     $gradetabindex = 1;
     $numusers = count($this->users);
     $showuserimage = $this->get_pref('showuserimage');
     $showuseridnumber = $this->get_pref('showuseridnumber');
     $fixedstudents = $this->is_fixed_students();
     // Preload scale objects for items with a scaleid
     $scales_list = array();
     $tabindices = array();
     foreach ($this->gtree->get_items() as $item) {
         if (!empty($item->scaleid)) {
             $scales_list[] = $item->scaleid;
         }
         $tabindices[$item->id]['grade'] = $gradetabindex;
         $tabindices[$item->id]['feedback'] = $gradetabindex + $numusers;
         $gradetabindex += $numusers * 2;
     }
     $scales_array = array();
     if (!empty($scales_list)) {
         $scales_array = $DB->get_records_list('scale', 'id', $scales_list);
     }
     $row_classes = array(' even ', ' odd ');
     $row_classes = array(' even ', ' odd ');
     foreach ($this->users as $userid => $user) {
         if ($this->canviewhidden) {
             $altered = array();
             $unknown = array();
         } else {
             $hiding_affected = grade_grade::get_hiding_affected($this->grades[$userid], $this->gtree->get_items());
             $altered = $hiding_affected['altered'];
             $unknown = $hiding_affected['unknown'];
             unset($hiding_affected);
         }
         $columncount = 0;
         if ($fixedstudents) {
             $studentshtml .= '<tr class="r' . $this->rowcount++ . $row_classes[$this->rowcount % 2] . '">';
         } else {
             // Student name and link
             $user_pic = null;
             if ($showuserimage) {
                 $user_pic = '<div class="userpic">' . $OUTPUT->user_picture(moodle_user_picture::make($user, $this->courseid)) . '</div>';
             }
             $studentshtml .= '<tr class="r' . $this->rowcount++ . $row_classes[$this->rowcount % 2] . '">' . '<th class="c' . $columncount++ . ' user" scope="row" onclick="set_row(this.parentNode.rowIndex);">' . $user_pic . '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $this->course->id . '">' . fullname($user) . '</a></th>';
             if ($showuseridnumber) {
                 $studentshtml .= '<th class="c' . $columncount++ . ' useridnumber" onclick="set_row(this.parentNode.rowIndex);">' . $user->idnumber . '</th>';
             }
         }
         foreach ($this->gtree->items as $itemid => $unused) {
             $item =& $this->gtree->items[$itemid];
             $grade = $this->grades[$userid][$item->id];
             // Get the decimal points preference for this item
             $decimalpoints = $item->get_decimals();
             if (in_array($itemid, $unknown)) {
                 $gradeval = null;
             } else {
                 if (array_key_exists($itemid, $altered)) {
                     $gradeval = $altered[$itemid];
                 } else {
                     $gradeval = $grade->finalgrade;
                 }
             }
             // MDL-11274
             // Hide grades in the grader report if the current grader doesn't have 'moodle/grade:viewhidden'
             if (!$this->canviewhidden and $grade->is_hidden()) {
                 if (!empty($CFG->grade_hiddenasdate) and $grade->get_datesubmitted() and !$item->is_category_item() and !$item->is_course_item()) {
                     // the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records
                     $studentshtml .= '<td class="cell c' . $columncount++ . '"><span class="datesubmitted">' . userdate($grade->get_datesubmitted(), get_string('strftimedatetimeshort')) . '</span></td>';
                 } else {
                     $studentshtml .= '<td class="cell c' . $columncount++ . '">-</td>';
                 }
                 continue;
             }
             // emulate grade element
             $eid = $this->gtree->get_grade_eid($grade);
             $element = array('eid' => $eid, 'object' => $grade, 'type' => 'grade');
             $cellclasses = 'grade cell c' . $columncount++;
             if ($item->is_category_item()) {
                 $cellclasses .= ' cat';
             }
             if ($item->is_course_item()) {
                 $cellclasses .= ' course';
             }
             if ($grade->is_overridden()) {
                 $cellclasses .= ' overridden';
             }
             if ($grade->is_excluded()) {
                 // $cellclasses .= ' excluded';
             }
             $grade_title = '<div class="fullname">' . fullname($user) . '</div>';
             $grade_title .= '<div class="itemname">' . $item->get_name(true) . '</div>';
             if (!empty($grade->feedback) && !$USER->gradeediting[$this->courseid]) {
                 $grade_title .= '<div class="feedback">' . wordwrap(trim(format_string($grade->feedback, $grade->feedbackformat)), 34, '<br/ >') . '</div>';
             } else {
             }
             $studentshtml .= '<td class="' . $cellclasses . '" title="' . s($grade_title) . '">';
             if ($grade->is_excluded()) {
                 $studentshtml .= '<span class="excludedfloater">' . get_string('excluded', 'grades') . '</span> ';
             }
             // Do not show any icons if no grade (no record in DB to match)
             if (!$item->needsupdate and $USER->gradeediting[$this->courseid]) {
                 $studentshtml .= $this->get_icons($element);
             }
             $hidden = '';
             if ($grade->is_hidden()) {
                 $hidden = ' hidden ';
             }
             $gradepass = '******';
             if ($grade->is_passed($item)) {
                 $gradepass = '******';
             } elseif (is_null($grade->is_passed($item))) {
                 $gradepass = '';
             }
             // if in editting mode, we need to print either a text box
             // or a drop down (for scales)
             // grades in item of type grade category or course are not directly editable
             if ($item->needsupdate) {
                 $studentshtml .= '<span class="gradingerror' . $hidden . '">' . get_string('error') . '</span>';
             } else {
                 if ($USER->gradeediting[$this->courseid]) {
                     if ($item->scaleid && !empty($scales_array[$item->scaleid])) {
                         $scale = $scales_array[$item->scaleid];
                         $gradeval = (int) $gradeval;
                         // scales use only integers
                         $scales = explode(",", $scale->scale);
                         // reindex because scale is off 1
                         // MDL-12104 some previous scales might have taken up part of the array
                         // so this needs to be reset
                         $scaleopt = array();
                         $i = 0;
                         foreach ($scales as $scaleoption) {
                             $i++;
                             $scaleopt[$i] = $scaleoption;
                         }
                         if ($this->get_pref('quickgrading') and $grade->is_editable()) {
                             $oldval = empty($gradeval) ? -1 : $gradeval;
                             if (empty($item->outcomeid)) {
                                 $nogradestr = $this->get_lang_string('nograde');
                             } else {
                                 $nogradestr = $this->get_lang_string('nooutcome', 'grades');
                             }
                             $studentshtml .= '<input type="hidden" name="oldgrade_' . $userid . '_' . $item->id . '" value="' . $oldval . '"/>';
                             $select = html_select::make($scaleopt, 'grade_' . $userid . '_' . $item->id, $gradeval, $nogradestr);
                             $select->nothingvalue = '-1';
                             $select->tabindex = $tabindices[$item->id]['grade'];
                             $studentshtml .= $OUTPUT->select($select);
                         } elseif (!empty($scale)) {
                             $scales = explode(",", $scale->scale);
                             // invalid grade if gradeval < 1
                             if ($gradeval < 1) {
                                 $studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">-</span>';
                             } else {
                                 $gradeval = $grade->grade_item->bounded_grade($gradeval);
                                 //just in case somebody changes scale
                                 $studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">' . $scales[$gradeval - 1] . '</span>';
                             }
                         } else {
                             // no such scale, throw error?
                         }
                     } else {
                         if ($item->gradetype != GRADE_TYPE_TEXT) {
                             // Value type
                             if ($this->get_pref('quickgrading') and $grade->is_editable()) {
                                 $value = format_float($gradeval, $decimalpoints);
                                 $studentshtml .= '<input type="hidden" name="oldgrade_' . $userid . '_' . $item->id . '" value="' . $value . '" />';
                                 $studentshtml .= '<input size="6" tabindex="' . $tabindices[$item->id]['grade'] . '" type="text" title="' . $strgrade . '" name="grade_' . $userid . '_' . $item->id . '" value="' . $value . '" />';
                             } else {
                                 $studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">' . format_float($gradeval, $decimalpoints) . '</span>';
                             }
                         }
                     }
                     // If quickfeedback is on, print an input element
                     if ($this->get_pref('showquickfeedback') and $grade->is_editable()) {
                         $studentshtml .= '<input type="hidden" name="oldfeedback_' . $userid . '_' . $item->id . '" value="' . s($grade->feedback) . '" />';
                         $studentshtml .= '<input class="quickfeedback" tabindex="' . $tabindices[$item->id]['feedback'] . '" size="6" title="' . $strfeedback . '" type="text" name="feedback_' . $userid . '_' . $item->id . '" value="' . s($grade->feedback) . '" />';
                     }
                 } else {
                     // Not editing
                     $gradedisplaytype = $item->get_displaytype();
                     // If feedback present, surround grade with feedback tooltip: Open span here
                     if ($item->needsupdate) {
                         $studentshtml .= '<span class="gradingerror' . $hidden . $gradepass . '">' . get_string('error') . '</span>';
                     } else {
                         $studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">' . grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null) . '</span>';
                     }
                 }
             }
             if (!empty($this->gradeserror[$item->id][$userid])) {
                 $studentshtml .= $this->gradeserror[$item->id][$userid];
             }
             $studentshtml .= '</td>' . "\n";
         }
         $studentshtml .= '</tr>';
     }
     return $studentshtml;
 }
Ejemplo n.º 7
0
    function get_content()
    {
        global $CFG, $OUTPUT;
        $calc = $OUTPUT->old_icon_url('i/calc');
        $this->content->text = '
        <script type="text/javascript">
       // <![CDATA[
    function Next()
    {
        submitScreen("Next");
        document.getElementById("vbankform").submit();
    }
    function Back()
    {
        submitScreen("Back");
        document.getElementById("vbankform").submit();
    }

    function num_format(x) { // format numbers with two digits
    sgn = (x < 0);
    x = Math.abs(x);
    x = Math.floor((x * 100) + .5);
    i = 3;
    y = "";
    while(((i--) > 0) || (x > 0)) {
        y = (x % 10) + y;
        x = Math.floor(x / 10);
        if(i == 1) {
            y = "." + y;
        }
    }
    if(sgn) {
        y = "-" + y;
    }
    return(y);
}
function comp(v) { // general entry point for all cases

    // convert all entry fields into variables
    x = document.getElementById("vbankform");
    pv = parseFloat(x.LOANAMOUNT.value);
    lpp = parseFloat(x.LOANPAYPERIOD[x.LOANPAYPERIOD.selectedIndex].value);
    if (isNaN(pv) && (v != "pv"))
    {
        x.LOANAMOUNT.select();
        x.LOANAMOUNT.focus();
        alert("Numbers only to be entered");
        return;
    }
    fv = parseFloat("0");
    yr = parseFloat(x.LOANTERM.value);
    if (isNaN(yr) && (v != "np"))
    {
        x.LOANTERM.select();
        x.LOANTERM.focus();
        alert("Numbers only to be entered");
        return;
    }
    np = lpp * yr;
    pmt = -parseFloat(x.LOANREPAYMENT.value);
    if (isNaN(pmt) && (v != "pmt"))
    {
        x.LOANREPAYMENT.select();
        x.LOANREPAYMENT.focus();
        alert("Numbers only to be entered");
        return;
    }
    if(x.LOANINTRATE.value == "") {
        alert("You must enter an interest rate (ir).");
    }
    else {
        ir = parseFloat(x.LOANINTRATE.value);
        if (isNaN(ir))
        {
            x.LOANINTRATE.select();
            x.LOANINTRATE.focus();
            alert("Numbers only to be entered");
            return;
        }
        ir = ((ir / lpp) / 100);

        // test and compute all cases

        if (v == "pv") {
            if(ir == 0) {
                pv = -(fv + (pmt * np));
            }
            else {
                q1 = Math.pow(1 + ir,-np);
                q2 = Math.pow(1 + ir,np);
                pv = -(q1 * (fv * ir - pmt + q2 * pmt))/ir;
            }
            x.LOANAMOUNT.value = num_format(pv);
        }

        if (v == "np") {
            if(ir == 0) {
                if(pmt != 0) {
                    np = - (fv + pv)/pmt;
                }
                else {
                    alert("Divide by zero error.");
                }
            }
            else {
                np = Math.log((-fv * ir + pmt)/(pmt + ir * pv))/ Math.log(1 + ir);
            }
            if(np == 0) {
                alert("Can\'t compute Number of Periods for the present values.");
            }
            else {
                np = (np / lpp)
                if (isNaN(np)) {
                    alert("The repayment amount is less than the interest. You must increase your repayments to pay off this loan!");
                } else {
                    x.LOANTERM.value = num_format(np);
                }
            }
        }

        if (v == "pmt") {
            if(ir == 0.0) {
                if(np != 0) {
                    pmt = (fv + pv)/np;
                }
                else {
                    alert("Divide by zero error.");
                }
            }
            else {
                q = Math.pow(1 + ir,np);
                pmt = ((ir * (fv + q * pv))/(-1 + q));
            }
            x.LOANREPAYMENT.value = num_format(pmt);
        }


    }
} // function comp
//]]>
</script>
<form method="post" id="vbankform" action="">
            <table>
                <tr>
                    <td colspan="2">' . get_string('amountofloan', 'block_loancalc') . '</td>
                </tr>
                <tr>
                    <td><input name="LOANAMOUNT" id="LOANAMOUNT" size="17" /></td>
                    <td><a href="JavaScript:comp(\'pv\');"><img src="' . $calc . '" alt="calculate" /></a></td>
                </tr>
                <tr>
                    <td colspan="2">' . get_string('repaymentamount', 'block_loancalc') . '</td>
                </tr>
                <tr>
                    <td><input name="LOANREPAYMENT" id="LOANREPAYMENT" size="17" /></td>
                    <td><a href="JavaScript:comp(\'pmt\');"><img src="' . $calc . '" alt="calculate" /></a></td>
                </tr>
                <tr>
                    <td colspan="2">' . get_string('loanterm', 'block_loancalc') . '</td>
                </tr>
                <tr>
                    <td><input name="LOANTERM" id="LOANTERM" size="17" /></td>
                    <td><a href="JavaScript:comp(\'np\');"><img src="' . $calc . '" alt="calculate" /></a></td>
                </tr>    
                <tr>
                    <td colspan="2">' . get_string('interestrate', 'block_loancalc') . '</td>
                </tr>
                <tr>
                    <td><input name="LOANINTRATE" id="LOANINTRATE" size="17" /></td>
                    <td></td>
                </tr>    
                <tr>
                    <td colspan="2">' . get_string('repaymentfreq', 'block_loancalc') . '</td>
                </tr>
                <tr>
                    <td>';
        $options[52] = get_string('weekly', 'block_loancalc');
        $options[26] = get_string('fortnightly', 'block_loancalc');
        $options[12] = get_string('monthly', 'block_loancalc');
        $this->content->text .= $OUTPUT->select(html_select::make($options, 'LOANPAYPERIOD', '12'));
        $this->content->text .= '</td>
                    <td></td>
                </tr>
            </table>
            </form>';
        $this->content->footer = '';
        return $this->content;
    }
Ejemplo n.º 8
0
$navlinks = array();
$navlinks[] = array('name' => $strfeedbacks, 'link' => "index.php?id={$course->id}", 'type' => 'activity');
$navlinks[] = array('name' => format_string($feedback->name), 'link' => "", 'type' => 'activityinstance');
$navigation = build_navigation($navlinks);
print_header_simple(format_string($feedback->name), "", $navigation, "", "", true, $buttontext, navmenu($course, $cm));
include 'tabs.php';
echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'), 'generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo '<form method="post">';
echo '<input type="hidden" name="id" value="' . $id . '" />';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
$sql = "select c.id, c.shortname\n              from {course} c\n             where c.shortname " . $DB->sql_ilike() . " ?\n                   OR c.fullname " . $DB->sql_ilike() . " ?";
$params = array("%{$searchcourse}%", "%{$searchcourse}%");
if (($courses = $DB->get_records_sql_menu($sql, $params)) && !empty($searchcourse)) {
    echo ' ' . get_string('courses') . ': ';
    echo $OUTPUT->select(html_select::make($courses, 'coursefilter', $coursefilter));
    echo '<input type="submit" value="' . get_string('mapcourse', 'feedback') . '"/>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('mapcourses', '', 'feedback', true));
    echo '<input type="button" value="' . get_string('searchagain') . '" onclick="document.location=\'mapcourse.php?id=' . $id . '\'"/>';
    echo '<input type="hidden" name="searchcourse" value="' . $searchcourse . '"/>';
    echo '<input type="hidden" name="feedbackid" value="' . $feedback->id . '"/>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('searchcourses', '', 'feedback', true));
} else {
    echo '<input type="text" name="searchcourse" value="' . $searchcourse . '"/> <input type="submit" value="' . get_string('searchcourses') . '"/>';
    echo $OUTPUT->help_icon(moodle_help_icon::make('searchcourses', '', 'feedback', true));
}
echo '</form>';
if ($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) {
    $table = new flexible_table('coursemaps');
    $table->define_columns(array('course'));
    $table->define_headers(array(get_string('mappedcourses', 'feedback')));
Ejemplo n.º 9
0
if (empty($roleoptions[$guestrole->id])) {
    $roleoptions[$guestrole->id] = $guestrole->name;
}
$roleoptions = role_fix_names($roleoptions, $context);
// print first controls.
echo '<form class="participationselectform" action="index.php" method="get"><div>' . "\n" . '<input type="hidden" name="id" value="' . $course->id . '" />' . "\n";
echo '<label for="menuinstanceid">' . get_string('activitymodule') . '</label>' . "\n";
$select = html_select::make($instanceoptions, 'instanceid', $instanceid);
$select->nested = true;
echo $OUTPUT->select($select);
echo '<label for="menutimefrom">' . get_string('lookback') . '</label>' . "\n";
echo $OUTPUT->select(html_select::make($timeoptions, 'timefrom', $timefrom));
echo '<label for="menuroleid">' . get_string('showonly') . '</label>' . "\n";
echo $OUTPUT->select(html_select::make($roleoptions, 'roleid', $roleid, false));
echo '<label for="menuaction">' . get_string('showactions') . '</label>' . "\n";
echo $OUTPUT->select(html_select::make($actionoptions, 'action', $action, false));
echo $OUTPUT->help_icon(moodle_help_icon::make('participationreport', get_string('participationreport')));
echo '<input type="submit" value="' . get_string('go') . '" />' . "\n</div></form>\n";
$baseurl = $CFG->wwwroot . '/course/report/participation/index.php?id=' . $course->id . '&amp;roleid=' . $roleid . '&amp;instanceid=' . $instanceid . '&amp;timefrom=' . $timefrom . '&amp;action=' . $action . '&amp;perpage=' . $perpage;
if (!empty($instanceid) && !empty($roleid)) {
    // from here assume we have at least the module we're using.
    $cm = $modinfo->cms[$instanceid];
    $modulename = get_string('modulename', $cm->modname);
    include_once $CFG->dirroot . '/mod/' . $cm->modname . '/lib.php';
    $viewfun = $cm->modname . '_get_view_actions';
    $postfun = $cm->modname . '_get_post_actions';
    if (!function_exists($viewfun) || !function_exists($postfun)) {
        print_error('modulemissingcode', 'error', $baseurl, $cm->modname);
    }
    $viewnames = $viewfun();
    $postnames = $postfun();
Ejemplo n.º 10
0
function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts, $updateopts)
{
    global $OUTPUT;
    echo '<tr><td colspan="3">';
    if ($retrieveopts) {
        echo $OUTPUT->heading(get_string('auth_data_mapping', 'auth'));
    } else {
        echo $OUTPUT->heading(get_string('auth_fieldlocks', 'auth'));
    }
    echo '</td></tr>';
    $lockoptions = array('unlocked' => get_string('unlocked', 'auth'), 'unlockedifempty' => get_string('unlockedifempty', 'auth'), 'locked' => get_string('locked', 'auth'));
    $updatelocaloptions = array('oncreate' => get_string('update_oncreate', 'auth'), 'onlogin' => get_string('update_onlogin', 'auth'));
    $updateextoptions = array('0' => get_string('update_never', 'auth'), '1' => get_string('update_onupdate', 'auth'));
    $pluginconfig = get_config("auth/{$auth}");
    // helptext is on a field with rowspan
    if (empty($helptext)) {
        $helptext = '&nbsp;';
    }
    foreach ($user_fields as $field) {
        // Define some vars we'll work with
        if (!isset($pluginconfig->{"field_map_{$field}"})) {
            $pluginconfig->{"field_map_{$field}"} = '';
        }
        if (!isset($pluginconfig->{"field_updatelocal_{$field}"})) {
            $pluginconfig->{"field_updatelocal_{$field}"} = '';
        }
        if (!isset($pluginconfig->{"field_updateremote_{$field}"})) {
            $pluginconfig->{"field_updateremote_{$field}"} = '';
        }
        if (!isset($pluginconfig->{"field_lock_{$field}"})) {
            $pluginconfig->{"field_lock_{$field}"} = '';
        }
        // define the fieldname we display to the  user
        $fieldname = $field;
        if ($fieldname === 'lang') {
            $fieldname = get_string('language');
        } elseif (preg_match('/^(.+?)(\\d+)$/', $fieldname, $matches)) {
            $fieldname = get_string($matches[1]) . ' ' . $matches[2];
        } elseif ($fieldname == 'url') {
            $fieldname = get_string('webpage');
        } else {
            $fieldname = get_string($fieldname);
        }
        if ($retrieveopts) {
            $varname = 'field_map_' . $field;
            echo '<tr valign="top"><td align="right">';
            echo '<label for="lockconfig_' . $varname . '">' . $fieldname . '</label>';
            echo '</td><td>';
            echo "<input id=\"lockconfig_{$varname}\" name=\"lockconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->{$varname}}\" />";
            echo '<div style="text-align: right">';
            echo '<label for="menulockconfig_field_updatelocal_' . $field . '">' . get_string('auth_updatelocal', 'auth') . '</label>&nbsp;';
            echo $OUTPUT->select(html_select::make($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_{$field}"}, false));
            echo '<br />';
            if ($updateopts) {
                echo '<label for="menulockconfig_field_updateremote_' . $field . '">' . get_string('auth_updateremote', 'auth') . '</label>&nbsp;';
                echo $OUTPUT->select(html_select::make($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_{$field}"}, false));
                echo '<br />';
            }
            echo '<label for="menulockconfig_field_lock_' . $field . '">' . get_string('auth_fieldlock', 'auth') . '</label>&nbsp;';
            echo $OUTPUT->select(html_select::make($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_{$field}"}, false));
            echo '</div>';
        } else {
            echo '<tr valign="top"><td align="right">';
            echo '<label for="menulockconfig_field_lock_' . $field . '">' . $fieldname . '</label>';
            echo '</td><td>';
            echo $OUTPUT->select(html_select::make($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_{$field}"}, false));
        }
        echo '</td>';
        if (!empty($helptext)) {
            echo '<td rowspan="' . count($user_fields) . '">' . $helptext . '</td>';
            $helptext = '';
        }
        echo '</tr>';
    }
}
Ejemplo n.º 11
0
/**
 * Prints a grade menu (as part of an existing form) with help
 * Showing all possible numerical grades and scales
 *
 * @todo Finish documenting this function
 * @todo Deprecate: this is only used in a few contrib modules
 *
 * @global object
 * @param int $courseid The course ID
 * @param string $name
 * @param string $current
 * @param boolean $includenograde Include those with no grades
 * @param boolean $return If set to true returns rather than echo's
 * @return string|bool Depending on value of $return
 */
function print_grade_menu($courseid, $name, $current, $includenograde = true, $return = false)
{
    global $CFG, $OUTPUT;
    $output = '';
    $strscale = get_string('scale');
    $strscales = get_string('scales');
    $scales = get_scales_menu($courseid);
    foreach ($scales as $i => $scalename) {
        $grades[-$i] = $strscale . ': ' . $scalename;
    }
    if ($includenograde) {
        $grades[0] = get_string('nograde');
    }
    for ($i = 100; $i >= 1; $i--) {
        $grades[$i] = $i;
    }
    $output .= $OUTPUT->select(html_select::make($grades, $name, $current, false));
    $linkobject = '<span class="helplink"><img class="iconhelp" alt="' . $strscales . '" src="' . $OUTPUT->old_icon_url('help') . '" /></span>';
    $link = html_link::make('/course/scales.php?id=' . $courseid . '&list=true', $linkobject);
    $link->add_action(new popup_action('click', $link->url, 'ratingscales', array('height' => 400, 'width' => 500)));
    $link->title = $strscales;
    $output .= $OUTPUT->link($link);
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Ejemplo n.º 12
0
        }
        echo "<hr>";
        echo $OUTPUT->continue_button("view.php?id={$cm->id}");
        echo $OUTPUT->footer();
        exit;
    }
}
/// Print upload form
$fileformatnames = get_import_export_formats('import');
print_heading_with_help($strimportquestions, "import", "lesson");
echo $OUTPUT->box_start('generalbox boxaligncenter');
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"import.php\">";
echo "<input type=\"hidden\" name=\"id\" value=\"{$cm->id}\" />\n";
echo "<input type=\"hidden\" name=\"pageid\" value=\"{$pageid}\" />\n";
echo "<table cellpadding=\"5\">";
echo "<tr><td align=\"right\">";
print_string("fileformat", "lesson");
echo ":</td><td>";
echo $OUTPUT->select(html_select::make($fileformatnames, "format", "gift", false));
echo "</td></tr>";
echo "<tr><td align=\"right\">";
print_string("upload");
echo ":</td><td>";
echo "<input name=\"newfile\" type=\"file\" size=\"50\" />";
echo "</td></tr><tr><td>&nbsp;</td><td>";
echo "<input type=\"submit\" name=\"save\" value=\"" . get_string("uploadthisfile") . "\" />";
echo "</td></tr>";
echo "</table>";
echo "</form>";
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
Ejemplo n.º 13
0
 protected function get_legacy_type_field($id)
 {
     global $OUTPUT;
     $options = array();
     $options[''] = get_string('none');
     foreach ($this->legacyroles as $type => $cap) {
         $options[$type] = get_string('legacy:' . $type, 'role');
     }
     return $OUTPUT->select(html_select::make($options, 'legacytype', $this->role->legacytype, false));
 }
Ejemplo n.º 14
0
     $table->align[] = 'left';
 }
 $table->width = ' ';
 $table->data = array();
 // iterate through filters adding to display table
 foreach ($availablefilters as $filter => $filterinfo) {
     $row = array();
     // Filter name.
     $row[] = filter_get_name($filter);
     // Default/on/off choice.
     if ($filterinfo->inheritedstate == TEXTFILTER_ON) {
         $activechoices[TEXTFILTER_INHERIT] = $strdefaulton;
     } else {
         $activechoices[TEXTFILTER_INHERIT] = $strdefaultoff;
     }
     $select = html_select::make($activechoices, str_replace('/', '_', $filter), $filterinfo->localstate, false);
     $select->nothingvalue = '';
     $row[] = $OUTPUT->select($select);
     // Settings link, if required
     if ($settingscol) {
         $settings = '';
         if ($filterinfo->hassettings) {
             $settings = '<a href="' . $baseurl . '&amp;filter=' . $filter . '">' . $strsettings . '</a>';
         }
         $row[] = $settings;
     }
     $table->data[] = $row;
 }
 echo $OUTPUT->table($table);
 echo '<div class="buttons">' . "\n";
 echo '<input type="submit" name="savechanges" value="' . get_string('savechanges') . '" />';
Ejemplo n.º 15
0
 public function test_html_select()
 {
     $options = array('var1' => 'value1', 'var2' => 'value2', 'var3' => 'value3');
     $select = html_select::make($options, 'mymenu', 'var2');
     $html = $this->renderer->select($select);
     $this->assert(new ContainsTagWithAttributes('select', array('name' => 'mymenu')), $html);
     $this->assert(new ContainsTagWithAttributes('option', array('value' => 'var1'), array('selected' => 'selected')), $html);
     $this->assert(new ContainsTagWithAttributes('option', array('value' => 'var2', 'selected' => 'selected')), $html);
     $this->assert(new ContainsTagWithAttributes('option', array('value' => 'var3'), array('selected' => 'selected')), $html);
     $this->assert(new ContainsTagWithContents('option', 'value1'), $html);
     $this->assert(new ContainsTagWithContents('option', 'value2'), $html);
     $this->assert(new ContainsTagWithContents('option', 'value3'), $html);
     $options = array('group1' => '--group1', 'var1' => 'value1', 'var2' => 'value2', 'group2' => '--', 'group2' => '--group2', 'var3' => 'value3', 'var4' => 'value4');
     $select = html_select::make($options, 'mymenu', 'var2');
     $html = $this->renderer->select($select);
     $this->assert(new ContainsTagWithAttributes('select', array('name' => 'mymenu')), $html);
     $this->assert(new ContainsTagWithAttributes('optgroup', array('label' => 'group1')), $html);
     $this->assert(new ContainsTagWithAttributes('optgroup', array('label' => 'group2')), $html);
     $this->assert(new ContainsTagWithAttributes('option', array('value' => 'var1'), array('selected' => 'selected')), $html);
     $this->assert(new ContainsTagWithAttributes('option', array('value' => 'var2', 'selected' => 'selected')), $html);
     $this->assert(new ContainsTagWithAttributes('option', array('value' => 'var3'), array('selected' => 'selected')), $html);
     $this->assert(new ContainsTagWithAttributes('option', array('value' => 'var4'), array('selected' => 'selected')), $html);
     $this->assert(new ContainsTagWithContents('option', 'value1'), $html);
     $this->assert(new ContainsTagWithContents('option', 'value2'), $html);
     $this->assert(new ContainsTagWithContents('option', 'value3'), $html);
     $this->assert(new ContainsTagWithContents('option', 'value4'), $html);
 }
Ejemplo n.º 16
0
function message_print_settings()
{
    global $USER, $OUTPUT;
    if ($frm = data_submitted() and confirm_sesskey()) {
        $pref = array();
        $pref['message_showmessagewindow'] = isset($frm->showmessagewindow) ? '1' : '0';
        $pref['message_beepnewmessage'] = isset($frm->beepnewmessage) ? '1' : '0';
        $pref['message_blocknoncontacts'] = isset($frm->blocknoncontacts) ? '1' : '0';
        $pref['message_usehtmleditor'] = isset($frm->usehtmleditor) ? '1' : '0';
        $pref['message_noframesjs'] = isset($frm->noframesjs) ? '1' : '0';
        $pref['message_emailmessages'] = isset($frm->emailmessages) ? '1' : '0';
        $pref['message_emailtimenosee'] = (int) $frm->emailtimenosee > 0 ? (int) $frm->emailtimenosee : '10';
        $pref['message_emailaddress'] = !empty($frm->emailaddress) ? $frm->emailaddress : $USER->email;
        $pref['message_emailformat'] = isset($frm->emailformat) ? $frm->emailformat : FORMAT_PLAIN;
        set_user_preferences($pref);
        redirect('index.php', get_string('settingssaved', 'message'), 1);
    }
    $cbshowmessagewindow = get_user_preferences('message_showmessagewindow', 1) == '1' ? 'checked="checked"' : '';
    $cbbeepnewmessage = get_user_preferences('message_beepnewmessage', 0) == '1' ? 'checked="checked"' : '';
    $cbblocknoncontacts = get_user_preferences('message_blocknoncontacts', 0) == '1' ? 'checked="checked"' : '';
    $cbusehtmleditor = get_user_preferences('message_usehtmleditor', 0) == '1' ? 'checked="checked"' : '';
    $cbnoframesjs = get_user_preferences('message_noframesjs', 0) == '1' ? 'checked="checked"' : '';
    $cbemailmessages = get_user_preferences('message_emailmessages', 1) == '1' ? 'checked="checked"' : '';
    $txemailaddress = get_user_preferences('message_emailaddress', $USER->email);
    $txemailtimenosee = get_user_preferences('message_emailtimenosee', 10);
    $format_select = $OUTPUT->select(html_select::make(array(FORMAT_PLAIN => get_string('formatplain'), FORMAT_HTML => get_string('formathtml')), 'emailformat', get_user_preferences('message_emailformat', FORMAT_PLAIN)));
    include 'settings.html';
}
Ejemplo n.º 17
0
 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG, $OUTPUT;
     $subquestions = $state->options->subquestions;
     $correctanswers = $this->get_correct_responses($question, $state);
     $nameprefix = $question->name_prefix;
     $answers = array();
     // Answer choices formatted ready for output.
     $allanswers = array();
     // This and the next used to detect identical answers
     $answerids = array();
     // and adjust ids.
     $responses =& $state->responses;
     // Prepare a list of answers, removing duplicates.
     foreach ($subquestions as $subquestion) {
         foreach ($subquestion->options->answers as $ans) {
             $allanswers[$ans->id] = $ans->answer;
             if (!in_array($ans->answer, $answers)) {
                 $answers[$ans->id] = strip_tags(format_string($ans->answer, false));
                 $answerids[$ans->answer] = $ans->id;
             }
         }
     }
     // Fix up the ids of any responses that point the the eliminated duplicates.
     foreach ($responses as $subquestionid => $ignored) {
         if ($responses[$subquestionid]) {
             $responses[$subquestionid] = $answerids[$allanswers[$responses[$subquestionid]]];
         }
     }
     foreach ($correctanswers as $subquestionid => $ignored) {
         $correctanswers[$subquestionid] = $answerids[$allanswers[$correctanswers[$subquestionid]]];
     }
     // Shuffle the answers
     $answers = draw_rand_array($answers, count($answers));
     // Print formulation
     $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
     $image = get_question_image($question);
     // Print the input controls
     foreach ($subquestions as $key => $subquestion) {
         if ($subquestion->questiontext !== '' && !is_null($subquestion->questiontext)) {
             // Subquestion text:
             $a = new stdClass();
             $a->text = $this->format_text($subquestion->questiontext, $question->questiontextformat, $cmoptions);
             // Drop-down list:
             $menuname = $nameprefix . $subquestion->id;
             $response = isset($state->responses[$subquestion->id]) ? $state->responses[$subquestion->id] : '0';
             $a->class = ' ';
             $a->feedbackimg = ' ';
             if ($options->readonly and $options->correct_responses) {
                 if (isset($correctanswers[$subquestion->id]) and $correctanswers[$subquestion->id] == $response) {
                     $correctresponse = 1;
                 } else {
                     $correctresponse = 0;
                 }
                 if ($options->feedback && $response) {
                     $a->class = question_get_feedback_class($correctresponse);
                     $a->feedbackimg = question_get_feedback_image($correctresponse);
                 }
             }
             $select = html_select::make($answers, $menuname, $response);
             $select->disabled = $options->readonly;
             $a->control = $OUTPUT->select($select);
             // Neither the editing interface or the database allow to provide
             // fedback for this question type.
             // However (as was pointed out in bug bug 3294) the randomsamatch
             // type which reuses this method can have feedback defined for
             // the wrapped shortanswer questions.
             //if ($options->feedback
             // && !empty($subquestion->options->answers[$responses[$key]]->feedback)) {
             //    print_comment($subquestion->options->answers[$responses[$key]]->feedback);
             //}
             $anss[] = $a;
         }
     }
     include "{$CFG->dirroot}/question/type/match/display.html";
 }
Ejemplo n.º 18
0
/**
 * @todo Document this function
 */
function forum_print_big_search_form($course)
{
    global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT;
    echo $OUTPUT->box(get_string('searchforumintro', 'forum'), 'searchbox boxaligncenter', 'intro');
    echo $OUTPUT->box_start('generalbox boxaligncenter');
    echo $PAGE->requires->js('mod/forum/forum.js')->asap();
    echo '<form id="searchform" action="search.php" method="get">';
    echo '<table cellpadding="10" class="searchbox" id="form">';
    echo '<tr>';
    echo '<td class="c0"><label for="words">' . get_string('searchwords', 'forum') . '</label>';
    echo '<input type="hidden" value="' . $course->id . '" name="id" alt="" /></td>';
    echo '<td class="c1"><input type="text" size="35" name="words" id="words"value="' . s($words, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="phrase">' . get_string('searchphrase', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="phrase" id="phrase" value="' . s($phrase, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="notwords">' . get_string('searchnotwords', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="notwords" id="notwords" value="' . s($notwords, true) . '" alt="" /></td>';
    echo '</tr>';
    if ($DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres') {
        echo '<tr>';
        echo '<td class="c0"><label for="fullwords">' . get_string('searchfullwords', 'forum') . '</label></td>';
        echo '<td class="c1"><input type="text" size="35" name="fullwords" id="fullwords" value="' . s($fullwords, true) . '" alt="" /></td>';
        echo '</tr>';
    }
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchdatefrom', 'forum') . '</td>';
    echo '<td class="c1">';
    if (empty($datefrom)) {
        $datefromchecked = '';
        $datefrom = make_timestamp(2000, 1, 1, 0, 0, 0);
    } else {
        $datefromchecked = 'checked="checked"';
    }
    echo '<input name="timefromrestrict" type="checkbox" value="1" alt="' . get_string('searchdatefrom', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timefromrestrict\', timefromitems)" ' . $datefromchecked . ' /> ';
    $selectors = html_select::make_time_selectors(array('days' => 'fromday', 'months' => 'frommonth', 'years' => 'fromyear', 'hours' => 'fromhour', 'minutes' => 'fromminute'), $datefrom);
    foreach ($selectors as $select) {
        echo $OUTPUT->select($select);
    }
    echo '<input type="hidden" name="hfromday" value="0" />';
    echo '<input type="hidden" name="hfrommonth" value="0" />';
    echo '<input type="hidden" name="hfromyear" value="0" />';
    echo '<input type="hidden" name="hfromhour" value="0" />';
    echo '<input type="hidden" name="hfromminute" value="0" />';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchdateto', 'forum') . '</td>';
    echo '<td class="c1">';
    if (empty($dateto)) {
        $datetochecked = '';
        $dateto = time() + 3600;
    } else {
        $datetochecked = 'checked="checked"';
    }
    echo '<input name="timetorestrict" type="checkbox" value="1" alt="' . get_string('searchdateto', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timetorestrict\', timetoitems)" ' . $datetochecked . ' /> ';
    $selectors = html_select::make_time_selectors(array('days' => 'today', 'months' => 'tomonth', 'years' => 'toyear', 'hours' => 'tohour', 'minutes' => 'tominute'), $dateto);
    foreach ($selectors as $select) {
        echo $OUTPUT->select($select);
    }
    echo '<input type="hidden" name="htoday" value="0" />';
    echo '<input type="hidden" name="htomonth" value="0" />';
    echo '<input type="hidden" name="htoyear" value="0" />';
    echo '<input type="hidden" name="htohour" value="0" />';
    echo '<input type="hidden" name="htominute" value="0" />';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="menuforumid">' . get_string('searchwhichforums', 'forum') . '</label></td>';
    echo '<td class="c1">';
    echo $OUTPUT->select(html_select::make(forum_menu_list($course), 'forumid', '', get_string('allforums', 'forum')));
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="subject">' . get_string('searchsubject', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="subject" id="subject" value="' . s($subject, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="user">' . get_string('searchuser', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="user" id="user" value="' . s($user, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="submit" colspan="2" align="center">';
    echo '<input type="submit" value="' . get_string('searchforums', 'forum') . '" alt="" /></td>';
    echo '</tr>';
    echo '</table>';
    echo '</form>';
    echo $PAGE->requires->js_function_call('lockoptions_timetoitems')->asap();
    echo $PAGE->requires->js_function_call('lockoptions_timefromitems')->asap();
    echo $OUTPUT->box_end();
}
Ejemplo n.º 19
0
        echo $OUTPUT->heading($scale->name);
        echo "<center>";
        echo $OUTPUT->select(html_select::make($scalemenu));
        echo "</center>";
        echo text_to_html($scale->description);
        echo $OUTPUT->box_end();
        echo "<hr />";
    }
} else {
    if (has_capability('moodle/course:managescales', $context)) {
        echo "<p align=\"center\">(";
        print_string("scalestip");
        echo ")</p>";
    }
}
if ($scales = $DB->get_records("scale", array("courseid" => 0), "name ASC")) {
    echo $OUTPUT->heading($strstandardscales);
    foreach ($scales as $scale) {
        $scalemenu = make_menu_from_list($scale->scale);
        echo $OUTPUT->box_start();
        echo $OUTPUT->heading($scale->name);
        echo "<center>";
        echo $OUTPUT->select(html_select::make($scalemenu, ''));
        echo "</center>";
        echo text_to_html($scale->description);
        echo $OUTPUT->box_end();
        echo "<hr />";
    }
}
echo $OUTPUT->close_window_button();
echo $OUTPUT->footer();
Ejemplo n.º 20
0
function calendar_print_month_selector($name, $selected)
{
    global $OUTPUT;
    $months = array();
    for ($i = 1; $i <= 12; $i++) {
        $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), '%B');
    }
    echo $OUTPUT->select(html_select::make($months, $name, $selected, false));
}
Ejemplo n.º 21
0
 /**
  * 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, $OUTPUT;
     /// Do the job, setting result as needed
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . $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
     /// Fetch request data
     $tableparam = required_param('table', PARAM_CLEAN);
     if (!($table =& $structure->getTable($tableparam))) {
         $this->errormsg = 'Wrong table specified: ' . $tableparam;
         return false;
     }
     $fieldparam = required_param('field', PARAM_CLEAN);
     if (!($field =& $table->getField($fieldparam))) {
         /// Arriving here from a name change, looking for the new field name
         $fieldparam = required_param('name', PARAM_CLEAN);
         $field =& $table->getField($fieldparam);
     }
     $dbdir =& $XMLDB->dbdirs[$dirpath];
     $origstructure =& $dbdir->xml_file->getStructure();
     $o = '';
     /// Output starts
     /// If field is XMLDB_TYPE_FLOAT, comment about to migrate it to XMLDB_TYPE_NUMBER
     if ($field->getType() == XMLDB_TYPE_FLOAT) {
         $o .= '<p>' . $this->str['float2numbernote'] . '</p>';
     }
     /// Add the main 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 ="table" value="' . $tableparam . '" />';
     $o .= '    <input type="hidden" name ="field" value="' . $fieldparam . '" />';
     $o .= '    <input type="hidden" name ="action" value="edit_field_save" />';
     $o .= '    <input type="hidden" name ="postaction" value="edit_table" />';
     $o .= '    <table id="formelements" class="boxaligncenter">';
     /// XMLDB field name
     /// If the field has dependencies, we cannot change its name
     $disabled = '';
     if ($structure->getFieldUses($table->getName(), $field->getName())) {
         $o .= '      <input type="hidden" name ="name" value="' . s($field->getName()) . '" />';
         $o .= '      <tr valign="top"><td>Name:</td><td colspan="2">' . s($field->getName()) . '</td></tr>';
     } else {
         $o .= '      <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" maxlength="30" id="name" value="' . s($field->getName()) . '" /></td></tr>';
     }
     /// XMLDB field comment
     $o .= '      <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td colspan="2"><textarea name="comment" rows="3" cols="80" id="comment">' . s($field->getComment()) . '</textarea></td></tr>';
     /// xmldb_field Type
     $typeoptions = array(XMLDB_TYPE_INTEGER => $field->getXMLDBTypeName(XMLDB_TYPE_INTEGER), XMLDB_TYPE_NUMBER => $field->getXMLDBTypeName(XMLDB_TYPE_NUMBER), XMLDB_TYPE_FLOAT => $field->getXMLDBTypeName(XMLDB_TYPE_FLOAT), XMLDB_TYPE_DATETIME => $field->getXMLDBTypeName(XMLDB_TYPE_DATETIME), XMLDB_TYPE_CHAR => $field->getXMLDBTypeName(XMLDB_TYPE_CHAR), XMLDB_TYPE_TEXT => $field->getXMLDBTypeName(XMLDB_TYPE_TEXT), XMLDB_TYPE_BINARY => $field->getXMLDBTypeName(XMLDB_TYPE_BINARY));
     /// If current field isnt float, delete such column type to avoid its creation from the interface
     /// Note that float fields are supported completely but it's possible than in a next future
     /// we delete them completely from Moodle DB, using, exlusively, number(x,y) types
     if ($field->getType() != XMLDB_TYPE_FLOAT) {
         unset($typeoptions[XMLDB_TYPE_FLOAT]);
     }
     /// Also we hide datetimes. Only edition of them is allowed (and retrofit) but not new creation
     if ($field->getType() != XMLDB_TYPE_DATETIME) {
         unset($typeoptions[XMLDB_TYPE_DATETIME]);
     }
     $select = html_select::make($typeoptions, 'type', $field->getType(), false);
     $select->nothingvalue = '';
     $o .= '      <tr valign="top"><td><label for="menutype" accesskey="t">Type:</label></td>';
     $o .= '        <td colspan="2">' . $OUTPUT->select($select) . '</td></tr>';
     /// xmldb_field Length
     $o .= '      <tr valign="top"><td><label for="length" accesskey="l">Length:</label></td>';
     $o .= '        <td colspan="2"><input name="length" type="text" size="6" maxlength="6" id="length" value="' . s($field->getLength()) . '" /><span id="lengthtip"></span></td></tr>';
     /// xmldb_field Decimals
     $o .= '      <tr valign="top"><td><label for="decimals" accesskey="d">Decimals:</label></td>';
     $o .= '        <td colspan="2"><input name="decimals" type="text" size="6" maxlength="6" id="decimals" value="' . s($field->getDecimals()) . '" /><span id="decimalstip"></span></td></tr>';
     /// xmldb_field Unsigned
     $unsignedoptions = array(0 => 'signed', 1 => 'unsigned');
     $select = html_select::make($unsignedoptions, 'unsigned', $field->getUnsigned(), false);
     $select->nothingvalue = '';
     $o .= '      <tr valign="top"><td><label for="menuunsigned" accesskey="u">Unsigned:</label></td>';
     $o .= '        <td colspan="2">' . $OUTPUT->select($select) . '</td></tr>';
     /// xmldb_field NotNull
     $notnulloptions = array(0 => 'null', 'not null');
     $select = html_select::make($notnulloptions, 'notnull', $field->getNotNull(), false);
     $select->nothingvalue = '';
     $o .= '      <tr valign="top"><td><label for="menunotnull" accesskey="n">Not Null:</label></td>';
     $o .= '        <td colspan="2">' . $OUTPUT->select($select) . '</td></tr>';
     /// xmldb_field Sequence
     $select = html_select::make($sequenceoptions, 'sequence', $field->getSequence(), false);
     $select->nothingvalue = '';
     $sequenceoptions = array(0 => $this->str['no'], 1 => 'auto-numbered');
     $o .= '      <tr valign="top"><td><label for="menusequence" accesskey="s">Sequence:</label></td>';
     $o .= '        <td colspan="2">' . $OUTPUT->select($select) . '</td></tr>';
     /// xmldb_field Default
     $o .= '      <tr valign="top"><td><label for="default" accesskey="d">Default:</label></td>';
     $o .= '        <td colspan="2"><input type="text" name="default" size="30" maxlength="80" id="default" value="' . s($field->getDefault()) . '" /></td></tr>';
     /// Change button
     $o .= '      <tr valign="top"><td>&nbsp;</td><td colspan="2"><input type="submit" value="' . $this->str['change'] . '" /></td></tr>';
     $o .= '    </table>';
     $o .= '</div></form>';
     /// Calculate the buttons
     $b = ' <p class="centerpara buttons">';
     /// The view original XML button
     if ($table->getField($fieldparam)) {
         $b .= '&nbsp;<a href="index.php?action=view_field_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;select=original&amp;table=' . $tableparam . '&amp;field=' . $fieldparam . '">[' . $this->str['vieworiginal'] . ']</a>';
     } else {
         $b .= '&nbsp;[' . $this->str['vieworiginal'] . ']';
     }
     /// The view edited XML button
     if ($field->hasChanged()) {
         $b .= '&nbsp;<a href="index.php?action=view_field_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;select=edited&amp;table=' . $tableparam . '&amp;field=' . $fieldparam . '">[' . $this->str['viewedited'] . ']</a>';
     } else {
         $b .= '&nbsp;[' . $this->str['viewedited'] . ']';
     }
     /// The back to edit table button
     $b .= '&nbsp;<a href="index.php?action=edit_table&amp;table=' . $tableparam . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
     $b .= '</p>';
     $o .= $b;
     $this->output = $o;
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
Ejemplo n.º 22
0
/**
 * authorize_print_orders
 *
 */
function authorize_print_orders($courseid, $userid)
{
    global $course;
    global $CFG, $USER, $SITE, $DB, $OUTPUT, $PAGE;
    global $strs, $authstrs;
    require_once $CFG->libdir . '/tablelib.php';
    $perpage = optional_param('perpage', 10, PARAM_INT);
    $showonlymy = optional_param('showonlymy', 0, PARAM_BOOL);
    $searchquery = optional_param('searchquery', '0', PARAM_INT);
    $searchtype = optional_param('searchtype', 'orderid', PARAM_ALPHA);
    $status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
    $searchmenu = array('orderid' => $authstrs->orderid, 'transid' => $authstrs->transid, 'cclastfour' => $authstrs->cclastfour);
    $buttons = "<form method='post' action='index.php' autocomplete='off'><div>";
    $select = html_select::make($searchmenu, 'searchtype', $searchtype, false);
    $select->nothingvalue = '';
    $buttons .= $OUTPUT->select($select);
    $buttons .= "<input type='text' size='16' name='searchquery' value='' />";
    $buttons .= "<input type='submit' value='{$strs->search}' />";
    $buttons .= "</div></form>";
    if (has_capability('enrol/authorize:uploadcsv', get_context_instance(CONTEXT_USER, $USER->id))) {
        $buttons .= "<form method='get' action='uploadcsv.php'><div><input type='submit' value='" . get_string('uploadcsv', 'enrol_authorize') . "' /></div></form>";
    }
    $canmanagepayments = has_capability('enrol/authorize:managepayments', get_context_instance(CONTEXT_COURSE, $courseid));
    if ($showonlymy || !$canmanagepayments) {
        $userid = $USER->id;
    }
    $baseurl = $CFG->wwwroot . '/enrol/authorize/index.php?user='******'userid' => $userid);
    $sql = "SELECT c.id, c.fullname FROM {course} c JOIN {enrol_authorize} e ON c.id = e.courseid ";
    $sql .= $userid > 0 ? "WHERE (e.userid=:userid) " : '';
    $sql .= "ORDER BY c.sortorder, c.fullname";
    if ($popupcrs = $DB->get_records_sql_menu($sql, $params)) {
        $popupcrs = array($SITE->id => $SITE->fullname) + $popupcrs;
    }
    $popupmenu = empty($popupcrs) ? '' : $OUTPUT->select(html_select::make_popup_form($baseurl . '&status=' . $status, 'course', $popupcrs, 'coursesmenu', $courseid));
    $popupmenu .= '<br />';
    $statusmenu = array(AN_STATUS_NONE => $strs->all, AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW => $authstrs->allpendingorders, AN_STATUS_AUTH => $authstrs->authorizedpendingcapture, AN_STATUS_AUTHCAPTURE => $authstrs->authcaptured, AN_STATUS_CREDIT => $authstrs->refunded, AN_STATUS_VOID => $authstrs->cancelled, AN_STATUS_EXPIRE => $authstrs->expired, AN_STATUS_UNDERREVIEW => $authstrs->underreview, AN_STATUS_APPROVEDREVIEW => $authstrs->approvedreview, AN_STATUS_REVIEWFAILED => $authstrs->reviewfailed, AN_STATUS_TEST => $authstrs->tested);
    $popupmenu .= $OUTPUT->select(html_select::make_popup_form($baseurl . '&course=' . $courseid, 'status', $statusmenu, 'statusmenu', $status));
    if ($canmanagepayments) {
        $popupmenu .= '<br />';
        $checkbox = html_select_option::make_checkbox(1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'));
        $PAGE->requires->js('enrol/authorize/authorize.js');
        $checkbox->add_action('click', 'authorize_jump_to_mypayments', array('userid' => $USER->id, 'status' => $status));
        $popupmenu .= $OUTPUT->checkbox($checkbox, 'showonlymy');
    }
    $navlinks = array();
    if (SITEID != $courseid) {
        $navlinks[] = array('name' => $course->shortname, 'link' => "{$CFG->wwwroot}/course/view.php?id=" . $course->id, 'type' => 'misc');
    }
    $navlinks[] = array('name' => $authstrs->paymentmanagement, 'link' => 'index.php', 'type' => 'misc');
    $navigation = build_navigation($navlinks);
    print_header("{$course->shortname}: {$authstrs->paymentmanagement}", $authstrs->paymentmanagement, $navigation, '', '', false, $buttons, $popupmenu);
    $table = new flexible_table('enrol-authorize');
    $table->set_attribute('width', '100%');
    $table->set_attribute('cellspacing', '0');
    $table->set_attribute('cellpadding', '3');
    $table->set_attribute('id', 'orders');
    $table->set_attribute('class', 'generaltable generalbox');
    if ($perpage > 100) {
        $perpage = 100;
    }
    $perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
    $perpagemenu = $OUTPUT->select(html_select::make_popup_form($baseurl . '&status=' . $status . '&course=' . $courseid, 'perpage', $perpagemenus, 'perpagemenu', $perpage));
    $table->define_columns(array('id', 'userid', 'timecreated', 'status', 'action'));
    $table->define_headers(array($authstrs->orderid, $authstrs->shopper, $strs->time, $strs->status, $perpagemenu));
    $table->define_baseurl($baseurl . "&amp;status={$status}&amp;course={$courseid}&amp;perpage={$perpage}");
    $table->no_sorting('action');
    $table->sortable(true, 'id', SORT_DESC);
    $table->pageable(true);
    $table->setup();
    $select = "SELECT e.id, e.paymentmethod, e.refundinfo, e.transid, e.courseid, e.userid, e.status, e.ccname, e.timecreated, e.settletime ";
    $from = "FROM {enrol_authorize} e ";
    $where = "WHERE (1=1) ";
    $params = array();
    if (!empty($searchquery)) {
        switch ($searchtype) {
            case 'orderid':
                $where = "WHERE (e.id = :searchquery) ";
                $params['searchquery'] = $searchquery;
                break;
            case 'transid':
                $where = "WHERE (e.transid = :searchquery) ";
                $params['searchquery'] = $searchquery;
                break;
            case 'cclastfour':
                $searchquery = sprintf("%04d", $searchquery);
                $where = "WHERE (e.refundinfo = :searchquery) AND (e.paymentmethod=:method) ";
                $params['searchquery'] = $searchquery;
                $params['method'] = AN_METHOD_CC;
                break;
        }
    } else {
        switch ($status) {
            case AN_STATUS_NONE:
                if (empty($CFG->an_test)) {
                    $where .= "AND (e.status != :status) ";
                    $params['status'] = AN_STATUS_NONE;
                }
                break;
            case AN_STATUS_TEST:
                $newordertime = time() - 120;
                // -2 minutes. Order may be still in process.
                $where .= "AND (e.status = :status) AND (e.transid = '0') AND (e.timecreated < :newordertime) ";
                $params['status'] = AN_STATUS_NONE;
                $params['newordertime'] = $newordertime;
                break;
            case AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW:
                $where .= 'AND (e.status IN(:status1,:status2,:status3)) ';
                $params['status1'] = AN_STATUS_AUTH;
                $params['status2'] = AN_STATUS_UNDERREVIEW;
                $params['status3'] = AN_STATUS_APPROVEDREVIEW;
                break;
            case AN_STATUS_CREDIT:
                $from .= "INNER JOIN {enrol_authorize_refunds} r ON e.id = r.orderid ";
                $where .= "AND (e.status = :status) ";
                $params['status'] = AN_STATUS_AUTHCAPTURE;
                break;
            default:
                $where .= "AND (e.status = :status) ";
                $params['status'] = $status;
                break;
        }
        if (SITEID != $courseid) {
            $where .= "AND (e.courseid = :courseid) ";
            $params['courseid'] = $courseid;
        }
    }
    // This must be always LAST where!!!
    if ($userid > 0) {
        $where .= "AND (e.userid = :userid) ";
        $params['userid'] = $userid;
    }
    if ($sort = $table->get_sql_sort()) {
        $sort = ' ORDER BY ' . $sort;
    }
    $totalcount = $DB->count_records_sql('SELECT COUNT(*) ' . $from . $where, $params);
    $table->initialbars($totalcount > $perpage);
    $table->pagesize($perpage, $totalcount);
    if ($records = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size())) {
        foreach ($records as $record) {
            $actionstatus = authorize_get_status_action($record);
            $color = authorize_get_status_color($actionstatus->status);
            $actions = '';
            if (empty($actionstatus->actions)) {
                $actions .= $strs->none;
            } else {
                foreach ($actionstatus->actions as $val) {
                    $actions .= authorize_print_action_button($record->id, $val);
                }
            }
            $table->add_data(array("<a href='index.php?order={$record->id}'>{$record->id}</a>", $record->ccname, userdate($record->timecreated), "<font style='color:{$color}'>" . $authstrs->{$actionstatus->status} . "</font>", $actions));
        }
    }
    $table->print_html();
    echo $OUTPUT->footer();
}
Ejemplo n.º 23
0
 /**
  * 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, $OUTPUT;
     /// Do the job, setting result as needed
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . $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
     /// Fetch request data
     $tableparam = required_param('table', PARAM_CLEAN);
     if (!($table =& $structure->getTable($tableparam))) {
         $this->errormsg = 'Wrong table specified: ' . $tableparam;
         return false;
     }
     $indexparam = required_param('index', PARAM_CLEAN);
     if (!($index =& $table->getIndex($indexparam))) {
         /// Arriving here from a name change, looking for the new key name
         $indexparam = required_param('name', PARAM_CLEAN);
         $index =& $table->getIndex($indexparam);
     }
     $dbdir =& $XMLDB->dbdirs[$dirpath];
     $origstructure =& $dbdir->xml_file->getStructure();
     /// Add the main 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 ="table" value="' . $tableparam . '" />';
     $o .= '    <input type="hidden" name ="index" value="' . $indexparam . '" />';
     $o .= '    <input type="hidden" name ="action" value="edit_index_save" />';
     $o .= '    <input type="hidden" name ="postaction" value="edit_table" />';
     $o .= '    <table id="formelements" class="boxaligncenter">';
     /// XMLDB index name
     /// If the index has dependencies, we cannot change its name
     $disabled = '';
     if ($structure->getIndexUses($table->getName(), $index->getName())) {
         $disabled = ' disabled="disabled " ';
     }
     $o .= '      <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" id="name"' . $disabled . ' value="' . s($index->getName()) . '" /></td></tr>';
     /// XMLDB key comment
     $o .= '      <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td colspan="2"><textarea name="comment" rows="3" cols="80" id="comment">' . s($index->getComment()) . '</textarea></td></tr>';
     /// xmldb_index Type
     $typeoptions = array(0 => 'not unique', 1 => 'unique');
     $o .= '      <tr valign="top"><td><label for="menuunique" accesskey="t">Type:</label></td>';
     $select = html_select::make($typeoptions, 'unique', $index->getUnique(), false);
     $select->nothingvalue = '';
     $o .= '        <td colspan="2">' . $OUTPUT->select($select) . '</td></tr>';
     /// xmldb_index Fields
     $o .= '      <tr valign="top"><td><label for="fields" accesskey="f">Fields:</label></td>';
     $o .= '        <td colspan="2"><input name="fields" type="text" size="40" maxlength="80" id="fields" value="' . s(implode(', ', $index->getFields())) . '" /></td></tr>';
     /// Change button
     $o .= '      <tr valign="top"><td>&nbsp;</td><td colspan="2"><input type="submit" value="' . $this->str['change'] . '" /></td></tr>';
     $o .= '    </table>';
     $o .= '</div></form>';
     /// Calculate the buttons
     $b = ' <p class="centerpara buttons">';
     /// The view original XML button
     if ($table->getIndex($indexparam)) {
         $b .= '&nbsp;<a href="index.php?action=view_index_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;select=original&amp;table=' . $tableparam . '&amp;index=' . $indexparam . '">[' . $this->str['vieworiginal'] . ']</a>';
     } else {
         $b .= '&nbsp;[' . $this->str['vieworiginal'] . ']';
     }
     /// The view edited XML button
     if ($index->hasChanged()) {
         $b .= '&nbsp;<a href="index.php?action=view_index_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;select=edited&amp;table=' . $tableparam . '&amp;index=' . $indexparam . '">[' . $this->str['viewedited'] . ']</a>';
     } else {
         $b .= '&nbsp;[' . $this->str['viewedited'] . ']';
     }
     /// The back to edit table button
     $b .= '&nbsp;<a href="index.php?action=edit_table&amp;table=' . $tableparam . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
     $b .= '</p>';
     $o .= $b;
     $this->output = $o;
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
Ejemplo n.º 24
0
        <td align="right" width="20%"><?php 
print_string('popupformat', 'glossary');
?>
</td>
        <td>
     <?php 
//get and update available formats
$recformats = glossary_get_available_formats();
$formats = array();
//Take names
foreach ($recformats as $format) {
    $formats[$format->name] = get_string("displayformat{$format->name}", "glossary");
}
//Sort it
asort($formats);
echo $OUTPUT->select(html_select::make($formats, 'popupformatname', $displayformat->popupformatname));
?>
        </td>
        <td width="60%">
        <?php 
print_string("cnfrelatedview", "glossary");
?>
<br /><br />
        </td>
    </tr>
    <tr valign="top">
        <td align="right" width="20%"><?php 
print_string('defaultmode', 'glossary');
?>
</td>
        <td>
Ejemplo n.º 25
0
echo '<input type="hidden" name="sesskey" value="' . 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 = $DB->get_record('user', array('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');
echo $OUTPUT->help_icon(moodle_help_icon::make('writing', get_string('helpwriting')));
echo '<br /><textarea name="content" rows="5" cols="50">' . strip_tags(@$content) . '</textarea></p>';
echo '<p>' . $strpublishstate;
echo $OUTPUT->help_icon(moodle_help_icon::make('status', $strpublishstate, 'notes'));
echo $OUTPUT->select(html_select::make($state_names, 'state', empty($state) ? NOTES_STATE_PUBLIC : $state, false));
echo '</p>';
echo '<input type="submit" value="' . get_string('savechanges') . '" /></div></form>';
echo $OUTPUT->footer();
Ejemplo n.º 26
0
echo '<form class="tag-management-form" method="post" action="' . $CFG->wwwroot . '/tag/manage.php"><div>';
//retrieve tags from DB
if ($tagrecords = $DB->get_records_sql($query, $params, $table->get_page_start(), $table->get_page_size())) {
    $taglist = array_values($tagrecords);
    //print_tag_cloud(array_values($DB->get_records_sql($query)), false);
    //populate table with data
    foreach ($taglist as $tag) {
        $id = $tag->id;
        $name = '<a href="' . $CFG->wwwroot . '/tag/index.php?id=' . $tag->id . '">' . tag_display_name($tag) . '</a>';
        $owner = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $tag->owner . '">' . fullname($tag) . '</a>';
        $count = $tag->count;
        $flag = $tag->flag;
        $timemodified = format_time(time() - $tag->timemodified);
        $checkbox = '<input type="checkbox" name="tagschecked[]" value="' . $tag->id . '" />';
        $text = '<input type="text" name="newname[' . $tag->id . ']" />';
        $tagtype = $OUTPUT->select(html_select::make($existing_tagtypes, 'tagtypes[' . $tag->id . ']', $tag->tagtype, false));
        //if the tag if flagged, highlight it
        if ($tag->flag > 0) {
            $id = '<span class="flagged-tag">' . $id . '</span>';
            $name = '<span class="flagged-tag">' . $name . '</span>';
            $owner = '<span class="flagged-tag">' . $owner . '</span>';
            $count = '<span class="flagged-tag">' . $count . '</span>';
            $flag = '<span class="flagged-tag">' . $flag . '</span>';
            $timemodified = '<span class="flagged-tag">' . $timemodified . '</span>';
            $tagtype = '<span class="flagged-tag">' . $tagtype . '</span>';
        }
        $data = array($id, $name, $owner, $count, $flag, $timemodified, $text, $tagtype, $checkbox);
        $table->add_data($data);
    }
    echo '<input type="button" onclick="checkall()" value="' . get_string('selectall') . '" /> ';
    echo '<input type="button" onclick="checknone()" value="' . get_string('deselectall') . '" /> ';
Ejemplo n.º 27
0
admin_externalpage_setup('reportquestioninstances');
admin_externalpage_print_header();
// Log.
add_to_log(SITEID, "admin", "report questioninstances", "report/questioninstances/index.php?qtype={$requestedqtype}", $requestedqtype);
// Prepare the list of capabilites to choose from
$qtypechoices = array();
foreach ($QTYPES as $qtype) {
    $qtypechoices[$qtype->name()] = $qtype->local_name();
}
// Print the settings form.
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter centerpara');
echo '<form method="get" action="." id="settingsform"><div>';
echo $OUTPUT->heading(get_string('reportsettings', 'report_questioninstances'));
echo '<p id="intro">', get_string('intro', 'report_questioninstances'), '</p>';
echo '<p><label for="menuqtype"> ' . get_string('questiontype', 'admin') . '</label> ';
$select = html_select::make($qtypechoices, 'qtype', $requestedqtype, get_string('all'));
$select->nothingvalue = '_all_';
echo $OUTPUT->select($select);
echo '</p>';
echo '<p><input type="submit" id="settingssubmit" value="' . get_string('getreport', 'report_questioninstances') . '" /></p>';
echo '</div></form>';
echo $OUTPUT->box_end();
// If we have a qtype to report on, generate the report.
if ($requestedqtype) {
    // Work out the bits needed for the SQL WHERE clauses.
    if ($requestedqtype == 'missingtype') {
        $othertypes = array_keys($QTYPES);
        $key = array_search('missingtype', $othertypes);
        unset($othertypes[$key]);
        list($sqlqtypetest, $params) = $DB->get_in_or_equal($othertypes, SQL_PARAMS_QM, '', false);
        $sqlqtypetest = 'WHERE qtype ' . $sqlqtypetest;
Ejemplo n.º 28
0
echo "<input type=\"hidden\" name=\"resources\" value=\"{$count}\" />\n";
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="adminname">' . get_string("administrator") . '</label></div>';
echo '<div class="felement ftext">';
echo "<input size=\"50\" type=\"text\" id=\"adminname\" name=\"adminname\" value=\"" . fullname($admin, true) . "\" />";
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="adminemail">' . get_string("email") . '</label></div>';
echo '<div class="felement ftext">';
echo "<input size=\"50\" type=\"text\" id=\"adminemail\" name=\"adminemail\" value=\"{$admin->email}\" />";
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="menumailme">' . get_string("registrationemail") . '</label></div>';
echo '<div class="felement ftext">';
$options[0] = get_string("registrationno");
$options[1] = get_string("registrationyes");
$select = html_select::make($options, "mailme", "1", false);
$select->nothingvalue = '';
echo $OUTPUT->select($select);
unset($options);
echo '</div>';
echo '</div>';
echo '<div class="felement fsubmit"><input name="submitbutton" value="' . get_string('registrationsend') . '" type="submit" id="id_submitbutton" /></div>';
echo "</fieldset>\n";
echo "</form>\n";
/// Print footer
echo $OUTPUT->footer();
Ejemplo n.º 29
0
 /**
  *  Display all the submissions ready for grading
  *
  * @global object
  * @global object
  * @global object
  * @global object
  * @param string $message
  * @return bool|void
  */
 function display_submissions($message = '')
 {
     global $CFG, $DB, $USER, $DB, $OUTPUT;
     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;
     }
     $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->cm->id, $this->assignment->id, $this->cm->id);
     $navigation = build_navigation($this->strsubmissions, $this->cm);
     print_header_simple(format_string($this->assignment->name, true), "", $navigation, '', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm));
     $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
     if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
         echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">' . get_string('seeallcoursegrades', 'grades') . '</a></div>';
     }
     if (!empty($message)) {
         echo $message;
         // display messages here if any
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// Check to see if groups are being used in this assignment
     /// 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
     if ($users = get_users_by_capability($context, 'mod/assignment:submit', 'u.id', '', '', '', $currentgroup, '', false)) {
         $users = array_keys($users);
     }
     // if groupmembersonly used, remove users who are not in any group
     if ($users and !empty($CFG->enablegroupings) and $cm->groupmembersonly) {
         if ($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') . ' (' . get_string('submission', 'assignment') . ')', get_string('lastmodified') . ' (' . get_string('grade') . ')', 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', '100%');
     //$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();
     if (empty($users)) {
         echo $OUTPUT->heading(get_string('nosubmitusers', '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, u.imagealt,
                       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 {user} u ' . 'LEFT JOIN {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 = $DB->get_records_sql($select . $sql . $sort, null, $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];
             $grademax = $grading_info->items[0]->grademax;
             $final_grade->formatted_grade = round($final_grade->grade, 2) . ' / ' . round($grademax, 2);
             $locked_overridden = 'locked';
             if ($final_grade->overridden) {
                 $locked_overridden = 'overridden';
             }
             /// Calculate user status
             $auser->status = $auser->timemarked > 0 && $auser->timemarked >= $auser->timemodified;
             $picture = $OUTPUT->user_picture(moodle_user_picture::make($auser, $course->id));
             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 . '" class="' . $locked_overridden . '">' . $final_grade->formatted_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $select = html_select::make(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'));
                             $select->nothingvalue = '-1';
                             $select->tabindex = $tabindex++;
                             $menu = $OUTPUT->select($select);
                             $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 . '" class="' . $locked_overridden . '">' . $final_grade->formatted_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $select = html_select::make(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'));
                             $select->nothingvalue = '-1';
                             $select->tabindex = $tabindex++;
                             $menu = $OUTPUT->select($select);
                             $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->formatted_grade . '</div>';
                 } else {
                     if ($quickgrade) {
                         // allow editing
                         $select = html_select::make(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'));
                         $select->nothingvalue = '-1';
                         $select->tabindex = $tabindex++;
                         $menu = $OUTPUT->select($select);
                         $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 . '&userid=' . $auser->id . '&mode=single' . '&offset=' . $offset++;
             $link = html_link::make($popup_url, $buttontext);
             $link->add_action(new popup_action('click', $link->url, 'grade' . $auser->id, array('height' => 600, 'width' => 700)));
             $link->title = $buttontext;
             $button = $OUTPUT->link($link);
             $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 .= ' ';
                         $select = html_select::make($options, 'outcome_' . $n . '[' . $auser->id . ']', $outcome->grades[$auser->id]->grade, get_string('nooutcome', 'grades'));
                         $select->nothingvalue = '0';
                         $select->tabindex = $tabindex++;
                         $select->id = 'outcome_' . $n . '_' . $auser->id;
                         $outcomes .= $OUTPUT->select($select);
                     }
                     $outcomes .= '</div>';
                 }
             }
             $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&amp;course=' . $course->id . '">' . fullname($auser) . '</a>';
             $row = array($picture, $userlink, $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>';
     }
     $table->print_html();
     /// Print the whole table
     if ($quickgrade) {
         $lastmailinfo = get_user_preferences('assignment_mailinfo', 1) ? 'checked="checked"' : '';
         echo '<div class="fgcontrols">';
         echo '<div class="emailnotification">';
         echo '<label for="mailinfo">' . get_string('enableemailnotification', 'assignment') . '</label>';
         echo '<input type="hidden" name="mailinfo" value="0" />';
         echo '<input type="checkbox" id="mailinfo" name="mailinfo" value="1" ' . $lastmailinfo . ' />';
         echo $OUTPUT->help_icon(moodle_help_icon::make('emailnotification', get_string('enableemailnotification', 'assignment'), 'assignment')) . '</p></div>';
         echo '</div>';
         echo '<div class="fastgbutton"><input type="submit" name="fastg" value="' . get_string('saveallfeedback', 'assignment') . '" /></div>';
         echo '</div>';
         echo '</form>';
     }
     /// End of fast grading form
     /// Mini form for setting user preference
     echo '<div class="qgprefs">';
     echo '<form id="options" action="submissions.php?id=' . $this->cm->id . '" method="post"><div>';
     echo '<input type="hidden" name="updatepref" value="1" />';
     echo '<table id="optiontable">';
     echo '<tr><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 . '" />';
     echo $OUTPUT->help_icon(moodle_help_icon::make('pagesize', get_string('pagesize', 'assignment'), 'assignment'));
     echo '</td></tr>';
     echo '<tr><td>';
     echo '<label for="quickgrade">' . get_string('quickgrade', 'assignment') . '</label>';
     echo '</td>';
     echo '<td>';
     $checked = $quickgrade ? 'checked="checked"' : '';
     echo '<input type="checkbox" id="quickgrade" name="quickgrade" value="1" ' . $checked . ' />';
     echo $OUTPUT->help_icon(moodle_help_icon::make('quickgrade', get_string('quickgrade', 'assignment'), 'assignment')) . '</p></div>';
     echo '</td></tr>';
     echo '<tr><td colspan="2">';
     echo '<input type="submit" value="' . get_string('savepreferences') . '" />';
     echo '</td></tr></table>';
     echo '</div></form></div>';
     ///End of mini form
     echo $OUTPUT->footer();
 }
Ejemplo n.º 30
0
    if (!($us = $DB->get_records_sql($sql, $param->params))) {
        print_error('nousers');
    }
    foreach ($us as $u) {
        $users[$u->userid] = fullname($u, true);
    }
    $table->align = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left');
    $table->data[] = array(get_string('course'), $OUTPUT->select(html_select::make($courseoptions, 'course', $course->id, false)), get_string('users'), $OUTPUT->select(html_select::make($users, 'userid', $userid, false)), get_string('statsreporttype'), $OUTPUT->select(html_select::make($reportoptions, 'report', $report == 5 ? $report . $roleid : $report, false)), get_string('statstimeperiod'), $OUTPUT->select(html_select::make($timeoptions, 'time', $time, false)), '<input type="submit" value="' . get_string('view') . '" />');
} else {
    if ($mode == STATS_MODE_RANKED) {
        $table->align = array('left', 'left', 'left', 'left', 'left', 'left');
        $table->data[] = array(get_string('statsreporttype'), $OUTPUT->select(html_select::make($reportoptions, 'report', $report == 5 ? $report . $roleid : $report, false)), get_string('statstimeperiod'), $OUTPUT->select(html_select::make($timeoptions, 'time', $time, false)), '<input type="submit" value="' . get_string('view') . '" />');
    } else {
        if ($mode == STATS_MODE_GENERAL) {
            $table->align = array('left', 'left', 'left', 'left', 'left', 'left', 'left');
            $table->data[] = array(get_string('course'), $OUTPUT->select(html_select::make($courseoptions, 'course', $course->id, false)), get_string('statsreporttype'), $OUTPUT->select(html_select::make($reportoptions, 'report', $report == 5 ? $report . $roleid : $report, false)), get_string('statstimeperiod'), $OUTPUT->select(html_select::make($timeoptions, 'time', $time, false)), '<input type="submit" value="' . get_string('view') . '" />');
        }
    }
}
echo '<form action="index.php" method="post">' . "\n" . '<div>' . "\n" . '<input type="hidden" name="mode" value="' . $mode . '" />' . "\n";
echo $OUTPUT->table($table);
echo '</div>';
echo '</form>';
if (!empty($report) && !empty($time)) {
    if ($report == STATS_REPORT_LOGINS && $course->id != SITEID) {
        print_error('reportnotavailable');
    }
    $param = stats_get_parameters($time, $report, $course->id, $mode);
    if ($mode == STATS_MODE_DETAILED) {
        $param->table = 'user_' . $param->table;
    }