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


PHP hotpot_strings函数代码示例

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


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

示例1: create_clickreport_table

 function create_clickreport_table(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options, &$tables)
 {
     global $CFG;
     $is_html = $options['reportformat'] == 'htm';
     // time and date format strings		// date format strings
     $strftimetime = '%H:%M:%S';
     $strftimedate = get_string('strftimedate');
     // get the current time and max execution time
     $start_report_time = microtime();
     $max_execution_time = ini_get('max_execution_time');
     $correct = get_string('reportcorrectsymbol', 'hotpot');
     $wrong = get_string('reportwrongsymbol', 'hotpot');
     $nottried = get_string('reportnottriedsymbol', 'hotpot');
     // shortcuts for font tags
     $blank = $is_html ? ' ' : "";
     // store question count
     $questioncount = count($questions);
     // array to map columns onto question ids ($col => $id)
     $questionids = array_keys($questions);
     // store exercise type
     $exercisetype = $this->get_exercisetype($questions, $questionids, $blank);
     // initialize details ('events' must go last)
     $details = array('checks', 'status', 'answers', 'changes', 'hints', 'clues', 'events');
     // initialize $table
     unset($table);
     $table->border = 1;
     $table->width = '100%';
     // initialize legend, if necessary
     if (!empty($options['reportshowlegend'])) {
         $table->legend = array();
     }
     // start $table headings
     $this->set_head($options, $table, 'exercise');
     $this->set_head($options, $table, 'user');
     $this->set_head($options, $table, 'attempt');
     $this->set_head($options, $table, 'click');
     // store clicktype column number
     $clicktype_col = count($table->head) - 1;
     // finish $table headings
     $this->set_head($options, $table, 'details', $exercisetype, $details, $questioncount);
     $this->set_head($options, $table, 'totals', $exercisetype);
     // set align and wrap
     $this->set_align_and_wrap($table);
     // is link to review allowed?
     $allow_review = $is_html && (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review);
     // initialize array of data values
     $this->data = array();
     // set exercise data values
     $this->set_data_exercise($cm, $course, $hotpot, $questions, $questionids, $questioncount, $blank);
     // add details of users' responses
     foreach ($users as $user) {
         $this->set_data_user($options, $course, $user);
         unset($clickreportid);
         foreach ($user->attempts as $attempt) {
             // initialize totals for
             $click = array('qnumber' => array(), 'correct' => array(), 'wrong' => array(), 'answers' => array(), 'hints' => array(), 'clues' => array(), 'changes' => array(), 'checks' => array(), 'events' => array(), 'score' => array(), 'weighting' => array());
             $clicktypes = array();
             // is the start of a new attempt?
             // (clicks in the same attempt have the same clickreportid)
             if (!isset($clickreportid) || $clickreportid != $attempt->clickreportid) {
                 $clickcount = 1;
                 $clickreportid = $attempt->clickreportid;
                 // initialize totals for all clicks in this attempt
                 $clicks = $click;
                 // $click has just been initialized
                 $this->set_data_attempt($attempt, $strftimedate, $strftimetime, $blank);
             }
             $cells = array();
             $this->set_data($cells, 'exercise');
             $this->set_data($cells, 'user');
             $this->set_data($cells, 'attempt');
             // get responses to questions in this attempt
             foreach ($attempt->responses as $response) {
                 // set $q(uestion number)
                 $q = array_search($response->question, $questionids);
                 $click['qnumber'][$q] = true;
                 // was this question answered correctly?
                 if ($answer = hotpot_strings($response->correct)) {
                     // mark the question as correctly answered
                     if (empty($clicks['correct'][$q])) {
                         $click['correct'][$q] = true;
                         $clicks['correct'][$q] = true;
                     }
                     // unset 'wrong' flags, if necessary
                     if (isset($click['wrong'][$q])) {
                         unset($click['wrong'][$q]);
                     }
                     if (isset($clicks['wrong'][$q])) {
                         unset($clicks['wrong'][$q]);
                     }
                     // otherwise, was the question answered wrongly?
                 } else {
                     if ($answer = hotpot_strings($response->wrong)) {
                         // mark the question as wrongly answered
                         $click['wrong'][$q] = true;
                         $clicks['wrong'][$q] = true;
                     } else {
                         // not correct or wrong (curious?!)
                         unset($answer);
                     }
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:report.php

示例2: hotpot_get_question_name

function hotpot_get_question_name($question)
{
    $name = '';
    if (isset($question->text)) {
        $name = hotpot_strings($question->text);
    }
    if (empty($name)) {
        $name = $question->name;
    }
    return $name;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:11,代码来源:lib.php

示例3: hotpot_set_attempt_details


//.........这里部分代码省略.........
                    if ($i < $correctlen) {
                        // append next correct letter
                        $responsevalue .= $firstcorrectvalue[$i];
                    }
                    $_POST[$responsefield] = $responsevalue;
                    $response->hints++;
                }
                // end if hint
            }
        }
        // end if not correct
        // get clue text, if any
        if (($field = "q{$q}_clue") && isset($_POST[$field])) {
            $response->clue_text = optional_param($field, '', PARAM_RAW);
        }
        // get question name
        $qq = sprintf('%02d', $q);
        // (a padded, two-digit version of $q)
        if (($field = "q{$q}_name") && isset($_POST[$field])) {
            $questionname = optional_param($field, '', PARAM_RAW);
            $questionname = strip_tags($questionname);
        } else {
            $questionname = $qq;
        }
        // get previous responses to this question (if any)
        $records = get_records_sql("\n            SELECT\n                r.*\n            FROM\n                {$CFG->prefix}hotpot_attempts a,\n                {$CFG->prefix}hotpot_questions q,\n                {$CFG->prefix}hotpot_responses r\n            WHERE\n                a.clickreportid = {$attempt->clickreportid} AND\n                a.id = r.attempt AND\n                r.question = q.id AND\n                q.name = '{$questionname}' AND\n                q.hotpot = {$attempt->hotpot}\n            ORDER BY\n                a.timefinish\n        ");
        if ($records) {
            foreach ($records as $record) {
                foreach ($buttons as $button) {
                    $oldresponse->{$button} = max($oldresponse->{$button}, $record->{$button});
                }
                foreach ($textfields as $field) {
                    if ($record->{$field} && ($field == 'correct' || $field == 'wrong')) {
                        $values = explode(',', hotpot_strings($record->{$field}));
                        $oldresponse->{$field} = array_merge($oldresponse->{$field}, $values);
                    }
                }
            }
        }
        // remove "correct" and "wrong" values from "ignored" values
        $response->ignored = array_diff($response->ignored, $response->correct, $response->wrong, $oldresponse->correct, $oldresponse->wrong);
        foreach ($buttons as $button) {
            $response->{$button} += $oldresponse->{$button};
        }
        $value_has_changed = false;
        foreach ($textfields as $field) {
            $response->{$field} = array_merge($oldresponse->{$field}, $response->{$field});
            $response->{$field} = array_unique($response->{$field});
            $response->{$field} = implode(',', $response->{$field});
            if ($field == 'correct' || $field == 'wrong') {
                $array = $oldresponse->{$field};
                $array = array_unique($array);
                $oldresponse->{$field} = implode(',', $array);
                if ($response->{$field} != $oldresponse->{$field}) {
                    $value_has_changed = true;
                }
            }
        }
        if ($value_has_changed) {
            $response->checks++;
        }
        // $response now holds amalgamation of all responses so far to this question
        // set question score and weighting
        if ($response->correct) {
            switch ($quiztype) {
                case HOTPOT_JCB:
开发者ID:kai707,项目名称:ITSA-backup,代码行数:67,代码来源:attempt.php


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