## DESCRIPTION
## Match each of the following characters in the Theranos story with their corresponding information.
## ENDDESCRIPTION
## KEYWORDS('characters in the Theranos story','information')
## DBsubject('Biotechnology')
## DBchapter('')
## DBsection('')
## Date('2026-05-31')
## Author('Neil R. Voss')
## Institution('Roosevelt University')

DOCUMENT();

loadMacros(
    'PGstandard.pl',
    'PGML.pl',
    'PGchoicemacros.pl',
    'parserPopUp.pl',
    'parserUtils.pl',
    'PGgraders.pl',
    'PGcourse.pl'
);
our @ALPHABET = ('A' .. 'Z');

# ================================
# Full matching data
# ================================
%match_data = (
  'Elizabeth Holmes' => [
    'Founder and chief execuitive officer (CEO) of Theranos',
    'youngest and wealthiest self-made female billionaire in America based on the $9-billion company valuation',
    'dropped out of Stanford in 2004 to start her own blood testing company',
  ],
  'Ramesh "Sunny" Balwani' => [
    'former president and chief operating officer (COO) of Theranos',
    'joined Theranos in 2009 and ran the company\'s day-to- day operations as its president',
    'was in a romantic relationship with Elizabeth Holmes during his tenure at Theranos',
  ],
  'George Shultz' => [
    'former secretary of state and chairman of the Theranos board',
    'chairman of the board and his grandson Tyler was one of the whistleblowers for problems at Theranos',
  ],
  'Tyler Shultz' => [
    'one of the whistleblowers for problems at Theranos whose grandfather was chairman of the board',
    'served as a confidential source for the Wall Street Journal showing the company\'s device was faulty',
  ],
  'Erika Cheung' => [
    'with chemist and biologist degrees from Berkeley, she was the main whistleblower',
  ],
  'David Boies' => [
    'the "pitbull" lawyer who represented Theranos and hired private investigators to harass employees',
  ],
  'Channing Robertson' => [
    'Stanford professor who first encouraged Holmes to start her company',
  ],
  'Phyllis Gardner' => [
    'Stanford professor who was skeptical of Holmes early on',
    'professor who knew from the moment the Holmes had her "brilliant" idea that it wouldn\'t work',
  ],
  'Rupert Murdoch' => [
    'Owner of the Wall Street Journal newspaper who could have killed the information leak',
  ],
  'Dr. Richard Fuisz, MD' => [
    'childhood neighbor of Holmes who was sued by Theranos for a misappropriated patent',
  ],
  'Avie Tevanian' => [
    'investor from Apple who was forced to step down for asking too many questions',
  ],
  'John Carreyrou' => [
    'journalist that was first to expose Theranos scandal',
    'author of Bad Blood book, Theranos tracked his movements to prevent him from getting secrets',
  ],
  'Amanda Seyfried' => [
    'actress who portrays Holmes in the Hulu TV series, The Dropout',
  ],
);

# -------------------------------
# Select N random keys
# -------------------------------
my $n = 5;
@all_keys = PGsort(sub { $_[0] lt $_[1] }, keys %match_data);
my $local_seed = (defined($problemSeed) && $problemSeed ne '') ? $problemSeed : 1;
my $local_random = new PGrandom($local_seed);

my @indices = (0 .. $#all_keys);
my @shuffled = ();
while (@indices) {
  my $pick = $local_random->random(0, $#indices, 1);
  push @shuffled, splice(@indices, $pick, 1);
}
my @selected_keys = @all_keys[@shuffled[0..$n-1]];

# -------------------------------
# Build question/answer pairs
# -------------------------------
# Each entry: [prompt, choice]
@q_and_a = ();
foreach my $key (@selected_keys) {
  my $values_ref = $match_data{$key};
  my $i = $local_random->random(0, $#$values_ref, 1);
  my $value = $values_ref->[$i];
  push @q_and_a, [ $value, $key ];
}

# -------------------------------
# Randomize the questions
# -------------------------------
my @q_indices = (0 .. $#q_and_a);
my @q_shuffled = ();
while (@q_indices) {
  my $pick = $local_random->random(0, $#q_indices, 1);
  push @q_shuffled, $q_and_a[splice(@q_indices, $pick, 1)];
}
@q_and_a = @q_shuffled;

# -------------------------------
# Sort the choices alphabetically
# -------------------------------
@answers = ();
push(@answers, (map { $_->[1] } @q_and_a));
@answers_sorted = PGsort(sub { $_[0] lt $_[1] }, @answers);

# -------------------------------
# HTML-safe answer labels
# -------------------------------
%answer_html = (
  'Elizabeth Holmes' => 'Elizabeth Holmes',
  'Ramesh "Sunny" Balwani' => 'Ramesh "Sunny" Balwani',
  'George Shultz' => 'George Shultz',
  'Tyler Shultz' => 'Tyler Shultz',
  'Erika Cheung' => 'Erika Cheung',
  'David Boies' => 'David Boies',
  'Channing Robertson' => 'Channing Robertson',
  'Phyllis Gardner' => 'Phyllis Gardner',
  'Rupert Murdoch' => 'Rupert Murdoch',
  'Dr. Richard Fuisz, MD' => 'Dr. Richard Fuisz, MD',
  'Avie Tevanian' => 'Avie Tevanian',
  'John Carreyrou' => 'John Carreyrou',
  'Amanda Seyfried' => 'Amanda Seyfried',
);

@answers_sorted_html = map { $answer_html{$_} || $_ } @answers_sorted;

# -------------------------------
# Create answer index lookup
# -------------------------------
our %answer_index;
for (my $i = 0; $i <= $#answers_sorted; $i++) {
  $answer_index{$answers_sorted[$i]} = $i;
}

# -------------------------------
# PopUp/DropDown compatibility
# -------------------------------
sub make_popup {
  return defined &DropDown ? DropDown(@_) : PopUp(@_);
}

# -------------------------------
# Create popup objects (blank default)
# -------------------------------
my @answer_letters = @ALPHABET[0 .. $#answers_sorted];
my @answer_letters_with_blank = ('', @answer_letters);
@answer_dropdowns =
  map { make_popup([ @answer_letters_with_blank ], $answer_index{$q_and_a[$_][1]} + 1 ) }
  0 .. $#q_and_a;

# -------------------------------
# Render the question
# -------------------------------
HEADER_TEXT(<<END_STYLE);
<style>
.two-column {
    display: flex;
	flex-wrap: wrap;
	gap: 2rem;
	align-items: center;
	justify-content: space-evenly;
}
</style>
END_STYLE

$question_text = 'Match each of the following characters in the Theranos story with their corresponding information.';
$note_text = 'Note: Each choice will be used exactly once.';

BEGIN_PGML
[$question_text]*
[$note_text]*

[@ MODES(HTML => '<div class="two-column"><div>') @]*
[@ join(
    "\n\n",
    map {
        '[_]{$answer_dropdowns[' . $_ . ']} '
            . '*' . ($_ + 1) . '.* '
            . '[$q_and_a[' . $_ . '][0]]*'
    } 0 .. $#q_and_a
) @]**
[@ MODES(HTML => '</div><div class="right-col">') @]*
[@ join(
    "\n\n",
    map {
        chr(65 + $_) . '\\.' . ' ' . '[$answers_sorted_html[' . $_ . ']]*'
    } 0 .. $#answers_sorted
) @]**
[@ MODES(HTML => '</div></div>') @]*
END_PGML

# -------------------------------
# Dynamic Partial Credit Based on $n
# -------------------------------
$showPartialCorrectAnswers = 0;
my @thresholds;
my @scores;
for (my $i = 1; $i <= $n; $i++) {
  push @thresholds, $i;
  push @scores, sprintf("%.2f", $i / $n);
}

install_problem_grader(~~&custom_problem_grader_fluid);
$ENV{grader_numright} = [@thresholds];
$ENV{grader_scores}   = [@scores];
$ENV{grader_message} = 'You can earn partial credit.';

# -------------------------------
# Solution
# -------------------------------
$answer_list = join(', ', map { ($_ + 1) . '-' . $ALPHABET[$answer_index{$q_and_a[$_][1]}] } 0 .. $#q_and_a);
BEGIN_PGML_SOLUTION
The correct answers are: [$answer_list].
END_PGML_SOLUTION

ENDDOCUMENT();

