Output the HTML needed to show the statistics graph.

@param int|object $quizorid The quiz, or its ID.
@param qubaid_condition $qubaids the question usages whose responses to analyse.
@param string $whichattempts Which attempts constant.
762585
protected function output_statistics_graph($quizorid, $qubaids) {
        global $DB, $PAGE;

        $quiz = $quizorid;
        if (!is_object($quiz)) {
            $quiz = $DB->get_record('quiz', array('id' => $quizorid), '*', MUST_EXIST);
        }

        // Load the rest of the required data.
        $questions = quiz_report_get_significant_questions($quiz);

        // Only load main question not sub questions.
        $questionstatistics = $DB->get_records_select('question_statistics',
                'hashcode = ? AND slot IS NOT NULL AND variant IS NULL',
            [$qubaids->get_hash_code()]);

        // Configure what to display.
        $fieldstoplot = [
            'facility' => get_string('facility', 'quiz_statistics'),
            'discriminativeefficiency' => get_string('discriminative_efficiency', 'quiz_statistics')
        ];
        $fieldstoplotfactor = ['facility' => 100, 'discriminativeefficiency' => 1];

        // Prepare the arrays to hold the data.
        $xdata = [];
        foreach (array_keys($fieldstoplot) as $fieldtoplot) {
            $ydata[$fieldtoplot] = [];
        }

        // Fill in the data for each question.
        foreach ($questionstatistics as $questionstatistic) {
            $number = $questions[$questionstatistic->slot]->number;
            $xdata[$number] = $number;

            foreach ($fieldstoplot as $fieldtoplot => $notused) {
                $value = $questionstatistic->$fieldtoplot;
                if (is_null($value)) {
                    $value = 0;
                }
                $value *= $fieldstoplotfactor[$fieldtoplot];
                $ydata[$fieldtoplot][$number] = number_format($value, 2);
            }
        }

        // Create the chart.
        sort($xdata);
        $chart = new \core\chart_bar();
        $chart->get_xaxis(0, true)->set_label(get_string('position', 'quiz_statistics'));
        $chart->set_labels(array_values($xdata));

        foreach ($fieldstoplot as $fieldtoplot => $notused) {
            ksort($ydata[$fieldtoplot]);
            $series = new \core\chart_series($fieldstoplot[$fieldtoplot], array_values($ydata[$fieldtoplot]));
            $chart->add_series($series);
        }

        // Find max.
        $max = 0;
        foreach ($fieldstoplot as $fieldtoplot => $notused) {
            $max = max($max, max($ydata[$fieldtoplot]));
        }

        // Set Y properties.
        $yaxis = $chart->get_yaxis(0, true);
        $yaxis->set_stepsize(10);
        $yaxis->set_label('%');

        $output = $PAGE->get_renderer('mod_quiz');
        $graphname = get_string('statisticsreportgraph', 'quiz_statistics');
        echo $output->chart($chart, $graphname);
    }
965243
protected function write_multichoice(array $multichoices, $oldquestiontextformat, $questionid) {
        global $CFG;

        // The grouped array is supposed to have just one element - let us use foreach anyway
        // just to be sure we do not loose anything.
        foreach ($multichoices as $multichoice) {
            // Append an artificial 'id' attribute (is not included in moodle.xml).
            $multichoice['id'] = $this->converter->get_nextid();

            // Replay the upgrade step 2009021801.
            $multichoice['correctfeedbackformat']               = 0;
            $multichoice['partiallycorrectfeedbackformat']      = 0;
            $multichoice['incorrectfeedbackformat']             = 0;

            if ($CFG->texteditors !== 'textarea' and $oldquestiontextformat == FORMAT_MOODLE) {
                $multichoice['correctfeedback']                 = text_to_html($multichoice['correctfeedback'], false, false, true);
                $multichoice['correctfeedbackformat']           = FORMAT_HTML;
                $multichoice['partiallycorrectfeedback']        = text_to_html($multichoice['partiallycorrectfeedback'], false, false, true);
                $multichoice['partiallycorrectfeedbackformat']  = FORMAT_HTML;
                $multichoice['incorrectfeedback']               = text_to_html($multichoice['incorrectfeedback'], false, false, true);
                $multichoice['incorrectfeedbackformat']         = FORMAT_HTML;
            } else {
                $multichoice['correctfeedbackformat']           = $oldquestiontextformat;
                $multichoice['partiallycorrectfeedbackformat']  = $oldquestiontextformat;
                $multichoice['incorrectfeedbackformat']         = $oldquestiontextformat;
            }

            $multichoice['correctfeedback'] = $this->migrate_files(
                    $multichoice['correctfeedback'], 'question', 'correctfeedback', $questionid);
            $multichoice['partiallycorrectfeedback'] = $this->migrate_files(
                    $multichoice['partiallycorrectfeedback'], 'question', 'partiallycorrectfeedback', $questionid);
            $multichoice['incorrectfeedback'] = $this->migrate_files(
                    $multichoice['incorrectfeedback'], 'question', 'incorrectfeedback', $questionid);

            $this->write_xml('multichoice', $multichoice, array('/multichoice/id'));
        }
    }
1055116
def show
      @question_sheet = @answer_sheet.question_sheet
      pf = Qe.table_name_prefix
      @elements = @question_sheet.pages.collect {|p| p.elements.includes(:pages).order("#{pf}pages.number,#{pf}page_elements.position").all}.flatten
      @elements = QuestionSet.new(@elements, @answer_sheet).elements.group_by{ |e| e.pages.first }
    end
345039
public void printHtmlJavaLogo(PrintWriter out, String strTag, String strParams, String strData)
    {
        String strType = m_recDetail.getField(MenusModel.TYPE).toString();
        String strJava = this.getRecordOwner().getProperty(DBParams.JAVA);
        if ((strJava == null) || (strJava.length() == 0))
            strJava = DBConstants.NO;
        if (strJava.toUpperCase().charAt(0) != 'N')
            if ((strType.equalsIgnoreCase(DBParams.RECORD))
                || (strType.equalsIgnoreCase(DBParams.SCREEN))
                    || (strType.equalsIgnoreCase("form")))
            out.print(strData);
    }
710758
public function addChat($roistat, $jivoSiteId, $jivoSiteChat)
	{
		$queryRoistat = array(
			'query' => $roistat,
			);
		$out = $this->listData($queryRoistat);
		if ($out !== NULL) {
			if (count($out->response->leads == 1)) {
				foreach ($out->response->leads as $lead) {
					foreach ($lead->custom_fields as $field) {
						if ($field->name = 'roistat') {
							foreach ($field->values as $value) {
								if( $roistat == $value->value){
									$notesQuery = array(
										'type' => self::TYPE_LEADS,
										'element_id' => $lead->id
										);
									$notes = $this->listData($notesQuery, self::TYPE_NOTES);
									foreach ($notes->response->notes as $note) {
										if(preg_match("!admin.jivosite!si", $note->text)){
											$id = explode(';', $note->text);
											if($id[2] == $jivoSiteId){
												$addNotes['request']['notes']['add'] = array(
													array(
														'element_id'=> $note->element_id,
														'element_type'=>2,
														'note_type'=>4,
														'text'=> $jivoSiteChat,
														'responsible_user_id'=>220402,
														)
													);
												$res = 	$this->addData($addNotes, self::TYPE_NOTES);
												echo 'success';
												var_dump($note);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
560559
public function render_adaptive_marks(qbehaviour_adaptive_mark_details $details, question_display_options $options) {
        if ($details->state == question_state::$todo || $options->marks < question_display_options::MARK_AND_MAX) {
            // No grades yet.
            return '';
        }

        // Display the grading details from the last graded state.
        $class = $details->state->get_feedback_class();
        return html_writer::tag('div', get_string($class, 'question'),
                        array('class' => 'correctness ' . $class))
                . html_writer::tag('div', $this->grading_details($details, $options),
                        array('class' => 'gradingdetails'));
    }
72164
def QueryHowDoI(Query, num_answers, full_text, window:sg.Window):
    '''
    
    '''
    howdoi_command = HOW_DO_I_COMMAND
    full_text_option = ' -a' if full_text else ''
    t = subprocess.Popen(howdoi_command + ' \"'+ Query + '\" -n ' + str(num_answers)+full_text_option, stdout=subprocess.PIPE)
    (output, err) = t.communicate()
    window.Element('_OUTPUT_').Update('{:^88}'.format(Query.rstrip()), append=True)
    window.Element('_OUTPUT_').Update('_'*60, append=True)
    window.Element('_OUTPUT_').Update(output.decode("utf-8"), append=True)
    exit_code = t.wait()
645599
protected function col_name($questionstat) {
        $name = $questionstat->question->name;

        if (!is_null($questionstat->variant)) {
            $a = new stdClass();
            $a->name = $name;
            $a->variant = $questionstat->variant;
            $name = get_string('nameforvariant', 'quiz_statistics', $a);
        }

        if ($this->is_downloading()) {
            return $name;
        }

        $baseurl = new moodle_url($this->baseurl);
        if (!is_null($questionstat->variant)) {
            if ($questionstat->subquestion) {
                // Variant of a sub-question.
                $url = new moodle_url($baseurl, array('qid' => $questionstat->questionid, 'variant' => $questionstat->variant));
                $name = html_writer::link($url, $name, array('title' => get_string('detailedanalysisforvariant',
                                                                                   'quiz_statistics',
                                                                                   $questionstat->variant)));
            } else if ($questionstat->slot) {
                // Variant of a question in a slot.
                $url = new moodle_url($baseurl, array('slot' => $questionstat->slot, 'variant' => $questionstat->variant));
                $name = html_writer::link($url, $name, array('title' => get_string('detailedanalysisforvariant',
                                                                                   'quiz_statistics',
                                                                                   $questionstat->variant)));
            }
        } else {
            if ($questionstat->subquestion && !$questionstat->get_variants()) {
                // Sub question without variants.
                $url = new moodle_url($baseurl, array('qid' => $questionstat->questionid));
                $name = html_writer::link($url, $name, array('title' => get_string('detailedanalysis', 'quiz_statistics')));
            } else if ($baseurl->param('slot') === null && $questionstat->slot) {
                // Question in a slot, we are not on a page showing structural analysis of one slot,
                // we don't want linking on those pages.
                $number = $questionstat->question->number;
                $israndomquestion = $questionstat->question->qtype == 'random';
                $url = new moodle_url($baseurl, array('slot' => $questionstat->slot));

                if ($this->is_calculated_question_summary($questionstat)) {
                    // Only make the random question summary row name link to the slot structure
                    // analysis page with specific text to clearly indicate the link to the user.
                    // Random and variant question rows will render the name without a link to improve clarity
                    // in the UI.
                    $name = html_writer::div(get_string('rangeofvalues', 'quiz_statistics'));
                } else if (!$israndomquestion && !$questionstat->get_variants() && !$questionstat->get_sub_question_ids()) {
                    // Question cannot be broken down into sub-questions or variants. Link will show response analysis page.
                    $name = html_writer::link($url,
                                              $name,
                                              array('title' => get_string('detailedanalysis', 'quiz_statistics')));
                }
            }
        }


        if ($this->is_dubious_question($questionstat)) {
            $name = html_writer::tag('div', $name, array('class' => 'dubious'));
        }

        if ($this->is_calculated_question_summary($questionstat)) {
            $name .= html_writer::link($url, get_string('viewanalysis', 'quiz_statistics'));
        } else if (!empty($questionstat->minmedianmaxnotice)) {
            $name = get_string($questionstat->minmedianmaxnotice, 'quiz_statistics') . '<br />' . $name;
        }

        return $name;
    }
1331423
def QueryHowDoI(Query, num_answers, full_text):
    '''
    
    '''
    howdoi_command = HOW_DO_I_COMMAND
    full_text_option = ' -a' if full_text else ''
    t = subprocess.Popen(howdoi_command + ' \"'+ Query + '\" -n ' + str(num_answers)+full_text_option, stdout=subprocess.PIPE)
    (output, err) = t.communicate()
    print('{:^88}'.format(Query.rstrip()))
    print('_'*60)
    print(output.decode("utf-8") )
    exit_code = t.wait()
913735
public function interactConfigureBehat(
    InputInterface $input,
    OutputInterface $output,
    AnnotationData $annotationData
  ) {
    /** @var \Acquia\Blt\Robo\Wizards\TestsWizard $tests_wizard */
    $tests_wizard = $this->getContainer()->get(TestsWizard::class);
    $tests_wizard->wizardConfigureBehat();
  }
542080
public function numericStatement($translatorevent, $questionAttempt, $question) {

        $translatorevent['interaction_type'] = 'numeric';


        $correctAnswerId = null;
        foreach ($question->answers as $answer) {
            if (intval($answer->fraction) === 1) {
                $correctAnswerId = $answer->id;
            }
        }

        $tolerance = 0;
        $toleranceType = 2;
        $answersdata = [];
        if ($question->qtype == "numerical") {
            $answersdata = $question->numerical->answers;
        } else if (strpos($question->qtype, 'calculated') === 0) {
            $answersdata = $question->calculated->answers;
        }

        if (!is_null($correctAnswerId) && count($answersdata) > 0) {
            foreach ($answersdata as $answerdata) {
                if(isset($answerdata->answer)){
                    if ($answerdata->answer == $correctAnswerId) {
                        $tolerance = floatval($answerdata->tolerance);
                        if (isset($answerdata->tolerancetype)) {
                            $toleranceType = intval($answerdata->tolerancetype);
                        }
                    }
                }
            }
        }

        $rigthtanswer = floatval($questionAttempt->rightanswer);
        if ($tolerance > 0) {
            $toleranceMax = $rigthtanswer + $tolerance;
            $toleranceMin = $rigthtanswer - $tolerance;
            switch ($toleranceType) {
                case 1:
                    $toleranceMax = $rigthtanswer + ($rigthtanswer * $tolerance);
                    $toleranceMin = $rigthtanswer - ($rigthtanswer * $tolerance);
                    break;
                case 3:
                    $toleranceMax = $rigthtanswer + ($rigthtanswer * $tolerance);
                    $toleranceMin = $rigthtanswer / (1 + $tolerance);
                    break;
                default:
                    break;
            }
            $rigthtanswerstring = strval($toleranceMin) . '[:]' . strval($toleranceMax);
            $translatorevent['interaction_correct_responses'] = [$rigthtanswerstring];
        } else {
            $translatorevent['interaction_correct_responses'] = [$questionAttempt->rightanswer];
        }

        return $translatorevent;
    }
744648
protected function initialise_combined_feedback(question_definition $question,
            $questiondata, $withparts = false) {
        $question->correctfeedback = $questiondata->options->correctfeedback;
        $question->correctfeedbackformat = $questiondata->options->correctfeedbackformat;
        $question->partiallycorrectfeedback = $questiondata->options->partiallycorrectfeedback;
        $question->partiallycorrectfeedbackformat =
                $questiondata->options->partiallycorrectfeedbackformat;
        $question->incorrectfeedback = $questiondata->options->incorrectfeedback;
        $question->incorrectfeedbackformat = $questiondata->options->incorrectfeedbackformat;
        if ($withparts) {
            $question->shownumcorrect = $questiondata->options->shownumcorrect;
        }
    }
473040
public function ChangePageAjax($iListIdent = null)
    {
        $oResponse = new MTShopArticleListResponse();
        /** @var $oResponse MTShopArticleListResponse */
        if (null === $iListIdent) {
            $oGlobal = TGlobal::instance();
            $iListIdent = $oGlobal->GetUserData(TdbShopArticleList::URL_LIST_KEY_NAME);
        }

        $oListItem = $this->oList;
        if (null !== $oListItem) {
            $bViewNameExists = false;
            $bViewTypeExists = false;
            $bCallTimeVarsExists = false;

            $aItemRawData = TdbShopArticleList::GetInstanceDataFromSession($iListIdent);
            if (is_array($aItemRawData)) {
                $bViewNameExists = (array_key_exists('sViewName', $aItemRawData));
                $bViewTypeExists = (array_key_exists('sViewType', $aItemRawData));
                $bCallTimeVarsExists = (array_key_exists('aCallTimeVars', $aItemRawData));
            }
            if ($bViewNameExists && $bViewTypeExists && $bCallTimeVarsExists) {
                // fetch data for requested item
                $oResponse->iNumberOfResults = $oListItem->GetNumberOfRecordsForCurrentPage();
                $oResponse->bHasNextPage = $oListItem->HasNextPage();
                $oResponse->bHasPreviousPage = $oListItem->HasPreviousPage();
                $oResponse->sItemPage = $oListItem->Render($aItemRawData['sViewName'], $aItemRawData['sViewType'], $aItemRawData['aCallTimeVars']);
                $oResponse->iListKey = $iListIdent;
            }
        }

        $_SESSION['iLastPageNumber'] = $oListItem->GetCurrentPageNumber() - 1;

        return $oResponse;
    }
757982
def _show(self, status=None, idx=None):
        
        _show('', 50)
        if not self.todos:
            self._show_no_todos()
        elif idx is not None:
            for todo in self.todos:
                if todo['idx'] == idx:
                    self._show_todos(todo)
        elif status is not None:
            if status not in STATUS_CODE:
                raise InvalidTodoStatus
            _todos = []
            for todo in self.todos:
                if todo['status'] == status:
                    _todos.append(todo)
            if not _todos:
                self._show_no_todos(text_fix='No {} todos...'.format(
                                    STATUS_CODE.get(status, None)))
            else:
                for todo in _todos:
                    self._show_todos(todo)
        else:
            for todo in self.todos:
                self._show_todos(todo)
        _show('', 50)
118655
protected final function add_answer($count, $label = null, $required = false, $format= '') {
        if ($label === null) {
            $label = get_string('answer', 'lesson');
        }

        if ($format == LESSON_ANSWER_HTML) {
            $this->_form->addElement('editor', 'answer_editor['.$count.']', $label,
                    array('rows' => '4', 'columns' => '80'),
                    array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $this->_customdata['maxbytes']));
            $this->_form->setType('answer_editor['.$count.']', PARAM_RAW);
            $this->_form->setDefault('answer_editor['.$count.']', array('text' => '', 'format' => FORMAT_HTML));
        } else {
            $this->_form->addElement('text', 'answer_editor['.$count.']', $label,
                    array('size' => '50', 'maxlength' => '200'));
            $this->_form->setType('answer_editor['.$count.']', PARAM_TEXT);
        }

        if ($required) {
            $this->_form->addRule('answer_editor['.$count.']', get_string('required'), 'required', null, 'client');
        }
    }
21375
public function display($quiz, $cm, $course) {
        global $OUTPUT, $DB;

        raise_memory_limit(MEMORY_HUGE);

        $this->context = context_module::instance($cm->id);

        if (!quiz_has_questions($quiz->id)) {
            $this->print_header_and_tabs($cm, $course, $quiz, 'statistics');
            echo quiz_no_questions_message($quiz, $cm, $this->context);
            return true;
        }

        // Work out the display options.
        $download = optional_param('download', '', PARAM_ALPHA);
        $everything = optional_param('everything', 0, PARAM_BOOL);
        $recalculate = optional_param('recalculate', 0, PARAM_BOOL);
        // A qid paramter indicates we should display the detailed analysis of a sub question.
        $qid = optional_param('qid', 0, PARAM_INT);
        $slot = optional_param('slot', 0, PARAM_INT);
        $variantno = optional_param('variant', null, PARAM_INT);
        $whichattempts = optional_param('whichattempts', $quiz->grademethod, PARAM_INT);
        $whichtries = optional_param('whichtries', question_attempt::LAST_TRY, PARAM_ALPHA);

        $pageoptions = array();
        $pageoptions['id'] = $cm->id;
        $pageoptions['mode'] = 'statistics';

        $reporturl = new moodle_url('/mod/quiz/report.php', $pageoptions);

        $mform = new quiz_statistics_settings_form($reporturl, compact('quiz'));

        $mform->set_data(array('whichattempts' => $whichattempts, 'whichtries' => $whichtries));

        if ($whichattempts != $quiz->grademethod) {
            $reporturl->param('whichattempts', $whichattempts);
        }

        if ($whichtries != question_attempt::LAST_TRY) {
            $reporturl->param('whichtries', $whichtries);
        }

        // Find out current groups mode.
        $currentgroup = $this->get_current_group($cm, $course, $this->context);
        $nostudentsingroup = false; // True if a group is selected and there is no one in it.
        if (empty($currentgroup)) {
            $currentgroup = 0;
            $groupstudentsjoins = new \core\dml\sql_join();

        } else if ($currentgroup == self::NO_GROUPS_ALLOWED) {
            $groupstudentsjoins = new \core\dml\sql_join();
            $nostudentsingroup = true;

        } else {
            // All users who can attempt quizzes and who are in the currently selected group.
            $groupstudentsjoins = get_enrolled_with_capabilities_join($this->context, '',
                    array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $currentgroup);
            if (!empty($groupstudentsjoins->joins)) {
                $sql = "SELECT DISTINCT u.id
                    FROM {user} u
                    {$groupstudentsjoins->joins}
                    WHERE {$groupstudentsjoins->wheres}";
                if (!$DB->record_exists_sql($sql, $groupstudentsjoins->params)) {
                    $nostudentsingroup = true;
                }
            }
        }

        $qubaids = quiz_statistics_qubaids_condition($quiz->id, $groupstudentsjoins, $whichattempts);

        // If recalculate was requested, handle that.
        if ($recalculate && confirm_sesskey()) {
            $this->clear_cached_data($qubaids);
            redirect($reporturl);
        }

        // Set up the main table.
        $this->table = new quiz_statistics_table();
        if ($everything) {
            $report = get_string('completestatsfilename', 'quiz_statistics');
        } else {
            $report = get_string('questionstatsfilename', 'quiz_statistics');
        }
        $courseshortname = format_string($course->shortname, true,
                array('context' => context_course::instance($course->id)));
        $filename = quiz_report_download_filename($report, $courseshortname, $quiz->name);
        $this->table->is_downloading($download, $filename,
                get_string('quizstructureanalysis', 'quiz_statistics'));
        $questions = $this->load_and_initialise_questions_for_calculations($quiz);

        // Print the page header stuff (if not downloading.
        if (!$this->table->is_downloading()) {
            $this->print_header_and_tabs($cm, $course, $quiz, 'statistics');
        }

        if (!$nostudentsingroup) {
            // Get the data to be displayed.
            $progress = $this->get_progress_trace_instance();
            list($quizstats, $questionstats) =
                $this->get_all_stats_and_analysis($quiz, $whichattempts, $whichtries, $groupstudentsjoins, $questions, $progress);
        } else {
            // Or create empty stats containers.
            $quizstats = new \quiz_statistics\calculated($whichattempts);
            $questionstats = new \core_question\statistics\questions\all_calculated_for_qubaid_condition();
        }

        // Set up the table.
        $this->table->statistics_setup($quiz, $cm->id, $reporturl, $quizstats->s());

        // Print the rest of the page header stuff (if not downloading.
        if (!$this->table->is_downloading()) {

            if (groups_get_activity_groupmode($cm)) {
                groups_print_activity_menu($cm, $reporturl->out());
                if ($currentgroup && $nostudentsingroup) {
                    $OUTPUT->notification(get_string('nostudentsingroup', 'quiz_statistics'));
                }
            }

            if (!$this->table->is_downloading() && $quizstats->s() == 0) {
                echo $OUTPUT->notification(get_string('nogradedattempts', 'quiz_statistics'));
            }

            foreach ($questionstats->any_error_messages() as $errormessage) {
                echo $OUTPUT->notification($errormessage);
            }

            // Print display options form.
            $mform->display();
        }

        if ($everything) { // Implies is downloading.
            // Overall report, then the analysis of each question.
            $quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);
            $this->download_quiz_info_table($quizinfo);

            if ($quizstats->s()) {
                $this->output_quiz_structure_analysis_table($questionstats);

                if ($this->table->is_downloading() == 'html' && $quizstats->s() != 0) {
                    $this->output_statistics_graph($quiz->id, $qubaids);
                }

                $this->output_all_question_response_analysis($qubaids, $questions, $questionstats, $reporturl, $whichtries);
            }

            $this->table->export_class_instance()->finish_document();

        } else if ($qid) {
            // Report on an individual sub-question indexed questionid.
            if (!$questionstats->has_subq($qid, $variantno)) {
                print_error('questiondoesnotexist', 'question');
            }

            $this->output_individual_question_data($quiz, $questionstats->for_subq($qid, $variantno));
            $this->output_individual_question_response_analysis($questionstats->for_subq($qid, $variantno)->question,
                                                                $variantno,
                                                                $questionstats->for_subq($qid, $variantno)->s,
                                                                $reporturl,
                                                                $qubaids,
                                                                $whichtries);
            // Back to overview link.
            echo $OUTPUT->box('<a href="' . $reporturl->out() . '">' .
                              get_string('backtoquizreport', 'quiz_statistics') . '</a>',
                              'boxaligncenter generalbox boxwidthnormal mdl-align');
        } else if ($slot) {
            // Report on an individual question indexed by position.
            if (!isset($questions[$slot])) {
                print_error('questiondoesnotexist', 'question');
            }

            if ($variantno === null &&
                                ($questionstats->for_slot($slot)->get_sub_question_ids()
                                || $questionstats->for_slot($slot)->get_variants())) {
                if (!$this->table->is_downloading()) {
                    $number = $questionstats->for_slot($slot)->question->number;
                    echo $OUTPUT->heading(get_string('slotstructureanalysis', 'quiz_statistics', $number), 3);
                }
                $this->table->define_baseurl(new moodle_url($reporturl, array('slot' => $slot)));
                $this->table->format_and_add_array_of_rows($questionstats->structure_analysis_for_one_slot($slot));
            } else {
                $this->output_individual_question_data($quiz, $questionstats->for_slot($slot, $variantno));
                $this->output_individual_question_response_analysis($questions[$slot],
                                                                    $variantno,
                                                                    $questionstats->for_slot($slot, $variantno)->s,
                                                                    $reporturl,
                                                                    $qubaids,
                                                                    $whichtries);
            }
            if (!$this->table->is_downloading()) {
                // Back to overview link.
                echo $OUTPUT->box('<a href="' . $reporturl->out() . '">' .
                        get_string('backtoquizreport', 'quiz_statistics') . '</a>',
                        'backtomainstats boxaligncenter generalbox boxwidthnormal mdl-align');
            } else {
                $this->table->finish_output();
            }

        } else if ($this->table->is_downloading()) {
            // Downloading overview report.
            $quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);
            $this->download_quiz_info_table($quizinfo);
            if ($quizstats->s()) {
                $this->output_quiz_structure_analysis_table($questionstats);
            }
            $this->table->export_class_instance()->finish_document();

        } else {
            // On-screen display of overview report.
            echo $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'), 3);
            echo $this->output_caching_info($quizstats->timemodified, $quiz->id, $groupstudentsjoins, $whichattempts, $reporturl);
            echo $this->everything_download_options($reporturl);
            $quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);
            echo $this->output_quiz_info_table($quizinfo);
            if ($quizstats->s()) {
                echo $OUTPUT->heading(get_string('quizstructureanalysis', 'quiz_statistics'), 3);
                $this->output_quiz_structure_analysis_table($questionstats);
                $this->output_statistics_graph($quiz, $qubaids);
            }
        }

        return true;
    }
1240160
public function getConditionToUpdateInputAjaxAction($couponId, $conditionIndex)
    {
        if (null !== $response = $this->checkAuth(AdminResources::COUPON, [], AccessManager::VIEW)) {
            return $response;
        }

        $this->checkXmlHttpRequest();

        $search = CouponQuery::create();
        /** @var Coupon $coupon */
        $coupon = $search->findOneById($couponId);
        if (!$coupon) {
            return $this->pageNotFound();
        }

        /** @var CouponFactory $couponFactory */
        $couponFactory = $this->container->get('thelia.coupon.factory');
        $couponManager = $couponFactory->buildCouponFromModel($coupon);

        if (!$couponManager instanceof CouponInterface) {
            return $this->pageNotFound();
        }

        $conditions = $couponManager->getConditions();
        if (!isset($conditions[$conditionIndex])) {
            return $this->pageNotFound();
        }
        /** @var ConditionInterface $condition */
        $condition = $conditions[$conditionIndex];

        /** @var ConditionFactory $conditionFactory */
        $conditionFactory = $this->container->get('thelia.condition.factory');
        $inputs = $conditionFactory->getInputsFromConditionInterface($condition);

        if ($inputs === null) {
            return $this->pageNotFound();
        }

        return $this->render(
            'coupon/condition-input-ajax',
            [
                'inputsDrawn' => $condition->drawBackOfficeInputs(),
                'conditionServiceId' => $condition->getServiceId(),
                'conditionIndex' => $conditionIndex,
            ]
        );
    }