app/importers/survey_note_importer/survey_reader.rb
# Timestamps have differnet formats if you download a Google Form as a CSV
# versus if you export that same form to Sheets (and then download that).
Timestamps have differnet formats if you download a Google Form as a CSV
versus if you export that same form to Sheets (and then download that).
Timestamps have differnet formats if you download a Google Form as a CSV versus if you export that same form to Sheets ( and then download that ) .
def maybe_row(raw_row, source_index)
    config = @config
    row = raw_row.to_h
    student_local_id = row[config[:student_local_id]].try(:strip)
    student_id = Student.find_by_local_id(student_local_id).try(:id) unless student_local_id.nil?
    if student_id.nil?
      @invalid_rows_count += 1
      @invalid_student_local_ids = (@invalid_student_local_ids + [student_local_id]).uniq
      return nil
    end
    google_educator_email = row[config[:educator_email]].try(:strip)
    educator_email = @google_email_address_mapping.fetch(google_educator_email, google_educator_email)
    educator_id = Educator.find_by_email(educator_email).try(:id) unless student_local_id.nil?
    if educator_id.nil?
      @invalid_rows_count += 1
      @invalid_educator_emails = (@invalid_educator_emails + [educator_email]).uniq
      return nil
    end
    source_timestamp = DateTime.strptime(row[config[:timestamp]], config[:strptime_format])
    special_keys = [config[:student_local_id], config[:educator_email], config[:timestamp]]
    keep_keys = row.keys - special_keys - config[:ignore_keys]
    source_json = row.slice(*keep_keys)
    {
      source_key: @source_key,
      source_index: source_index,
      student_id: student_id,
      educator_id: educator_id,
      source_timestamp: source_timestamp,
      source_json: source_json
    }
  end
def maybe_row ( raw_row , source_index ) config = @config row = raw_row . to_h student_local_id = row [ config [ :student_local_id ] ] . try ( :strip ) student_id = Student . find_by_local_id ( student_local_id ) . try ( :id ) unless student_local_id . nil? if student_id . nil? @invalid_rows_count += 1 @invalid_student_local_ids = ( @invalid_student_local_ids + [ student_local_id ] ) . uniq return nil end google_educator_email = row [ config [ :educator_email ] ] . try ( :strip ) educator_email = @google_email_address_mapping . fetch ( google_educator_email , google_educator_email ) educator_id = Educator . find_by_email ( educator_email ) . try ( :id ) unless student_local_id . nil? if educator_id . nil? @invalid_rows_count += 1 @invalid_educator_emails = ( @invalid_educator_emails + [ educator_email ] ) . uniq return nil end source_timestamp = DateTime . strptime ( row [ config [ :timestamp ] ] , config [ :strptime_format ] ) special_keys = [ config [ :student_local_id ] , config [ :educator_email ] , config [ :timestamp ] ] keep_keys = row . keys - special_keys - config [ :ignore_keys ] source_json = row . slice ( * keep_keys ) { source_key : @source_key , source_index : source_index , student_id : student_id , educator_id : educator_id , source_timestamp : source_timestamp , source_json : source_json } end
Timestamps have differnet formats if you download a Google Form as a CSV
versus if you export that same form to Sheets (and then download that).
Timestamps have differnet formats if you download a Google Form as a CSV versus if you export that same form to Sheets ( and then download that ) .
# student? # educator? also support mapping from Google email to SIS/LDAP/Insights email # parse timestamp into DateTime # grab other fields, filtering out special ones and `ignore_keys`
raw_row
<not_specific>
source_index
<not_specific>