singpath / verifier

Pull verifier task from a Firebase queue and run them inside docker container
MIT License
1 stars 1 forks source link

Java tests should be able to import package #25

Closed dinoboff closed 8 years ago

dinoboff commented 8 years ago

Test would be defined as follow:

import java.util.*; //Arrays, Map, List
import java.util.stream.*; //Stream, IntStream, Collectors;
import static org.junit.Assert.*;

public abstract class SingPath {

    public static void main() throws Exception {
        SingPath one = new SingPath();

        List<String> input = Arrays.asList("c2", "a5", "A3", "b1", "c1");;
        List<String> expected = Arrays.asList("C2", "A5", "A3", "B1", "C1");

        assertEquals(expected, one.capitalize(input));
    }

    // user content
   public List<String> capitalize(List<String> myList) {}
}

A solution would be define as:

public List<String> capitalize(List<String> myList) {
    List<String> result = myList.stream()
        .map(s -> s.toUpperCase()) 
        .collect(Collectors.toList());
    return result;
}

The verifier would need to parse the solution find where to insert the user solution, compile the class, run it, encode the result and save it in firebase db.

dinoboff commented 8 years ago

@SingaporeClouds Would it work like that?

dinoboff commented 8 years ago

ps: the verifier would return results similar to the current implementation except for the meta field which report the test runner run count and run time.

dinoboff commented 8 years ago

@SingaporeClouds

An easier solution (which only require to update the test and a template string in the current implementation) is to expect the following type of test and solution:

It let both solution and tests import packages, no parsing involved. It also let the test case have multiple tests.

SingaporeClouds commented 8 years ago

Ok. If this is what you recommend, let's try this.

By the way, if we always give the editor this test as an example along with this sample solution to experiment with, it will allow users to create new problems a lot more quickly.

On Thu, Jan 14, 2016 at 9:29 PM, Damien Lebrun notifications@github.com wrote:

@SingaporeClouds https://github.com/SingaporeClouds

An easier solution (which only require to update the test and a temple string in the current implementation is to expect the following type of test and solution:

  • tests:

    import java.util.*; //Arrays, Map, List
    
    import org.junit.Test;
    import static org.junit.Assert.*;
    import junit.framework.*;
    import com.singpath.SolutionRunner;
    
    public class SingPathTest extends SolutionRunner {
    
      @Test
      public void testCapitalize() throws Exception {
          SingPath one = new SingPath();
    
          List<String> input = Arrays.asList("c2", "a5", "A3", "b1", "c1");;
          List<String> expected = Arrays.asList("C2", "A5", "A3", "B1", "C1");
    
          assertEquals(expected, one.capitalize(input));
      }
    }
  • solutions:

    import java.util.; //Arrays, Map, List import java.util.stream.; //Stream, IntStream, Collectors;

    public class SingPath {

    public List capitalize(List myList) { List result = myList.stream() .map(s -> s.toUpperCase()) .collect(Collectors.toList()); return result; } }

It let both solution and tests import packages, no parsing involved. It also let the test case have multiple tests.

— Reply to this email directly or view it on GitHub https://github.com/singpath/verifier/issues/25#issuecomment-171645020.

Best Regards, Chris Boesch Associate Professor of Information Systems (Education) Singapore Management University

dinoboff commented 8 years ago

@SingaporeClouds The verifier have been updated and the problems migrated.

What do you think?

SingaporeClouds commented 8 years ago

The Java verifier looks good.

  1. Can we put a "Run Solution" button besides the save button to allow the problem editor to check their tests against the sample code?

If it is difficult to do this, then the solution can be treated as the current user's solution to the problem. This is essentially what I'm doing already by having 2 tabs open in my browser - in one I'm editing the problem and in the other tab I'm solving the problem as a user. I'd rather just have a [Run Solution] button in the editor and then be able to see the test results below the buttons.

This will allow the problem editor to paste in some code to the hint which they believe will pass their tests. Once they have their tests working with a known good solution, they can remove all or as many lines of code as they want from the hint and save the problem.

So we just need:

  1. A "Run Solution" button to the left of the Save button
  2. The tests results should show below the solution when the Run Solution button is pressed.

[image: Inline image 1]

I've added this as issue #240.

On Sat, Jan 16, 2016 at 8:46 AM, Damien Lebrun notifications@github.com wrote:

@SingaporeClouds https://github.com/SingaporeClouds The verifier have been updated and the problems migrated.

What do you think?

— Reply to this email directly or view it on GitHub https://github.com/singpath/verifier/issues/25#issuecomment-172137750.

Best Regards, Chris Boesch Associate Professor of Information Systems (Education) Singapore Management University