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


PHP stack_string函数代码示例

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


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

示例1: test_validation_error

 public function test_validation_error()
 {
     $casstring = new stack_cas_casstring('π');
     $casstring->get_valid('s');
     $this->assertEquals(stack_string('stackCas_forbiddenChar', array('char' => 'π')), $casstring->get_errors());
     $this->assertEquals('forbiddenChar', $casstring->get_answernote());
 }
开发者ID:profcab,项目名称:moodle-qtype_stack,代码行数:7,代码来源:casstring_test.php

示例2: test_maths_rendering

 public function test_maths_rendering()
 {
     if (!stack_maths_output_maths::filter_is_installed()) {
         $this->markTestSkipped('The OU maths filter is not installed.');
     }
     if (!defined('FILTER_MATHS_TEST_SERVICE_URL_BASE')) {
         $this->markTestSkipped('To run the OU maths filter output tests, ' . 'you must define FILTER_MATHS_TEST_SERVICE_URL_BASE in config.php.');
     }
     $this->resetAfterTest();
     set_config('mathsdisplay', 'maths', 'qtype_stack');
     set_config('texservice', FILTER_MATHS_TEST_SERVICE_URL_BASE . 'tex', 'filter_maths');
     set_config('imageservice', FILTER_MATHS_TEST_SERVICE_URL_BASE . 'imagetex', 'filter_maths');
     set_config('englishservice', FILTER_MATHS_TEST_SERVICE_URL_BASE . 'english', 'filter_maths');
     stack_utils::clear_config_cache();
     filter_set_global_state('mathjaxloader', TEXTFILTER_DISABLED);
     // Test language string.
     $this->assertRegExp('~^Your answer needs to be a single fraction of the form <a .*alt="a over b".*</a>\\. $~', stack_string('ATSingleFrac_part'));
     // Test docs - make sure maths inside <code> is not rendered.
     $this->assertRegExp('~^<p><code>\\\\\\(x\\^2\\\\\\)</code> gives <a .*alt="x squared".*</a>\\.</p>\\n$~', stack_docs_render_markdown('<code>\\(x^2\\)</code> gives \\(x^2\\).', ''));
     // Test docs - make sure maths inside <textarea> is not rendered.
     $this->assertRegExp('~^<p>\\n' . 'Differentiate \\\\\\\\\\[x\\^2 \\+ y\\^2\\\\\\\\\\] with respect to \\\\\\\\\\(x\\\\\\\\\\).</p>\\n$~', stack_docs_render_markdown('<textarea readonly="readonly" rows="3" cols="50">' . "\n" . 'Differentiate \\[x^2 + y^2\\] with respect to \\(x\\).</textarea>', ''));
     // Test CAS text with inline maths.
     $this->assertEquals('What is &lt;tex mode="inline"&gt;x^2&lt;/tex&gt;?', stack_maths::process_display_castext('What is \\(x^2\\)?'));
     // Test CAS text with display maths.
     $this->assertEquals('What is <span class="displayequation">&lt;tex mode="display"&gt;x^2&lt;/tex&gt;</span>?', stack_maths::process_display_castext('What is \\[x^2\\]?'));
     // Test with replacedollars.
     set_config('replacedollars', '1', 'qtype_stack');
     stack_utils::clear_config_cache();
     $this->assertEquals('What is &lt;tex mode="inline"&gt;x^2&lt;/tex&gt; or ' . '<span class="displayequation">&lt;tex mode="display"&gt;x^2&lt;/tex&gt;</span>?', stack_maths::process_display_castext('What is $x^2$ or $$x^2$$?'));
     stack_utils::clear_config_cache();
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:31,代码来源:mathsoutputmaths_test.php

示例3: extra_validation

 protected function extra_validation($contents)
 {
     if (strlen($contents[0]) > 1) {
         return stack_string('singlechargotmorethanone');
     }
     return '';
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:7,代码来源:singlechar.class.php

示例4: extra_validation

 protected function extra_validation($contents)
 {
     if (!array_key_exists($contents[0], $this->get_choices())) {
         return stack_string('booleangotunrecognisedvalue');
     }
     return '';
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:7,代码来源:boolean.class.php

示例5: add_to_moodleform_testinput

 public function add_to_moodleform_testinput(MoodleQuickForm $mform)
 {
     $values = $this->get_choices();
     if (empty($values)) {
         $mform->addElement('static', $this->name, stack_string('ddl_empty'));
     } else {
         $mform->addElement('select', $this->name, $this->name, $values);
     }
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:9,代码来源:dropdown.class.php

示例6: test_maths_output_mathsjax

 public function test_maths_output_mathsjax()
 {
     filter_set_global_state('mathjaxloader', TEXTFILTER_DISABLED);
     // MathJax output is the default.
     $this->assertEquals('Your answer needs to be a single fraction of the form \\( {a}\\over{b} \\). ', stack_string('ATSingleFrac_part'));
     $this->assertEquals("<p><code>\\(x^2\\)</code> gives \\(x^2\\).</p>\n", stack_docs_render_markdown('`\\(x^2\\)` gives \\(x^2\\).', ''));
     $this->assertEquals('What is \\(x^2\\)?', stack_maths::process_display_castext('What is \\(x^2\\)?'));
     $this->resetAfterTest();
     set_config('replacedollars', '1', 'qtype_stack');
     stack_utils::clear_config_cache();
     $this->assertEquals('What is \\(x^2\\) or \\[x^2\\]?', stack_maths::process_display_castext('What is $x^2$ or $$x^2$$?'));
     stack_utils::clear_config_cache();
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:13,代码来源:mathsoutputmathjax_test.php

示例7: stack_trans

/**
 * Translates a string taken as output from Maxima.
 *
 * This function takes a variable number of arguments, the first of which is assumed to be the identifier
 * of the string to be translated.
 */
function stack_trans()
{
    $nargs = func_num_args();
    if ($nargs > 0) {
        $arglist = func_get_args();
        $identifier = func_get_arg(0);
        $a = array();
        if ($nargs > 1) {
            for ($i = 1; $i < $nargs; $i++) {
                $index = $i - 1;
                $a["m{$index}"] = func_get_arg($i);
            }
        }
        $return = stack_string($identifier, $a);
        echo $return;
    }
}
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:23,代码来源:locallib.php

示例8: validate

 private function validate()
 {
     if (empty($this->raw) or '' == trim($this->raw)) {
         $this->valid = true;
         return true;
     }
     // CAS keyval may not contain @ or $.
     if (strpos($this->raw, '@') !== false || strpos($this->raw, '$') !== false) {
         $this->errors = stack_string('illegalcaschars');
         $this->valid = false;
         return false;
     }
     // Subtle one: must protect things inside strings before we explode.
     $str = $this->raw;
     $strings = stack_utils::all_substring_strings($str);
     foreach ($strings as $key => $string) {
         $str = str_replace('"' . $string . '"', '[STR:' . $key . ']', $str);
     }
     $str = str_replace("\n", ';', $str);
     $str = stack_utils::remove_comments($str);
     $str = str_replace(';', "\n", $str);
     $kvarray = explode("\n", $str);
     foreach ($strings as $key => $string) {
         foreach ($kvarray as $kkey => $kstr) {
             $kvarray[$kkey] = str_replace('[STR:' . $key . ']', '"' . $string . '"', $kstr);
         }
     }
     // 23/4/12 - significant changes to the way keyvals are interpreted.  Use Maxima assignmentsm i.e. x:2.
     $errors = '';
     $valid = true;
     $vars = array();
     foreach ($kvarray as $kvs) {
         $kvs = trim($kvs);
         if ('' != $kvs) {
             $cs = new stack_cas_casstring($kvs);
             $cs->get_valid($this->security, $this->syntax, $this->insertstars);
             $vars[] = $cs;
         }
     }
     $this->session->add_vars($vars);
     $this->valid = $this->session->get_valid();
     $this->errors = $this->session->get_errors();
 }
开发者ID:profcab,项目名称:moodle-qtype_stack,代码行数:43,代码来源:keyval.class.php

示例9: do_test

 public function do_test()
 {
     if ($this->atoption == null) {
         $this->aterror = 'TEST_FAILED';
         $this->atfeedback = stack_string('TEST_FAILED', array('errors' => ''));
         $this->atansnote = 'ATRegEx_STACKERROR_Option.';
         $this->atmark = 0;
         $this->atvalid = false;
         return null;
     } else {
         $this->atvalid = true;
         if (preg_match($this->atoption, $this->sanskey, $pattern)) {
             $this->atmark = 1;
             $this->atansnote = ' Pattern matched: ' . $pattern[0] . '.';
             return true;
         } else {
             $this->atmark = 0;
             return false;
         }
     }
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:21,代码来源:atregexp.class.php

示例10: test_tex_rendering

 public function test_tex_rendering()
 {
     $this->resetAfterTest();
     set_config('mathsdisplay', 'tex', 'qtype_stack');
     stack_utils::clear_config_cache();
     filter_set_global_state('mathjaxloader', TEXTFILTER_DISABLED);
     // Test language string.
     // The <span class="MathJax_Preview"> bit is something that got added in
     // Moodle 2.8, so match it optionally.
     $this->assertRegExp('~^Your answer needs to be a single fraction of the form ' . '(<span class="MathJax_Preview">)?<a .*alt=" \\{a\\}\\\\over\\{b\\} ".*</(a|script)> \\. ~', stack_string('ATSingleFrac_part'));
     // Test docs - make sure maths inside <code> is not rendered.
     $this->assertRegExp('~^<p><code>\\\\\\(x\\^2\\\\\\)</code> gives (<span class="MathJax_Preview">)?<a .*alt="x\\^2".*</(a|script)> \\.</p>\\n$~', stack_docs_render_markdown('<code>\\(x^2\\)</code> gives \\(x^2\\).', ''));
     // Test docs - make sure maths inside <textarea> is not rendered.
     $this->assertRegExp('~^<p>\\n' . 'Differentiate \\\\\\\\\\[x\\^2 \\+ y\\^2\\\\\\\\\\] with respect to \\\\\\\\\\(x\\\\\\\\\\).</p>\\n$~', stack_docs_render_markdown('<textarea readonly="readonly" rows="3" cols="50">' . "\n" . 'Differentiate \\[x^2 + y^2\\] with respect to \\(x\\).</textarea>', ''));
     // Test CAS text with inline maths.
     $this->assertEquals('What is \\[x^2\\]?', stack_maths::process_display_castext('What is \\(x^2\\)?'));
     // Test CAS text with display maths.
     $this->assertEquals('What is <span class="displayequation">\\[\\displaystyle x^2\\]</span>?', stack_maths::process_display_castext('What is \\[x^2\\]?'));
     // Test with replacedollars.
     set_config('replacedollars', '1', 'qtype_stack');
     stack_utils::clear_config_cache();
     $this->assertEquals('What is \\[x^2\\] or <span class="displayequation">\\[\\displaystyle x^2\\]</span>?', stack_maths::process_display_castext('What is $x^2$ or $$x^2$$?'));
     stack_utils::clear_config_cache();
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:24,代码来源:mathsoutputtex_test.php

示例11: definition

 protected function definition()
 {
     $mform = $this->_form;
     $question = $this->_customdata['question'];
     // Inputs.
     $mform->addElement('header', 'inputsheader', stack_string('testinputs'));
     foreach ($question->inputs as $inputname => $input) {
         // We do not require these to be filled in, (or contain valid input), as the teacher may want to test such cases.
         $input->add_to_moodleform_testinput($mform);
     }
     $mform->addElement('submit', 'complete', stack_string('completetestcase'));
     $mform->registerNoSubmitButton('complete');
     // Expected outcome.
     $mform->addElement('header', 'prtsheader', stack_string('expectedoutcomes'));
     foreach ($question->prts as $prtname => $prt) {
         $elements = array($mform->createElement('text', $prtname . 'score', stack_string('score'), array('size' => 2)), $mform->createElement('text', $prtname . 'penalty', stack_string('penalty'), array('size' => 2)), $mform->createElement('select', $prtname . 'answernote', stack_string('answernote'), $prt->get_all_answer_notes()));
         $mform->addGroup($elements, $prtname . 'group', $prtname, ' ', false);
         $mform->setType($prtname . 'score', PARAM_RAW);
         $mform->setType($prtname . 'penalty', PARAM_RAW);
         $mform->setType($prtname . 'answernote', PARAM_RAW);
     }
     // Submit buttons.
     $this->add_action_buttons(true, $this->_customdata['submitlabel']);
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:24,代码来源:questiontestform.php

示例12: test_test0_no_validation_required

 public function test_test0_no_validation_required()
 {
     // Account for the changes in Moodle 2.6.
     if (question_cbm::adjust_fraction(1, question_cbm::HIGH) > 2) {
         // Moodle 2.6+.
         $outof = 1;
     } else {
         // Moodle 2.5-.
         $outof = 3;
     }
     // Create a stack question - we use test0, then replace the input with
     // a dropdown, to get a question that does not require validation.
     $q = test_question_maker::make_question('stack', 'test0');
     $q->inputs['ans1'] = stack_input_factory::make('dropdown', 'ans1', '2', array('ddl_values' => '1,2'));
     $this->start_attempt_at_question($q, 'deferredcbm', $outof);
     // Check the right behaviour is used.
     $this->assertEquals('deferredcbm', $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
     // Check the initial state.
     $this->check_current_state(question_state::$todo);
     $this->check_current_mark(null);
     $this->render();
     $this->check_output_does_not_contain_input_validation();
     $this->check_output_does_not_contain_prt_feedback();
     $this->check_output_does_not_contain_stray_placeholders();
     $this->check_current_output($this->get_contains_select_expectation('ans1', array('' => stack_string('notanswered'), '1' => '1', '2' => '2'), null, true), $this->get_does_not_contain_feedback_expectation(), $this->get_does_not_contain_num_parts_correct(), $this->get_no_hint_visible_expectation());
     // Save a correct response, medium certainty.
     $this->process_submission(array('ans1' => '2', '-certainty' => 2));
     $this->check_current_state(question_state::$complete);
     $this->check_current_mark(null);
     $this->render();
     $this->check_output_does_not_contain_input_validation();
     $this->check_output_does_not_contain_prt_feedback();
     $this->check_output_does_not_contain_stray_placeholders();
     $this->check_current_output($this->get_contains_select_expectation('ans1', array('' => stack_string('notanswered'), '1' => '1', '2' => '2'), '2', true), $this->get_does_not_contain_feedback_expectation(), $this->get_does_not_contain_num_parts_correct(), $this->get_no_hint_visible_expectation());
     // Submit all and finish.
     $this->quba->finish_all_questions();
     $this->check_current_state(question_state::$gradedright);
     $this->check_current_mark(2);
     $this->render();
     $this->check_output_does_not_contain_input_validation();
     $this->check_output_contains_prt_feedback('firsttree');
     $this->check_output_does_not_contain_stray_placeholders();
     $this->check_current_output($this->get_contains_select_expectation('ans1', array('' => stack_string('notanswered'), '1' => '1', '2' => '2'), '2', false), $this->get_does_not_contain_num_parts_correct(), $this->get_no_hint_visible_expectation());
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:44,代码来源:walkthrough_deferred_cbm_test.php

示例13: check_no_placeholders

 /**
  * Check a form field to ensure it does not contain any placeholders of given types.
  * @param string $fieldname the name of this field. Used in the error messages.
  * @param value $value the value to check.
  * @param array $placeholders types to check for. By default 'input', 'validation' and 'feedback'.
  * @return array of problems (so an empty array means all is well).
  */
 protected function check_no_placeholders($fieldname, $value, $placeholders = array('input', 'validation', 'feedback'))
 {
     $problems = array();
     foreach ($placeholders as $placeholder) {
         if (stack_utils::extract_placeholders($value, 'input')) {
             $problems[] = stack_string('fieldshouldnotcontainplaceholder', array('field' => $fieldname, 'type' => $placeholder));
         }
     }
     return $problems;
 }
开发者ID:sanyaade-teachings,项目名称:moodle-qtype_stack,代码行数:17,代码来源:edit_stack_form.php

示例14: tidy_error

 /**
  * Deals with Maxima errors. Enables some translation.
  *
  * @param string $errstr a Maxima error string
  * @return string
  */
 protected function tidy_error($errstr)
 {
     // This case arises when we use a numerical text for algebraic equivalence.
     if (strpos($errstr, 'STACK: ignore previous error.') !== false) {
         return '';
     }
     if (strpos($errstr, '0 to a negative exponent') !== false) {
         $errstr = stack_string('Maxima_DivisionZero');
     }
     return $errstr;
 }
开发者ID:profcab,项目名称:moodle-qtype_stack,代码行数:17,代码来源:connector.class.php

示例15: require_login

//
// You should have received a copy of the GNU General Public License
// along with Stack.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This script provdies an index for running the question tests in bulk.
 *
 * @copyright  2013 the Open University
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once __DIR__ . '/../../../config.php';
require_once $CFG->libdir . '/questionlib.php';
require_once __DIR__ . '/locallib.php';
require_once __DIR__ . '/stack/utils.class.php';
// Login and check permissions.
$context = context_system::instance();
require_login();
require_capability('qtype/stack:usediagnostictools', $context);
$PAGE->set_url('/question/type/stack/bulktestindex.php');
$PAGE->set_context($context);
$PAGE->set_title(stack_string('bulktestindextitle'));
// Load the necessary data.
$counts = $DB->get_records_sql_menu("\n            SELECT ctx.id, COUNT(q.id) AS numstackquestions\n              FROM {context} ctx\n              JOIN {question_categories} qc ON qc.contextid = ctx.id\n              JOIN {question} q ON q.category = qc.id\n             WHERE q.qtype = 'stack'\n          GROUP BY ctx.id, ctx.path\n          ORDER BY ctx.path\n        ");
// Display.
echo $OUTPUT->header();
echo $OUTPUT->heading(stack_string('replacedollarsindex'));
echo html_writer::start_tag('ul');
foreach ($counts as $contextid => $numstackquestions) {
    echo html_writer::tag('li', html_writer::link(new moodle_url('/question/type/stack/bulktest.php', array('contextid' => $contextid)), context::instance_by_id($contextid)->get_context_name(true, true) . ' (' . $numstackquestions . ')'));
}
echo html_writer::end_tag('ul');
echo $OUTPUT->footer();
开发者ID:profcab,项目名称:moodle-qtype_stack,代码行数:31,代码来源:bulktestindex.php


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