本文整理匯總了PHP中question_attempt::get_database_id方法的典型用法代碼示例。如果您正苦於以下問題:PHP question_attempt::get_database_id方法的具體用法?PHP question_attempt::get_database_id怎麽用?PHP question_attempt::get_database_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類question_attempt
的用法示例。
在下文中一共展示了question_attempt::get_database_id方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: specific_feedback
/**
* Generates the specific feedback from the database when the attempt is finished and the question is answered.
*/
public function specific_feedback(question_attempt $qa)
{
global $DB, $CFG;
// get feedback from the database
$record = $DB->get_record('qtype_javaunittest_feedback', array('questionattemptid' => $qa->get_database_id()), 'feedback');
if ($record === false) {
return '';
}
$feedback = $record->feedback;
$question = $qa->get_question();
return $question->format_text($feedback, 0, $qa, 'question', 'answerfeedback', 1);
}
示例2: formulation_and_controls
public function formulation_and_controls(question_attempt $qa, question_display_options $options)
{
$question = $qa->get_question();
$response = $qa->get_last_qt_data();
$questiontext = $question->questiontextinstantiated;
// Replace inputs.
$inputstovaldiate = array();
$qaid = null;
foreach ($question->inputs as $name => $input) {
$fieldname = $qa->get_qt_field_name($name);
$state = $question->get_input_state($name, $response);
$questiontext = str_replace("[[input:{$name}]]", $input->render($state, $fieldname, $options->readonly), $questiontext);
$feedback = $this->input_validation($fieldname . '_val', $input->render_validation($state, $fieldname));
$questiontext = str_replace("[[validation:{$name}]]", $feedback, $questiontext);
$qaid = $qa->get_database_id();
if ($input->requires_validation()) {
$inputstovaldiate[] = $name;
}
}
// Replace PRTs.
foreach ($question->prts as $index => $prt) {
$feedback = '';
if ($options->feedback) {
$feedback = $this->prt_feedback($index, $response, $qa, $options, true);
} else {
if (in_array($qa->get_behaviour_name(), array('interactivecountback', 'adaptivemulipart'))) {
// The behaviour name test here is a hack. The trouble is that interactive
// behaviour or adaptivemulipart does not show feedback if the input
// is invalid, but we want to show the CAS errors from the PRT.
$result = $question->get_prt_result($index, $response, $qa->get_state()->is_finished());
$feedback = html_writer::nonempty_tag('div', $result->errors, array('class' => 'stackprtfeedback stackprtfeedback-' . $name));
}
}
$questiontext = str_replace("[[feedback:{$index}]]", $feedback, $questiontext);
}
// Now format the questiontext. This should be done after the subsitutions of inputs and PRTs.
$questiontext = $question->format_text(stack_maths::process_display_castext($questiontext, $this), $question->questiontextformat, $qa, 'question', 'questiontext', $question->id);
// Initialise automatic validation, if enabled.
if ($qaid && stack_utils::get_config()->ajaxvalidation) {
$this->page->requires->yui_module('moodle-qtype_stack-input', 'M.qtype_stack.init_inputs', array($inputstovaldiate, $qaid, $qa->get_field_prefix()));
}
$result = '';
$result .= $this->question_tests_link($question, $options) . $questiontext;
if ($qa->get_state() == question_state::$invalid) {
$result .= html_writer::nonempty_tag('div', $question->get_validation_error($response), array('class' => 'validationerror'));
}
return $result;
}
示例3: notify_step_modified
public function notify_step_modified(question_attempt_step $step, question_attempt $qa, $seq)
{
if (array_key_exists($qa->get_slot(), $this->attemptsadded)) {
return;
}
if (($key = $this->is_step_added($step)) !== false) {
return;
}
if (($key = $this->is_step_deleted($step)) !== false) {
throw new coding_exception('Cannot modify a step after it has been deleted.');
}
$stepid = $step->get_id();
if (empty($stepid)) {
throw new coding_exception('Cannot modify a step that has never been stored in the database.');
}
$this->stepsmodified[] = array($step, $qa->get_database_id(), $seq);
}
示例4: get_postdata
/**
* Get the postdata that needs to be sent to question/toggleflag.php to change the flag state.
* You need to append &newstate=0/1 to this.
* @return the post data to send.
*/
public static function get_postdata(question_attempt $qa)
{
$qaid = $qa->get_database_id();
$qubaid = $qa->get_usage_id();
$qid = $qa->get_question()->id;
$slot = $qa->get_slot();
$checksum = self::get_toggle_checksum($qubaid, $qid, $qaid, $slot);
return "qaid={$qaid}&qubaid={$qubaid}&qid={$qid}&slot={$slot}&checksum={$checksum}&sesskey=" . sesskey() . '&newstate=';
}
示例5: to_unique_identifier
private static function to_unique_identifier(question_attempt $qa, $identifier)
{
return $identifier . "-" . $qa->get_database_id();
}
示例6: notify_step_added
public function notify_step_added(question_attempt_step $step, question_attempt $qa, $seq)
{
if (array_key_exists($qa->get_slot(), $this->attemptsadded)) {
return;
}
$this->stepsadded[] = array($step, $qa->get_database_id(), $seq);
}