当前位置: 首页>>代码示例>>PHP>>正文


PHP feedback_get_item_class函数代码示例

本文整理汇总了PHP中feedback_get_item_class函数的典型用法代码示例。如果您正苦于以下问题:PHP feedback_get_item_class函数的具体用法?PHP feedback_get_item_class怎么用?PHP feedback_get_item_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了feedback_get_item_class函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: feedback_update_values

/**
 * this function updates a complete-record and the related value-records.
 * depending on the $tmp (true/false) the values are saved temporary or permanently
 *
 * @global object
 * @param object $completed
 * @param boolean $tmp
 * @return int the completedid
 */
function feedback_update_values($completed, $tmp = false) {
    global $DB;

    $courseid = optional_param('courseid', false, PARAM_INT);
    $tmpstr = $tmp ? 'tmp' : '';

    $DB->update_record('feedback_completed'.$tmpstr, $completed);
    //get the values of this completed
    $values = $DB->get_records('feedback_value'.$tmpstr, array('completed'=>$completed->id));

    //get the items of the feedback
    if (!$allitems = $DB->get_records('feedback_item', array('feedback'=>$completed->feedback))) {
        return false;
    }
    foreach ($allitems as $item) {
        if (!$item->hasvalue) {
            continue;
        }
        //get the class of item-typ
        $itemobj = feedback_get_item_class($item->typ);

        $keyname = $item->typ.'_'.$item->id;

        if ($itemobj->value_is_array()) {
            $itemvalue = optional_param_array($keyname, null, $itemobj->value_type());
        } else {
            $itemvalue = optional_param($keyname, null, $itemobj->value_type());
        }

        //is the itemvalue set (could be a subset of items because pagebreak)?
        if (is_null($itemvalue)) {
            continue;
        }

        $newvalue = new stdClass();
        $newvalue->item = $item->id;
        $newvalue->completed = $completed->id;
        $newvalue->course_id = $courseid;

        //the kind of values can be absolutely different
        //so we run create_value directly by the item-class
        $newvalue->value = $itemobj->create_value($itemvalue);

        //check, if we have to create or update the value
        $exist = false;
        foreach ($values as $value) {
            if ($value->item == $newvalue->item) {
                $newvalue->id = $value->id;
                $exist = true;
                break;
            }
        }
        if ($exist) {
            $DB->update_record('feedback_value'.$tmpstr, $newvalue);
        } else {
            $DB->insert_record('feedback_value'.$tmpstr, $newvalue);
        }
    }

    return $completed->id;
}
开发者ID:numbas,项目名称:moodle,代码行数:70,代码来源:lib.php

示例2: feedback_excelprint_detailed_items

function feedback_excelprint_detailed_items(&$worksheet, $xlsFormats, $completed, $items, $rowOffset)
{
    global $DB, $fstring;
    if (!$items) {
        return;
    }
    $colOffset = 0;
    $courseid = 0;
    $feedback = $DB->get_record('feedback', array('id' => $completed->feedback));
    //get the username
    //anonymous users are separated automatically because the userid in the completed is "0"
    // $worksheet->setFormat('<l><f><ru2>');
    if ($user = $DB->get_record('user', array('id' => $completed->userid))) {
        if ($completed->anonymous_response == FEEDBACK_ANONYMOUS_NO) {
            $worksheet->write_string($rowOffset, $colOffset, $user->idnumber, $xlsFormats->head2);
            $colOffset++;
            $userfullname = fullname($user);
            $worksheet->write_string($rowOffset, $colOffset, $user->username, $xlsFormats->head2);
            $colOffset++;
        } else {
            $userfullname = $fstring->anonymous_user;
            $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
            $colOffset++;
            $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
            $colOffset++;
        }
    } else {
        $userfullname = $fstring->anonymous_user;
        $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
        $colOffset++;
        $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
        $colOffset++;
    }
    $worksheet->write_string($rowOffset, $colOffset, $userfullname, $xlsFormats->head2);
    $colOffset++;
    foreach ($items as $item) {
        $value = $DB->get_record('feedback_value', array('item' => $item->id, 'completed' => $completed->id));
        $itemobj = feedback_get_item_class($item->typ);
        $printval = $itemobj->get_printval($item, $value);
        $printval = trim($printval);
        // $worksheet->setFormat('<l><vo>');
        if (is_numeric($printval)) {
            $worksheet->write_number($rowOffset, $colOffset, $printval, $xlsFormats->default);
        } elseif ($printval != '') {
            $worksheet->write_string($rowOffset, $colOffset, $printval, $xlsFormats->default);
        }
        $printval = '';
        $colOffset++;
        $courseid = isset($value->course_id) ? $value->course_id : 0;
        if ($courseid == 0) {
            $courseid = $feedback->course;
        }
    }
    $worksheet->write_number($rowOffset, $colOffset, $courseid, $xlsFormats->default);
    $colOffset++;
    if (isset($courseid) and $course = $DB->get_record('course', array('id' => $courseid))) {
        $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid)));
        $worksheet->write_string($rowOffset, $colOffset, $shortname, $xlsFormats->default);
    }
    return $rowOffset + 1;
}
开发者ID:hatone,项目名称:moodle,代码行数:61,代码来源:analysis_to_excel.php

示例3: array

                                  null, array('id'=>'coursefilterid'));

         $PAGE->requires->js_init_call('M.util.init_select_autosubmit',
                                        array('analysis-form', 'coursefilterid', false));
    }
    echo '<hr />';
    $itemnr = 0;
    //print the items in an analysed form
    echo '<tr><td>';
    foreach ($items as $item) {
        if ($item->hasvalue == 0) {
            continue;
        }
        echo '<table width="100%" class="generalbox">';
        //get the class from item-typ
        $itemobj = feedback_get_item_class($item->typ);
        $itemnr++;
        if ($feedback->autonumbering) {
            $printnr = $itemnr.'.';
        } else {
            $printnr = '';
        }
        $itemobj->print_analysed($item, $printnr, $mygroupid, $coursefilter);
        if (preg_match('/rated$/i', $item->typ)) {
            $onclick = 'onclick="setcourseitemfilter'.
                        "(".$item->id.",'".$item->typ."');".
                        ' return false;"';

            $anker = '<a href="#" '.$onclick.'>'.
                     get_string('sort_by_course', 'feedback').
                     '</a>';
开发者ID:JP-Git,项目名称:moodle,代码行数:31,代码来源:analysis_course.php

示例4: add_all_values_to_output

 /**
  * Adds common values to the table that do not change the number or order of entries and
  * are only needed when outputting or downloading data.
  */
 protected function add_all_values_to_output()
 {
     $tablecolumns = array_keys($this->columns);
     $tableheaders = $this->headers;
     // Add all feedback response values.
     $items = $this->feedbackstructure->get_items(true);
     foreach ($items as $nr => $item) {
         $this->sql->fields .= ", v{$nr}.value AS val{$nr}";
         $this->sql->from .= " LEFT OUTER JOIN {feedback_value} v{$nr} " . "ON v{$nr}.completed = c.id AND v{$nr}.item = :itemid{$nr}";
         $this->sql->params["itemid{$nr}"] = $item->id;
         $tablecolumns[] = "val{$nr}";
         $itemobj = feedback_get_item_class($item->typ);
         $tableheaders[] = $itemobj->get_display_name($item);
     }
     // Add 'Delete entry' column.
     if (!$this->is_downloading() && has_capability('mod/feedback:deletesubmissions', $this->get_context())) {
         $tablecolumns[] = 'deleteentry';
         $tableheaders[] = '';
     }
     $this->define_columns($tablecolumns);
     $this->define_headers($tableheaders);
 }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:26,代码来源:responses_table.php

示例5: enhance_name_for_edit

 /**
  * Adds editing actions to the question name in the edit mode
  * @param stdClass $item
  * @param HTML_QuickForm_element $element
  */
 protected function enhance_name_for_edit($item, $element)
 {
     global $OUTPUT;
     $menu = new action_menu();
     $menu->set_owner_selector('#' . $this->guess_element_id($item, $element));
     $menu->set_constraint('.feedback_form');
     $menu->set_alignment(action_menu::TR, action_menu::BR);
     $menu->set_menu_trigger(get_string('edit'));
     $menu->prioritise = true;
     $itemobj = feedback_get_item_class($item->typ);
     $actions = $itemobj->edit_actions($item, $this->get_feedback(), $this->get_cm());
     foreach ($actions as $action) {
         $menu->add($action);
     }
     $editmenu = $OUTPUT->render($menu);
     $name = $element->getLabel();
     $name = html_writer::span('', 'itemdd', array('id' => 'feedback_item_box_' . $item->id)) . html_writer::span($name, 'itemname') . html_writer::span($editmenu, 'itemactions');
     $element->setLabel(html_writer::span($name, 'itemtitle'));
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:24,代码来源:complete_form.php

示例6: feedback_update_values

/**
 * this function updates a complete-record and the related value-records.
 * depending on the $tmp (true/false) the values are saved temporary or permanently
 *
 * @global object
 * @param object $completed
 * @param boolean $tmp
 * @return int the completedid
 */
function feedback_update_values($completed, $tmp = false)
{
    global $DB;
    debugging('Function feedback_update_values() was deprecated because it did not have ' . 'enough arguments, was not suitable for non-temporary table and was taking ' . 'data directly from input', DEBUG_DEVELOPER);
    $courseid = optional_param('courseid', false, PARAM_INT);
    $tmpstr = $tmp ? 'tmp' : '';
    $DB->update_record('feedback_completed' . $tmpstr, $completed);
    //get the values of this completed
    $values = $DB->get_records('feedback_value' . $tmpstr, array('completed' => $completed->id));
    //get the items of the feedback
    if (!($allitems = $DB->get_records('feedback_item', array('feedback' => $completed->feedback)))) {
        return false;
    }
    foreach ($allitems as $item) {
        if (!$item->hasvalue) {
            continue;
        }
        //get the class of item-typ
        $itemobj = feedback_get_item_class($item->typ);
        $keyname = $item->typ . '_' . $item->id;
        if ($item->typ === 'multichoice') {
            $itemvalue = optional_param_array($keyname, null, PARAM_INT);
        } else {
            $itemvalue = optional_param($keyname, null, PARAM_NOTAGS);
        }
        //is the itemvalue set (could be a subset of items because pagebreak)?
        if (is_null($itemvalue)) {
            continue;
        }
        $newvalue = new stdClass();
        $newvalue->item = $item->id;
        $newvalue->completed = $completed->id;
        $newvalue->course_id = $courseid;
        //the kind of values can be absolutely different
        //so we run create_value directly by the item-class
        $newvalue->value = $itemobj->create_value($itemvalue);
        //check, if we have to create or update the value
        $exist = false;
        foreach ($values as $value) {
            if ($value->item == $newvalue->item) {
                $newvalue->id = $value->id;
                $exist = true;
                break;
            }
        }
        if ($exist) {
            $DB->update_record('feedback_value' . $tmpstr, $newvalue);
        } else {
            $DB->insert_record('feedback_value' . $tmpstr, $newvalue);
        }
    }
    return $completed->id;
}
开发者ID:evltuma,项目名称:moodle,代码行数:62,代码来源:lib.php

示例7: save_response_tmp

 /**
  * Saves unfinished response to the temporary table
  *
  * This is called when user proceeds to the next/previous page in the complete form
  * and also right after the form submit.
  * After the form submit the {@link save_response()} is called to
  * move response from temporary table to completion table.
  *
  * @param stdClass $data data from the form mod_feedback_complete_form
  */
 public function save_response_tmp($data)
 {
     global $DB;
     if (!($completedtmp = $this->get_current_completed_tmp())) {
         $completedtmp = $this->create_current_completed_tmp();
     } else {
         $currentime = time();
         $DB->update_record('feedback_completedtmp', ['id' => $completedtmp->id, 'timemodified' => $currentime]);
         $completedtmp->timemodified = $currentime;
     }
     // Find all existing values.
     $existingvalues = $DB->get_records_menu('feedback_valuetmp', ['completed' => $completedtmp->id], '', 'item, id');
     // Loop through all feedback items and save the ones that are present in $data.
     $allitems = $this->get_items();
     foreach ($allitems as $item) {
         if (!$item->hasvalue) {
             continue;
         }
         $keyname = $item->typ . '_' . $item->id;
         if (!isset($data->{$keyname})) {
             // This item is either on another page or dependency was not met - nothing to save.
             continue;
         }
         $newvalue = ['item' => $item->id, 'completed' => $completedtmp->id, 'course_id' => $completedtmp->courseid];
         // Convert the value to string that can be stored in 'feedback_valuetmp' or 'feedback_value'.
         $itemobj = feedback_get_item_class($item->typ);
         $newvalue['value'] = $itemobj->create_value($data->{$keyname});
         // Update or insert the value in the 'feedback_valuetmp' table.
         if (array_key_exists($item->id, $existingvalues)) {
             $newvalue['id'] = $existingvalues[$item->id];
             $DB->update_record('feedback_valuetmp', $newvalue);
         } else {
             $DB->insert_record('feedback_valuetmp', $newvalue);
         }
     }
     // Reset valuestmp cache.
     $this->valuestmp = null;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:48,代码来源:completion.php

示例8: add_all_values_to_output

 /**
  * Adds common values to the table that do not change the number or order of entries and
  * are only needed when outputting or downloading data.
  */
 protected function add_all_values_to_output()
 {
     $tablecolumns = array_keys($this->columns);
     $tableheaders = $this->headers;
     $items = $this->feedbackstructure->get_items(true);
     if (!$this->is_downloading()) {
         // In preview mode do not show all columns or the page becomes unreadable.
         // The information message will be displayed to the teacher that the rest of the data can be viewed when downloading.
         $items = array_slice($items, 0, self::PREVIEWCOLUMNSLIMIT, true);
     }
     $columnscount = 0;
     $this->hasmorecolumns = max(0, count($items) - self::TABLEJOINLIMIT);
     // Add feedback response values.
     foreach ($items as $nr => $item) {
         if ($columnscount++ < self::TABLEJOINLIMIT) {
             // Mysql has a limit on the number of tables in the join, so we only add limited number of columns here,
             // the rest will be added in {@link self::build_table()} and {@link self::build_table_chunk()} functions.
             $this->sql->fields .= ", v{$nr}.value AS val{$nr}";
             $this->sql->from .= " LEFT OUTER JOIN {feedback_value} v{$nr} " . "ON v{$nr}.completed = c.id AND v{$nr}.item = :itemid{$nr}";
             $this->sql->params["itemid{$nr}"] = $item->id;
         }
         $tablecolumns[] = "val{$nr}";
         $itemobj = feedback_get_item_class($item->typ);
         $tableheaders[] = $itemobj->get_display_name($item);
     }
     // Add 'Delete entry' column.
     if (!$this->is_downloading() && has_capability('mod/feedback:deletesubmissions', $this->get_context())) {
         $tablecolumns[] = 'deleteentry';
         $tableheaders[] = '';
     }
     $this->define_columns($tablecolumns);
     $this->define_headers($tableheaders);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:37,代码来源:responses_table.php


注:本文中的feedback_get_item_class函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。