original_string: protected static function get_url_for_image(question_attempt $qa, $filearea, $itemid = 0) {
          $question = $qa->get_question();
          $qubaid = $qa->get_usage_id();
          $slot = $qa->get_slot();
          $fs = get_file_storage();
          if ($filearea == 'bgimage') {
              $itemid = $question->id;
          }
          $componentname = $question->qtype->plugin_name();
          $draftfiles = $fs->get_area_files($question->contextid, $componentname,
                                                                          $filearea, $itemid, 'id');
          if ($draftfiles) {
              foreach ($draftfiles as $file) {
                  if ($file->is_directory()) {
                      continue;
                  }
                  $url = moodle_url::make_pluginfile_url($question->contextid, $componentname,
                                              $filearea, "$qubaid/$slot/{$itemid}", '/',
                                              $file->get_filename());
                  return $url->out();
              }
          }
          return null;
      }
code: protected static function get_url_for_image(question_attempt $qa, $filearea, $itemid = 0) {
          $question = $qa->get_question();
          $qubaid = $qa->get_usage_id();
          $slot = $qa->get_slot();
          $fs = get_file_storage();
          if ($filearea == 'bgimage') {
              $itemid = $question->id;
          }
          $componentname = $question->qtype->plugin_name();
          $draftfiles = $fs->get_area_files($question->contextid, $componentname,
                                                                          $filearea, $itemid, 'id');
          if ($draftfiles) {
              foreach ($draftfiles as $file) {
                  if ($file->is_directory()) {
                      continue;
                  }
                  $url = moodle_url::make_pluginfile_url($question->contextid, $componentname,
                                              $filearea, "$qubaid/$slot/{$itemid}", '/',
                                              $file->get_filename());
                  return $url->out();
              }
          }
          return null;
      }
code_tokens: protected static function get_url_for_image ( question_attempt $ qa , $ filearea , $ itemid = 0 ) { $ question = $ qa -> get_question ( ) ; $ qubaid = $ qa -> get_usage_id ( ) ; $ slot = $ qa -> get_slot ( ) ; $ fs = get_file_storage ( ) ; if ( $ filearea == 'bgimage' ) { $ itemid = $ question -> id ; } $ componentname = $ question -> qtype -> plugin_name ( ) ; $ draftfiles = $ fs -> get_area_files ( $ question -> contextid , $ componentname , $ filearea , $ itemid , 'id' ) ; if ( $ draftfiles ) { foreach ( $ draftfiles as $ file ) { if ( $ file -> is_directory ( ) ) { continue ; } $ url = moodle_url :: make_pluginfile_url ( $ question -> contextid , $ componentname , $ filearea , "$qubaid/$slot/{$itemid}" , '/' , $ file -> get_filename ( ) ) ; return $ url -> out ( ) ; } } return null ; }
docstring: Returns the URL for an image
  
  @param object $qa Question attempt object
  @param string $filearea File area descriptor
  @param int $itemid Item id to get
  @return string Output url, or null if not found
docstring_tokens: Returns the URL for an image