<commit_before>import React, { Component, PropTypes } from 'react';
import SuperDownloadButton from '../../common/components/SuperDownloadButton';
import { DownloadHelper } from '../../../helpers/download.js';
const mapconfig = require('../../../constants/mapExplorer.config.json');

class ClassroomAssignments extends Component {
  constructor(props) {
    super(props);

    this.classificationButtons = {};
    this.aggregationButtons = {};
  }

  downloadMyClassifications(username, assignment_id) {
    return () => {
      const sql =
        'SELECT cla.*, sub.location FROM {CLASSIFICATIONS} as cla LEFT JOIN {SUBJECTS} as sub ON cla.subject_id = sub.subject_id WHERE user_name =\'{WHERE_USER}\' AND workflow_id = {WHERE_WORKFLOW}'
        .replace(/{SUBJECTS}/ig, mapconfig.cartodb.sqlTableSubjects)
        .replace(/{CLASSIFICATIONS}/ig, mapconfig.cartodb.sqlTableClassifications)
        .replace(/{WHERE_USER}/ig, DownloadHelper.sqlStrSafe(username))
        .replace(/{WHERE_WORKFLOW}/ig, parseInt(assignment_id));
      this.classificationButtons[assignment_id].downloadCSV(sql, true);
    }
  }

  downloadAssignmentSubjects(subjects, assignment_id) {
    return () => {
      const where = 'WHERE items.subject_id IN ('+(subjects.join(','))+')';
      const sql =
        mapconfig.cartodb.sqlQueryDownload
        .replace(/{CAMERAS}/ig, mapconfig.cartodb.sqlTableCameras)
        .replace(/{SUBJECTS}/ig, mapconfig.cartodb.sqlTableSubjects)
        .replace(/{AGGREGATIONS}/ig, mapconfig.cartodb.sqlTableAggregations)
        .replace('{WHERE}', where);
      this.aggregationButtons[assignment_id].downloadCSV(sql, true);
    }
  }

  render() {
    const { data, user, token } = this.props;
    return (
    <div className="student-assignmentlist">
      <h1>Assignments</h1>
      { data.map(classroom =>
        <section key={ classroom.classroom_id }>
          <h3>Classroom { classroom.classroom_name }</h3>
          <table className="table table-hover">
            <thead>
              <tr>
                <th>Name</th>
                <th>Description</th>
                <th>Due date</th>
                <th>Progress</th>
                <th>Action</th>
              </tr>
            </thead>
            <tbody>
            { classroom.assignments.map(assignment =>
              <tr key={ assignment.id } className="listitem">
                <td>{ assignment.name }</td>
                <td>{ assignment.description }</td>
                <td>{ assignment.duedate }</td>
                <td>{ assignment.classification_count }/{ assignment.target }</td>
                <td>
                  <a className="btn btn-primary"
                    href={`https://www.wildcamgorongosa.org/#/classify/assignment-${ assignment.id }/access_token=${ token.access_token }`}
                    target="_blank"
                    role="button">
                    Start assignment
                  </a>
                  <SuperDownloadButton
                    ref={ele => this.classificationButtons[assignment.id] = ele}
                    onClick={this.downloadMyClassifications(user.display_name, assignment.id)}
                    filename={DownloadHelper.generateFilename('wildcam-my-classifications-')}
                    text="My Data"
                  />
                  <SuperDownloadButton
                    ref={ele => this.aggregationButtons[assignment.id] = ele}
                    onClick={this.downloadAssignmentSubjects(assignment.subjects, assignment.id)}
                    filename={DownloadHelper.generateFilename('wildcam-assignment-subjects-')}
                    text="Public Data"
                  />
                </td>
              </tr>
            ) }
            </tbody>
          </table>
        </section>
      ) }
    </div>
  );
  }
};
<commit_msg>Remove unused (?) access_token from Assignment URLs<commit_after>import React, { Component, PropTypes } from 'react';
import SuperDownloadButton from '../../common/components/SuperDownloadButton';
import { DownloadHelper } from '../../../helpers/download.js';
const mapconfig = require('../../../constants/mapExplorer.config.json');

class ClassroomAssignments extends Component {
  constructor(props) {
    super(props);

    this.classificationButtons = {};
    this.aggregationButtons = {};
  }

  downloadMyClassifications(username, assignment_id) {
    return () => {
      const sql =
        'SELECT cla.*, sub.location FROM {CLASSIFICATIONS} as cla LEFT JOIN {SUBJECTS} as sub ON cla.subject_id = sub.subject_id WHERE user_name =\'{WHERE_USER}\' AND workflow_id = {WHERE_WORKFLOW}'
        .replace(/{SUBJECTS}/ig, mapconfig.cartodb.sqlTableSubjects)
        .replace(/{CLASSIFICATIONS}/ig, mapconfig.cartodb.sqlTableClassifications)
        .replace(/{WHERE_USER}/ig, DownloadHelper.sqlStrSafe(username))
        .replace(/{WHERE_WORKFLOW}/ig, parseInt(assignment_id));
      this.classificationButtons[assignment_id].downloadCSV(sql, true);
    }
  }

  downloadAssignmentSubjects(subjects, assignment_id) {
    return () => {
      const where = 'WHERE items.subject_id IN ('+(subjects.join(','))+')';
      const sql =
        mapconfig.cartodb.sqlQueryDownload
        .replace(/{CAMERAS}/ig, mapconfig.cartodb.sqlTableCameras)
        .replace(/{SUBJECTS}/ig, mapconfig.cartodb.sqlTableSubjects)
        .replace(/{AGGREGATIONS}/ig, mapconfig.cartodb.sqlTableAggregations)
        .replace('{WHERE}', where);
      this.aggregationButtons[assignment_id].downloadCSV(sql, true);
    }
  }

  render() {
    const { data, user, token } = this.props;
    return (
    <div className="student-assignmentlist">
      <h1>Assignments</h1>
      { data.map(classroom =>
        <section key={ classroom.classroom_id }>
          <h3>Classroom { classroom.classroom_name }</h3>
          <table className="table table-hover">
            <thead>
              <tr>
                <th>Name</th>
                <th>Description</th>
                <th>Due date</th>
                <th>Progress</th>
                <th>Action</th>
              </tr>
            </thead>
            <tbody>
            { classroom.assignments.map(assignment =>
              <tr key={ assignment.id } className="listitem">
                <td>{ assignment.name }</td>
                <td>{ assignment.description }</td>
                <td>{ assignment.duedate }</td>
                <td>{ assignment.classification_count }/{ assignment.target }</td>
                <td>
                  <a className="btn btn-primary"
                    href={`https://www.wildcamgorongosa.org/#/classify/assignment-${ assignment.id }`}
                    target="_blank"
                    role="button">
                    Start assignment
                  </a>
                  <SuperDownloadButton
                    ref={ele => this.classificationButtons[assignment.id] = ele}
                    onClick={this.downloadMyClassifications(user.display_name, assignment.id)}
                    filename={DownloadHelper.generateFilename('wildcam-my-classifications-')}
                    text="My Data"
                  />
                  <SuperDownloadButton
                    ref={ele => this.aggregationButtons[assignment.id] = ele}
                    onClick={this.downloadAssignmentSubjects(assignment.subjects, assignment.id)}
                    filename={DownloadHelper.generateFilename('wildcam-assignment-subjects-')}
                    text="Public Data"
                  />
                </td>
              </tr>
            ) }
            </tbody>
          </table>
        </section>
      ) }
    </div>
  );
  }
};

{'fraction_non_alphanumeric': 0.13375962416808038, 'fraction_numerical': 0.0010439775544825785, 'mean_word_length': 2.025661271219897, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 99, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4040637', 'n_tokens_mistral': 2177, 'n_tokens_neox': 2083, 'n_words': 341}