<commit_before><?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');

require_once dirname(__FILE__) . "/../Query/Term.php";

//  Creates a dropdown menu with a list of visible and editable terms
//  and returns an associative array of that terms data fields from
//  the database, otherwise FALSE.
//  PARAMETERS:
//      subIdent:   identifier of submission button
//      kwargs:     associative array of keyword arguments to change functionality,
//                  this is also passed as a parameter to the internal query, see
//                  Source/Query/Term.php::term_retrieve_visible_by_start for more
//                  information
//          view_only_alert:    if the dropdown should indicate terms that are
//                              non-editable, default false
//  OTHER:
//      See test/test_Dropdown_student_term.php for an example of use
function dropdown_select_term($subIdent, $kwargs=null) {
    //  This variable ensures that multiple calls in
    //  the same form or file won't interfere
    static $id = 0;
    $id++;

    //  Default values
    $view_only_alert = false;

    //  Read from kwargs if necessary
    if ($kwargs) {
        if (isset($kwargs['view_only_alert'])) {
            $view_only_alert = $kwargs['view_only_alert'];
        }
    }

    //  First we father the terms and convert them to an array
    if (!($result = term_retrieve_visible_by_start($kwargs))) {
        return false;
    } else if (!($terms = pg_fetch_all($result))) {
        return false;
    }

    //  Output HTML for the dropdown menu using our gathered terms
    //  The caller must provide the form initialization and
    //  submission button/object
    echo "<select name=\"formTerm" . $id . "\">\n";
    echo "<option value=\"\">Please select a term...</option>\n";
    foreach ($terms as $term) {<commit_msg>US202: added option to view non visible terms in dropdown_select_term()<commit_after><?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');

require_once dirname(__FILE__) . "/../Query/Term.php";

//  Creates a dropdown menu with a list of terms
//  and returns an associative array of that terms data fields from
//  the database, otherwise FALSE.
//  PARAMETERS:
//      subIdent:   identifier of submission button
//      kwargs:     associative array of keyword arguments to change functionality,
//                  this is also passed as a parameter to the internal query, see
//                  Source/Query/Term.php::term_retrieve_visible_by_start for more
//                  information
//          view_only_alert:    if the dropdown should indicate terms that are
//                              non-editable, default false
//          all_terms:          if the dropdown should also display non visible terms
//  OTHER:
//      See test/test_Dropdown_student_term.php for an example of use
function dropdown_select_term($subIdent, $kwargs=null) {
    //  This variable ensures that multiple calls in
    //  the same form or file won't interfere
    static $id = 0;
    $id++;

    //  Default values
    $view_only_alert = false;
    $all_terms = false;

    //  Read from kwargs if necessary
    if ($kwargs) {
        if (isset($kwargs['view_only_alert'])) {
            $view_only_alert = $kwargs['view_only_alert'];
        }
        if (isset($kwargs['all_terms'])) {
            $all_terms = $kwargs['all_terms'];
        }
    }

    //  First we father the terms and convert them to an array
    if ($all_terms) {
      if (!($result = term_retrieve_by_start($kwargs))) {
        return false;
      } else if (!($terms = pg_fetch_all($result))) {
        return false;
      }
    } else {
      if (!($result = term_retrieve_visible_by_start($kwargs))) {
          return false;
      } else if (!($terms = pg_fetch_all($result))) {
          return false;
      }
    }

    //  Output HTML for the dropdown menu using our gathered terms
    //  The caller must provide the form initialization and
    //  submission button/object
    echo "<select name=\"formTerm" . $id . "\">\n";
    echo "<option value=\"\">Please select a term...</option>\n";
    foreach ($terms as $term) {
{'fraction_non_alphanumeric': 0.10825732117138742, 'fraction_numerical': 0.001200192030724916, 'mean_word_length': 2.3768233387358184, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5135622', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1133, 'n_words': 392}