コード例 #1
0
 private void setUpDefaultMetaInfo(Task task, ContestManager contestManager, String contestId) {
   task.setTestGroups(new LinkedList<TestGroup>());
   for (int i = 1; i <= task.getNumberOfTests(); ++i) {
     TestGroup group = new TestGroup();
     group.setFeedbackEnabled(i * 5 <= task.getNumberOfTests());
     group.setTestCases(Arrays.asList(i));
     group.setPoints(new BigDecimal(100 / task.getNumberOfTests()));
     task.addTestGroup(group);
   }
   contestManager.updateTask(contestId, task);
 }
コード例 #2
0
  private boolean handleMetaInfo(
      ZipEntry zipEntry,
      Task task,
      ZipInputStream zipStream,
      List<String> errorMessages,
      ContestManager contestManager,
      String contestId) {
    String fileName = new File(zipEntry.getName()).getName().toLowerCase();
    if (!fileName.equals(task.getName() + ".txt")) return false;

    List<TestGroup> testGroups = new LinkedList<TestGroup>();
    BufferedReader reader = new BufferedReader(new InputStreamReader(zipStream));
    String line = null;
    int lineNumber = 0;
    try {
      while ((line = reader.readLine()) != null) {
        String secondLine = reader.readLine();
        lineNumber += 2;
        if (secondLine == null) {
          if ("".equals(line)) {
            break;
          } else {
            addMessageOnLine(errorMessages, lineNumber, "Line appears to be empty.");
            return false;
          }
        }

        TestGroup group = new TestGroup();
        if (!parseOddLineOfMetaInfo(errorMessages, line, lineNumber, group)
            || !parseEvenLineOfMetaInfo(secondLine, task, errorMessages, lineNumber, group)) {
          return false;
        }
        testGroups.add(group);
      }
    } catch (IOException e) {
      addMessageOnLine(errorMessages, lineNumber, "Cannot read the file after this line.");
      return false;
    }
    task.setTestGroups(testGroups);
    contestManager.updateTask(contestId, task);

    return true;
  }