id
stringlengths
11
19
dataset_type
stringclasses
2 values
language
stringclasses
7 values
task_category
stringclasses
11 values
prompt_en
stringlengths
57
550
prompt_nl
stringlengths
62
566
code_snippet_input
stringlengths
0
2.02k
canonical_solution
stringlengths
86
3.05k
unit_test_setup
stringlengths
0
543
unit_test_assertion
stringlengths
172
1.27k
comment
stringlengths
86
465
dialect
stringclasses
3 values
base_sql_06
base
SQL
id_bug
This query should return the probability of a disease ocurring in each region but returns zero for all regions, when thats not the case. Fix the query.
Deze query zou de kans op het voorkomen van een ziekte in elke regio moeten weergeven, maar geeft voor alle regio's nul weer, terwijl dat niet het geval is. Corrigeer de query.
SELECT region_name, positive_cases, total_population, (positive_cases / total_population) AS disease_probability FROM population_studies;
SELECT region_name, (positive_cases * 1.0 / total_population) AS disease_probability FROM population_studies;
CREATE TABLE population_studies ( region_name VARCHAR(50), positive_cases INT, total_population INT ); INSERT INTO population_studies VALUES ('Region A', 50, 100);
@Test public void testIntegerDivision(Connection conn) throws SQLException { try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(generatedSqlQuery)) { assertTrue(rs.next()); double probability = rs.getDouble("disea...
In Postgres (not necessarily other dialects), dividing INT by INT truncates to the nearest integer (0). The solution MUST cast one operand to a float either explicitly or by * 1.0 to get a decimal result above 0.
postgresql
base_sql_07
base
SQL
id_bug
I want to collect all of the 2023 transactions for the annual report but this query returns 4 additional transactions from 2024. Fix the query.
Ik wil alle transacties van 2023 verzamelen voor het jaarverslag, maar deze query geeft 4 extra transacties uit 2024 weer. Corrigeer de query.
DECLARE @Start DATETIME = '2023-1-1 00:00:00.000'; DECLARE @End DATETIME = '2023-12-31 23:59:59.999'; SELECT * FROM transactions WHERE transaction_date BETWEEN @Start AND @End;
SELECT * FROM transactions WHERE transaction_date >= '2023-1-1 00:00:00' AND transaction_date < '2024-1-1 00:00:00';
CREATE TABLE transactions ( id INT, transaction_date DATETIME ); INSERT INTO transactions VALUES (1, '2023-06-15 12:00:00'); INSERT INTO transactions VALUES (2, '2023-12-31 23:59:59.990'); INSERT INTO transactions VALUES (3, '2024-01-01 00:00:00.000');
@Test public void testDateRounding(Connection conn) throws SQLException { try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(generatedSqlQuery)) { int count = 0; while(rs.next()) { count++; Time...
The solution MUST use a half-open interval (< '2024-1-1') to safely capture all 2023 data without hitting MSSQL's 3ms rounding issue on .999 milliseconds.
mssql
base_sql_08
base
SQL
fix_bug
I want a query to get the logging time and ip address of the last time each user logged in to my website, but i get an error. Fix this query.
Ik wil een query om de inlogtijd en het IP adres te achterhalen van de laatste keer dat elke gebruiker zich op mijn website heeft aangemeld, maar ik krijg een foutmelding. Los deze query op.
-- Column 'user_logins.ip_address' is invalid in the select list because it is -- not contained in either an aggregate function or the GROUP BY clause. SELECT user_id, MAX(login_time) AS last_seen, ip_address FROM user_logins GROUP BY user_id, ip_address;
SELECT original.user_id, original.login_time AS last_seen, original.ip_address FROM user_logins original INNER JOIN ( SELECT user_id, MAX(login_time) AS max_time FROM user_logins GROUP BY user_id ) filtered ON original.user_id = filtered.user_id AND original.login_time = fil...
CREATE TABLE user_logins ( user_id INT, login_time DATETIME, ip_address VARCHAR(50) ); INSERT INTO user_logins VALUES (1, '2023-01-01 10:00:00', '1.1.1.1'); INSERT INTO user_logins VALUES (1, '2023-01-02 10:00:00', '2.2.2.2'); INSERT INTO user_logins VALUES (2, '2023-01-05 10:00:00', '3.3.3.3');
@Test public void testGroupByLogic(Connection conn) throws SQLException { try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(generatedSqlQuery)) { boolean foundUser1 = false; while(rs.next()) { if(rs.getInt("user_id") == 1) ...
The solution MUST resolve the aggregation error and return latest login ip for each user, either by joining the table to a subquery on itself (Self-Join), or using Window Functions (ROW_NUMBER).
mssql
base_sql_09
base
SQL
fix_bug
I want this query to return all of the patients that have visited the radiology department more than 10 times, but I get an error. Fix the query.
Ik wil dat deze query alle patiënten weergeeft die meer dan 10 keer de afdeling radiologie hebben bezocht, maar ik krijg een foutmelding. Corrigeer de query.
-- ERROR 1111 (HY000): Invalid use of group function SELECT p.patient_name, COUNT(r.log_id) AS visit_count FROM patients p JOIN radiology_log r ON p.patient_id = r.patient_id WHERE COUNT(r.log_id) > 10 GROUP BY p.patient_name;
SELECT p.patient_name, COUNT(r.log_id) AS visit_count FROM patients p JOIN radiology_log r ON p.patient_id = r.patient_id GROUP BY p.patient_name HAVING COUNT(r.log_id) > 10;
CREATE TABLE patients ( patient_id INT, patient_name VARCHAR(50) ); CREATE TABLE radiology_log ( log_id INT AUTO_INCREMENT, patient_id INT, PRIMARY KEY(log_id) ); INSERT INTO patients VALUES (1, 'Alice'); INSERT INTO radiology_log (patient_id) VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1)...
@Test public void testHavingClause(Connection conn) throws SQLException { try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(generatedSqlQuery)) { assertTrue(rs.next(), "Should return at least one patient with > 10 visits"); asser...
The solution MUST replace the WHERE clause with HAVING for filtering aggregate fields.
mysql
base_sql_10
base
SQL
fix_bug
I want a query that returns all of the patients in the system and the date they were admitted to the hospital, but I get an error. Fix the query.
Ik wil een query die alle patiënten in het systeem en de datum waarop ze in het ziekenhuis zijn opgenomen weergeeft, maar ik krijg een foutmelding. Los de query op.
-- Error Code: 1052. Column 'patient_id' in field list is ambiguous SELECT patient_id, name, admission_date FROM patients p JOIN admissions a ON p.patient_id = a.patient_id;
SELECT p.patient_id, p.name, a.admission_date FROM patients p JOIN admissions a ON p.patient_id = a.patient_id;
CREATE TABLE patients ( patient_id INT, name VARCHAR(50) ); CREATE TABLE admissions ( admission_id INT, patient_id INT, admission_date DATE ); INSERT INTO patients VALUES (1, 'John Doe'); INSERT INTO admissions VALUES (100, 1, '2023-01-01');
@Test public void testAmbiguousColumn(Connection conn) throws SQLException { try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(generatedSqlQuery)) { assertTrue(rs.next(), "Query should return results once the ambiguity is fixed."); ...
The solution MUST solve the ambiguity in 'patient_id' column with a table alias, either p.patient_id or a.patient_id (doesn't matter because they're identical, hence the JOIN).
mysql
base_sql_11
base
SQL
fix_bug
I want to retrieve all patients who have lab results greater than 100, but I get a conversion error because some results are not numeric even though I'm filtering them out. Fix the error.
Ik wil alle patiënten ophalen met laboratoriumresultaten hoger dan 100, maar ik krijg een conversiefout omdat sommige resultaten niet numeriek zijn, ook al filter ik ze eruit. Los de fout op.
-- Conversion failed when converting the varchar value 'Pending' to data type int SELECT patient_id, result_value FROM lab_results WHERE result_value NOT LIKE '%[^0-9]%' AND CAST(result_value AS INT) > 100;
SELECT patient_id, result_value FROM lab_results WHERE TRY_CAST(result_value AS INT) > 100;
CREATE TABLE lab_results ( patient_id INT, result_value VARCHAR(50) ); INSERT INTO lab_results VALUES (1, '150'); INSERT INTO lab_results VALUES (2, '50'); INSERT INTO lab_results VALUES (3, 'Pending');
@Test public void testSafeCast(Connection conn) throws SQLException { try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(generatedSqlQuery)) { assertTrue(rs.next(), "Should return the valid numeric row > 100"); assertEquals("150"...
The solution MUST use TRY_CAST (or similar) to attemp conversion safely, otherwise the conversion will raise an error because SQL is not procedural so order of operations can't be controlled
mssql
base_sql_12
base
SQL
refactoring
This query retrieves the names, the total spend and the date of the most recent order of our top buyers (spent more than 1000$ total). Refactor this query to make it more efficient and readable without changing functionality.
Deze query haalt de namen, het totale bedrag en de datum van de meest recente bestelling van onze topkopers (die in totaal meer dan 1000$ hebben uitgegeven) op. Herstructureer deze query om hem efficiënter en leesbaarder te maken zonder de functionaliteit te wijzigen.
SELECT c.customer_name, (SELECT SUM(amount) FROM orders o WHERE o.customer_id = c.id) as total_spend, (SELECT MAX(order_date) FROM orders o WHERE o.customer_id = c.id) as last_order_date FROM customers c WHERE (SELECT SUM(amount) FROM orders o WHERE o.customer_id = c.id) > 1000;
WITH CustomerStats AS ( SELECT customer_id, SUM(amount) AS total_spend, MAX(order_date) AS last_order_date FROM orders GROUP BY customer_id ), HighValueCustomers AS ( SELECT customer_id, total_spend, last_order_date FROM CustomerStats WHERE total...
CREATE TABLE customers ( id INT PRIMARY KEY, customer_name VARCHAR(50) ); CREATE TABLE orders ( id INT PRIMARY KEY, customer_id INT, amount INT, order_date DATE ); INSERT INTO customers VALUES (1, 'Alice'); INSERT INTO orders VALUES (101, 1, 600, '2023-01-01'); INSERT INTO orders VALUES (102...
@Test public void testRefactoring(Connection conn) throws SQLException { String sql = generatedSqlQuery.toUpperCase().replaceAll("\\s+", " "); boolean usesCTE = sql.contains("WITH "); boolean usesJoin = sql.contains("JOIN "); assertTrue(usesCTE || usesJoin, "Refac...
the solution MUST separate the big query with redundant subqueries into multiple queries with sepration of concerns (i.e. one for the math, one for the filtering, and one for the display), this makes the code mre efficient (less redundancy), more readable, and more maintainable (easier to debug). The unit test includes...
postgresql
base_sql_13
base
SQL
refactoring
Refactor this code use a CTE, keep the same functionality.
Herstructureer deze code met behulp van een CTE, behoud dezelfde functionaliteit.
SELECT patient_name, weight_kg, height_m, CASE WHEN (weight_kg / (height_m * height_m)) < 18.5 THEN 'Underweight' WHEN (weight_kg / (height_m * height_m)) >= 18.5 AND (weight_kg / (height_m * height_m)) < 25 THEN 'Healthy' WHEN (weight_kg / (height_m * height_m)) >= 25 AND (wei...
WITH PatientBMI AS ( SELECT patient_name, (weight_kg / (height_m * height_m)) as bmi_score FROM patients ) SELECT patient_name, bmi_score, CASE WHEN bmi_score < 18.5 THEN 'Underweight' WHEN bmi_score < 25 THEN 'Healthy' -- Implicitly means ">= 18.5 AND < 25" WHEN bmi_score < 30 THEN 'Overweight' -- Implicitly...
CREATE TABLE patients ( patient_name VARCHAR(50), weight_kg DECIMAL(10, 2), height_m DECIMAL(10, 2) ); INSERT INTO patients VALUES ('Alice', 50.0, 1.80); INSERT INTO patients VALUES ('Bob', 70.0, 1.75); INSERT INTO patients VALUES ('Charlie', 85.0, 1.75); INSERT INTO patients VALUES ('Diana', 100.0, 1.7...
@Test public void testBMIRefactoring(Connection conn) throws SQLException { String sql = generatedSqlQuery.toUpperCase(); assertTrue(sql.contains("WITH "), "Refactoring failed: You must use a Common Table Expression (WITH clause)."); try (Statement stmt = conn.createStatement(); ...
the solution MUST use a CTE to calculate BMI just once, then reference that in the main query to assign a category. The unit test includes structural checks (as well as functional checks) to ensure refactoring and specific use of CTE as the prompt requires. The unit test includes structural checks (as well as functiona...
postgresql
base_sql_14
base
SQL
refactoring
These are two queries that have similar calculations, one returns the gpa of all students, the other returns the gpa of cum laude students. Make a view called student_gpa_view to refactor this code to reduce redundancy.
Dit zijn twee query's met vergelijkbare berekeningen: de ene retourneert het gemiddelde cijfer van alle studenten, de andere retourneert het gemiddelde cijfer van cum laude-studenten. Maak een weergave met de naam student_gpa_view om deze code te herstructureren en redundantie te verminderen.
SELECT s.student_name, SUM(g.score * c.credits) * 1.0 / SUM(c.credits) AS gpa FROM students s JOIN grades g ON s.id = g.student_id JOIN courses c ON g.course_id = c.id GROUP BY s.student_name; SELECT s.student_name, SUM(g.score * c.credits) * 1.0 / SUM(c.credits) AS gpa FROM students s JOIN grades g ...
CREATE VIEW student_gpa_view AS SELECT s.id AS student_id, s.student_name, COUNT(g.course_id) AS total_classes, CAST(SUM(g.score * c.credits) * 1.0 / SUM(c.credits) AS DECIMAL(10,2)) AS gpa FROM students s JOIN grades g ON s.id = g.student_id JOIN courses c ON g.course_id = c.id GROUP BY s.id, s.studen...
CREATE TABLE students (id INT PRIMARY KEY, student_name VARCHAR(50)); CREATE TABLE courses (id INT PRIMARY KEY, credits INT); CREATE TABLE grades (student_id INT, course_id INT, score INT); INSERT INTO students VALUES (1, 'Felipe'); INSERT INTO courses VALUES (101, 5), (102, 5); INSERT INTO grades VALUES (1, 101, 9), ...
@Test public void testViewCreation(Connection conn) throws SQLException { try (Statement stmt = conn.createStatement()) { stmt.execute(generatedSqlQuery); } String verifySql = "SELECT student_name, gpa FROM student_gpa_view ORDER BY student_name DESC"; try (S...
the solution MUST create a view called student_gpa_view that encapsulates the GPA calculation logic, so that both original queries can be simplified to select from this view with appropriate filtering (by student_id for the first, and by gpa for the second). This reduces redundancy and improves maintainability. The uni...
postgresql
base_sql_15
base
SQL
refactoring
This query retrieves the name, last order date and last product ordered for all customers, but it has repeated subqueries. Refactor the query using a lateral join to make it more efficient and readable without changing functionality.
Deze query haalt de naam, laatste besteldatum en laatst bestelde producten voor alle klanten op, maar bevat herhaalde subquery's. Herstructureer de query met behulp van een lateral join om deze efficiënter en leesbaarder te maken zonder de functionaliteit te wijzigen.
SELECT c.name, (SELECT order_date FROM orders o WHERE o.customer_id = c.id ORDER BY order_date DESC LIMIT 1) as order_date, (SELECT product_name FROM orders o WHERE o.customer_id = c.id ORDER BY order_date DESC LIMIT 1) as product_name, (SELECT amount FROM orders o WHERE o.customer_id = c.id ORDER BY o...
SELECT c.name, last_o.order_date, last_o.product_name, last_o.amount FROM customers c LEFT JOIN LATERAL ( SELECT order_date, product_name, amount FROM orders o WHERE o.customer_id = c.id ORDER BY order_date DESC LIMIT 1 ) last_o ON TRUE;
CREATE TABLE customers ( id INT PRIMARY KEY, name VARCHAR(50) ); CREATE TABLE orders ( id INT, customer_id INT, product_name VARCHAR(50), amount INT, order_date DATE ); INSERT INTO customers VALUES (1, 'Alice'); INSERT INTO orders VALUES (101, 1, 'Phone', 500, '2023-01-01'); INSERT IN...
@Test public void testLateralJoin(Connection conn) throws SQLException { String sql = generatedSqlQuery.toUpperCase(); assertTrue(sql.contains("LATERAL"), "Refactoring failed: The model ignored the instruction to use LATERAL JOIN."); try (Statement stmt = conn.createStatement(); ...
the solution MUST use a LATERAL JOIN to fetch the last order details in a single subquery per customer. The unit test includes structural checks (as well as functional checks) to ensure refactoring.
postgresql
stress_groovy_01
stress
Groovy
elem_func
write a singleton DatabaseConnection class in Groovy with the builder pattern. It must have fields for url, timeout and encrypted, and have equals, hashCode and toString methods.
Schrijf een singleton DatabaseConnection klasse in Groovy met het builder patroon. Deze moet velden hebben voor url, timeout en encrypted, en beschikken over equals, hashCode en toString methoden.
import groovy.transform.Canonical import groovy.transform.builder.Builder @Singleton(lazy = true) @Canonical @Builder class DatabaseConnection { String url Integer timeout Boolean encrypted }
import groovy.lang.GroovyClassLoader def evalCode(String llmOutput) { GroovyClassLoader loader = new GroovyClassLoader() try { Class clazz = loader.parseClass(llmOutput) return clazz } catch (Exception e) { return "Compilation Error: ${e.message}" } }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result Class clazz = (Class) result def hasSingleton = clazz.methods.any { it.name == 'getInstance' } def hasCanonical = clazz.methods.any { it.name == 'canEqual' } def hasBuilder = clazz.declaredClas...
Groovy automatically handles the boilerplate code for a singleton and builder architecture by using the @Singleton and @Builder annotations. The @Canonical annotation is used to generate the equals, hashCode, and toString methods based on the fields of the class. The solution MUST use @Singleton, @Builder and @Canonica...
null
stress_groovy_02
stress
Groovy
id_bug
I dont know why the second test case fails since they are different objects. fix the bug.
Ik weet niet waarom de tweede testcase mislukt, aangezien het verschillende objecten zijn. Los de bug op.
@groovy.transform.EqualsAndHashCode class Cell{ private int x; private int y; Cell(x,y){ this.x = x; this.y = y; } } def liveCells = [] as Set Cell cell = new Cell(0,0); Cell diffCell = new Cell(1,1); liveCells.add(cell) assert liveCells.contains(cell) == true assert liveCells.con...
@groovy.transform.EqualsAndHashCode class Cell{ int x; int y; } def liveCells = [] as Set Cell cell = new Cell(0,0); Cell diffCell = new Cell(1,1); liveCells.add(cell) assert liveCells.contains(cell) == true assert liveCells.contains(diffCell) == false
import groovy.lang.GroovyClassLoader def evalCode(String llmOutput) { def loader = new GroovyClassLoader() try { Class clazz = loader.parseClass(llmOutput) return clazz } catch (Exception e) { return "Compilation Error: " + e.message } }
def testSolution(Object result) { if (result instanceof String) return result Class clazz = (Class) result def c1, c2 try { c1 = clazz.newInstance() c1.x = 0; c1.y = 0 c2 = clazz.newInstance() c2.x = 1; c2.y = 1 } catch (e) { try { c1 = clazz.getDe...
In groovy @EqualsAndHashCode does not take into account private fields, so two objects with the same properties (none) but different private fields will have the same hashcode and be considered equal. The solution MUST remove the private fields OR use EqualsAndHashCode(includeFields=true) to include private fields in t...
null
stress_groovy_03
stress
Groovy
syntax recall
write this logmessage so that the status dynamically updates in the log output at the time it is printed, without reassigning the logmessage variable.
Schrijf dit logmessage zodat de status dynamisch wordt bijgewerkt in de loguitvoer.
class Logger { String status = 'initialized' def logMessage = }
class Logger { String status = 'initialized' def logMessage = "${-> status}" }
import groovy.lang.GroovyClassLoader def evalCode(String llmOutput) { def loader = new GroovyClassLoader() try { Class clazz = loader.parseClass(llmOutput) return [clazz: clazz, source: llmOutput] } catch (Exception e) { return "Compilation Error: ${e.message}" } }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result def clazz = result.clazz def source = result.source def instance = clazz.newInstance() instance.status = "alpha" def firstVal = instance.logMessage.toString() instance.status = "omega" ...
In groovy, using Gstirng lazy evaluation syntax ${-> var} allows the string to print the current value of the variable at the time of evaluation, instead of at the time of the string's creation. The solution MUST use the ${-> var} syntax to ensure the log message updates dynamically with the current status.
null
stress_vuejs_01
stress
VueJS
UI_comps
Write a VueJS component for a header of a webpage that contains the name "Christina's Bakery", a dropdown manu with items "Home", "Recipes" and "Contact", and a search bar.
Schrijf een VueJS-component voor een koptekst van een webpagina met de naam "Christina's Bakery", een vervolgkeuzemenu met de items "Home", "Recepten" en "Contact" en een zoekbalk.
<template> <header class="navbar"> <div class="brand"> <h1>Christina's Bakery</h1> </div> <nav class="nav-container"> <div class="dropdown" @mouseleave="isMenuOpen = false"> <button class="dropdown-trigger" @click="toggleMenu" aria-haspopup="true" ...
def evalCode(String llmOutput) { if (llmOutput == null || llmOutput.trim().isEmpty()) { return "empty solution" } return [source:llmOutput] }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result def source = result.source def requirements = [ [/(?i)<template/, "Missing <template> block"], [/(?i)Christina[''’]s\s+Bakery/, "Brand name 'Christina's Bakery' not found"], [/(?...
The solution MUST include a <template> block with the brand name 'Christina's Bakery', a dropdown menu with the items 'Home', 'Recipes', and 'Contact', and a search bar input that is reactively bound using v-model. The dropdown menu MUST also include logic for showing/hiding the menu items using v-if or v-show, and be ...
null
stress_vuejs_02
stress
VueJS
syntax_recall
I want to dynamically set the backgroundColor of the status-indicator div based on the value "statusColor", that will be green when available, and red when on loan.
Ik wishow me tl de backgroundColor van de status-indicator div dynamisch instellen op basis van de waarde "statusColor", die groen is wanneer beschikbaar en rood wanneer uitgeleend.
<template> <div class="library-item"> <span class="book-info"> <strong>{{ bookTitle }}</strong> — {{ status }} </span> <div class="status-indicator"></div> </div> </template>
<template> <div class="library-item"> <span class="book-info"> <strong>{{ bookTitle }}</strong> — {{ status }} </span> <div class="status-indicator" :style="{ backgroundColor: statusColor }" ></div> </div> </template> <script setup> import { computed } from 'vue' const props = ...
def evalCode(String llmOutput) { if (llmOutput == null || llmOutput.trim().isEmpty()) { return "empty solution" } return [source:llmOutput] }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result def source = result.source def hasBinding = source =~ /(?is)(:style|v-bind:style)[ ]*=[ ]*['"]/ def referencesVar = source =~ /(?is)(:style|v-bind:style)[ ]*=[ ]*['\"][^'\"]*statusColor[^'\"]*['\"...
the solution MUST use the :style or v-bind:style directive to bind the backgroundColor to statusColor. the solution does not need to include the logic for determining the value of statusColor, but it must correctly reference it in the style binding.
null
stress_vuejs_03
stress
VueJS
migrating
Migrate this component to Vue 3 composition API syntax. Don't change anything else.
Migreer deze component naar de syntaxis van de Vue 3 composition API. Verander verder niets.
<template> <div class="felipe-productions"> <header> <h1>{{ companyName }}</h1> <p>{{ welcomeMessage }}</p> </header> <section class="portfolio-stats"> <span>Featured Projects: {{ projectCount }}</span> <span> | </span> <span>Your Favorites: {{ favoriteCount }}</span> </...
<template> <div class="felipe-productions"> <header> <h1>{{ companyName }}</h1> <p>{{ welcomeMessage }}</p> </header> <section class="portfolio-stats"> <span>Featured Projects: {{ projectCount }}</span> <span> | </span> <span>Your Favorites: {{ favoriteCount }}</span> </...
def evalCode(String llmOutput) { if (llmOutput == null || llmOutput.trim().isEmpty()) { return "empty solution" } return [source:llmOutput] }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result def source = result.source def usesReactivity = (source =~ /\.value/) || (source =~ /reactive\(/) assert usesReactivity : "The model did not implement Vue 3 reactivity correctly." def hasThisC...
the solution MUST use the <script setup> syntax, import 'ref' and 'computed' from 'vue', and correctly use .value for reactive references. The mounted() lifecycle hook should be replaced with onMounted(). The solution should not use the 'this' keyword, as it is not used in the Composition API.
null
stress_dataweave_01
stress
DataWeave
queries
Write a function in DataWeave that calculates and returns the GPA of each student.
Schrijf een functie in DataWeave die het GPA van elke student berekent en weergeeft.
[ { "student_id": "STU001", "name": "Laura Morales", "grades": { "Mathematical Modelling": 9, "Human Computer Interaction": 8, "Natural Language Processing": 10 } }, { "student_id": "STU002", "name": "Felipe Janssen", "grades": { "Mathematical Modelling": 7, ...
%dw 2.0 output application/json fun calculateGPA(grades: Object) = do { var gradeList = valuesOf(grades) --- avg(gradeList) as String {format: "0.00"} as Number } --- payload map (student) -> { "id": student.student_id, "name": student.name, "total_subjects": sizeOf(student.grades), "gpa": ...
def evalCode(String llmOutput) { if (llmOutput == null || llmOutput.trim().isEmpty()) { return "empty solution" } return [source:llmOutput] }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result; def source = result.source; assert source =~ '(?is)%dw 2\\.0' : "Missing %dw 2.0 directive."; def extractsValues = (source =~ '(?is)valuesOf\\s*\\(') || (source =~ '(?is)pluck'); assert extra...
the solution MUST extract the values from the grades object using valuesOf() or pluck, calculate the mean using avg() or by manually summing and dividing by the number of subjects, and contain a 'gpa' (case insensitive) field with the calculated GPA for each student.
null
stress_dataweave_02
stress
DataWeave
fix_bug
I want to pass the item variable dynamically to the getSFDCId function, but it doesn't work. fix the bug.
Ik wil de variable item dynamisch doorgeven aan de functie getSFDCId, maar dat lukt niet. Los het probleem op.
/* { "OrderId": "TST-test-123212-01", } */ %dw 2.0 output application/json var lis = { "TST-test-123212-01": "a2F2h000000pMl8EAE", "TST-test-123212-02": "a2F2h000000q6qHEAQ" } fun getSFDCId (item) = lis.item --- { OrderId__c: getSFDCId(payload.OrderId) }
%dw 2.0 output application/json var lis = { "TST-test-123212-01": "a2F2h000000pMl8EAE", "TST-test-123212-02": "a2F2h000000q6qHEAQ" } fun getSFDCId (item) = lis[item] --- { OrderId__c: getSFDCId(payload.OrderId) }
def evalCode(String llmOutput) { if (llmOutput == null || llmOutput.trim().isEmpty()) { return "empty solution" } return [source:llmOutput] }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result def source = result.source def hasBuggyNotation = source =~ /lis\.item/ assert !hasBuggyNotation : "kept the buggy 'lis.item' notation." def hasDynamicAccess = source =~ /lis\s*\[\s*item\s*\]/...
the bug is in lis.item, which looks for an 'item' key in the list, instead of searching for the value in the item variable. The solution MUST use bracket notation lis[item] to access the value dynamically based on the item variable
null
stress_dataweave_03
stress
DataWeave
syntax_recall
write a Dataweave function loanBook(book:Object)to change the entry passed as an input to available = false and last_loan_date to the current date, whithout reassigning every field.
Schrijf een Dataweave function loanBook(book:Object) om de invoer die als input wordt doorgegeven te wijzigen in available = false en last_loan_date in de huidige datum, zonder elk veld opnieuw toe te wijzen.
/*title,author,available,last_loan_date The Great Gatsby,F. Scott Fitzgerald,true,2025-11-12 1984,George Orwell,false,2026-02-28 To Kill a Mockingbird,Harper Lee,true,2025-08-15 The Hobbit,J.R.R. Tolkien,true,2026-01-10 Brave New World,Aldous Huxley,false,2026-03-01 The Catcher in the Rye,J.D. Salinger,true,2025-12-05 ...
%dw 2.0 output application/json fun loanBook(book: Object) = book update { case .available -> false case .last_loan_date -> now() as String {format: "yyyy-MM-dd"} } --- payload map (item) -> loanBook(item)
def evalCode(String llmOutput) { if (llmOutput == null || llmOutput.trim().isEmpty()) { return "empty solution" } return [source:llmOutput] }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result def source = result.source def usesUpdateOperator = source =~ /(?i)case\s+\.available/ assert usesUpdateOperator : "The solution failed to use the 'update' operator." def hasCaseStatements = so...
the solution MUST use the 'update' operator to modify only the specified fields without reassigning every field in the object with the map operator. The 'update' operator requires 'case' selectors to specify which fields to update, so the solution MUST include 'case .available' to set it to false and 'case .last_loan_d...
null
stress_dataweave_04
stress
DataWeave
refactoring
Refactor this DataWeave code to improve redability and maintainability, without changing its functionality.
Herstructureer deze DataWeave code om de leesbaarheid en onderhoudbaarheid te verbeteren, zonder de functionaliteit te wijzigen.
%dw 2.0 output application/json --- payload map (sensor) -> { sensor_id: sensor.id, alert_level: if (sensor.status == "OFFLINE") "CRITICAL" else if (sensor.type == "BOILER") if (sensor.temp > 100) "DANGER" else if (sensor.temp > 80) "WARNING" else "NORMAL...
%dw 2.0 output application/json --- payload map (sensor) -> { sensor_id: sensor.id, alert_level: sensor match { case s if (s.status == "OFFLINE") -> "CRITICAL" case s if (s.type == "BOILER" and s.temp > 100) -> "DANGER" case s if (s.type == "BOILER" and s.temp > 80) -> "WARNING" ...
def evalCode(String llmOutput) { if (llmOutput == null || llmOutput.trim().isEmpty()) { return "empty solution" } return [source:llmOutput] }
def testSolution(Object result) { if (result instanceof String && result.contains("Error")) return result def source = result.source def usesMatch = source =~ /(?i)match\s*\{/ assert usesMatch : "The solution failed to implement the 'match' operator." assert source =~ /->/ : "Missing case arrows (...
the solution MUST refactor the nested if-else statements into a more readable structure using the 'match' operator. Each condition should be represented as a 'case' within the match block.
null