Skip to content

Commit

Permalink
fix basecourseid retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
Yinnii committed May 23, 2024
1 parent 0d66aad commit 8580686
Showing 1 changed file with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ public boolean llm_feedback(@PathParam("label1") String label1, @PathParam("labe
System.out.println("Block " + label1);
JSONObject error = new JSONObject();
JSONObject newText = new JSONObject();

CodecRegistry pojoCodecRegistry = fromProviders(PojoCodecProvider.builder().automatic(true).build());
CodecRegistry codecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(), pojoCodecRegistry);
MongoClientSettings settings = MongoClientSettings.builder()
Expand All @@ -446,40 +445,21 @@ public boolean llm_feedback(@PathParam("label1") String label1, @PathParam("labe
@Override
public void run() {
String[] courseAndTask = label2.split("-");
int basisId = 0;
int courseId = Integer.parseInt(courseAndTask[0]);
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;

storeFileLocally(label1, body.getText(), body.getType());
System.out.println("Upload text");

try {
conn = service.getConnection();
stmt = conn.prepareStatement("SELECT * FROM course WHERE id = ? ORDER BY id ASC");
stmt.setInt(1, courseId);
rs = stmt.executeQuery();
basisId = rs.getInt("basecourseid");
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
int basisId = rs.getInt("basecourseid");

storeFileLocally(label1, body.getText(), body.getType());
System.out.println("Upload text");

try {
// Store usertext with label
String wordspec = body.getWordSpec();
String fileName = createFileName(label1, body.getType());
Expand Down Expand Up @@ -608,14 +588,29 @@ public void run() {
isActive.put(label1, false);
error.put("error", e.toString());
callBack(callbackUrl, label1, label1, label2, error);
}
catch (Exception e) {
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
isActive.put(label1, false);
error.put("error", e.toString());
callBack(callbackUrl, label1, label1, label2, error);
} finally {
try {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
}
}
}).start();
return true;
} catch (Exception e) {
Expand Down

0 comments on commit 8580686

Please sign in to comment.