cloudcoderdotorg / CloudCoder

A web-based programming exercise system.
GNU Affero General Public License v3.0
71 stars 60 forks source link

registerstudents: Unknown column 'courseId' #64

Closed league closed 10 years ago

league commented 10 years ago

Hey guys, I'm trying to load a tab-separated roster as described in the wiki, and I got a MySQLSyntaxErrorException. Here's the transcript:

$ java -jar cloudcoderApp-v0.0.7.1.jar registerstudents
For which course would you like to register students?
0 - CCDemo - CloudCoder demo course
1 - CS102 - Programming 1
[Enter value in range 0..1] 1
Enter the name of the file containing a tab-separated list student registration entries in this format: 
username        firstname       lastname        email   password        section
Usernames in the datbase will be re-used, but the names/email/password will not be updated,and users will not be registered for a course if they are already registered
[default: ] ==> /home/ubuntu/cloudcoder-accounts.csv
Note that this may be a slow operation
Some logging results will be appended to logs/cloudcoder.log rather than echoed to stdout
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'courseId' in 'where clause'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.Util.getInstance(Util.java:386)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
        at org.cloudcoder.app.server.persist.ConfigurationUtil.getUsersInCourse(Unknown Source)
        at org.cloudcoder.app.server.persist.ConfigurationUtil.registerStudentsForCourseId2(Unknown Source)
        at org.cloudcoder.app.server.persist.RegisterStudents.registerStudents(Unknown Source)
        at org.cloudcoder.app.server.persist.RegisterStudents.main(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.cloudcoder.jetty.NestedJarClassLoader.runMain(Unknown Source)
        at org.cloudcoder.jetty.WebServer.runAdminCommand(Unknown Source)
        at org.cloudcoder.jetty.WebServer.handleCommand(Unknown Source)
        at org.cloudcoder.webserver.CloudCoderWebServer.main(CloudCoderWebServer.java:61)
Database error: Unknown column 'courseId' in 'where clause'

I checked out the schema in MySQL to see how the column was specified there, and it seems to be course_id:

mysql> describe cc_course_registrations;
+-------------------+---------+------+-----+---------+----------------+
| Field             | Type    | Null | Key | Default | Extra          |
+-------------------+---------+------+-----+---------+----------------+
| id                | int(11) | NO   | PRI | NULL    | auto_increment |
| course_id         | int(11) | NO   |     | NULL    |                |
| user_id           | int(11) | NO   |     | NULL    |                |
| registration_type | int(11) | NO   |     | NULL    |                |
| section           | int(11) | NO   |     | NULL    |                |
+-------------------+---------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

I'm probably going to set up a dev environment shortly, so I can occasionally push patches into my live environment. Thanks for the help!

league commented 10 years ago

I was able to work around this using the "Bulk Register" button on the Users page, so maybe it can be considered as a documentation bug.

daveho commented 10 years ago

I pushed a fix to my public repository. We will test this before the next release. Thanks for the report!

daveho commented 10 years ago

I'm going to optimistically assume that this is fixed :-)