@@ -2275,26 +2275,52 @@ abstract class NDB_BVL_Instrument extends NDB_Page
2275
2275
(SELECT CommentID FROM load_comment_ids) " ;
2276
2276
}
2277
2277
if ($ condition !== null ) {
2278
- $ conditions [] = 'JSON_VALUE(Data, "$. '
2279
- . substr (
2278
+ $ fname = substr (
2280
2279
$ condition ->dictionary ->getName (),
2281
2280
strlen ($ this ->testName )+1
2282
- )
2283
- . '") '
2284
- . \LORIS \Data \Query \SQLQueryEngine::sqlOperator ($ condition ->criteria )
2285
- . ' '
2286
- . \LORIS \Data \Query \SQLQueryEngine::sqlValue (
2287
- $ condition ->dictionary ,
2288
- $ condition ->criteria ,
2289
- $ params
2290
- )
2291
- . ' ' ;
2281
+ );
2282
+ if ($ fname == 'Administration '
2283
+ || $ fname == 'Validity '
2284
+ || $ fname == 'Data_entry '
2285
+ ) {
2286
+ $ conditions [] = "flag. $ fname "
2287
+ . \LORIS \Data \Query \SQLQueryEngine::sqlOperator (
2288
+ $ condition ->criteria
2289
+ )
2290
+ . \LORIS \Data \Query \SQLQueryEngine::sqlValue (
2291
+ $ condition ->dictionary ,
2292
+ $ condition ->criteria ,
2293
+ $ params
2294
+ )
2295
+ . ' ' ;
2296
+ } else {
2297
+
2298
+ $ conditions [] = 'JSON_VALUE(Data, "$. '
2299
+ . substr (
2300
+ $ condition ->dictionary ->getName (),
2301
+ strlen ($ this ->testName )+1
2302
+ )
2303
+ . '") '
2304
+ . \LORIS \Data \Query \SQLQueryEngine::sqlOperator (
2305
+ $ condition ->criteria
2306
+ )
2307
+ . \LORIS \Data \Query \SQLQueryEngine::sqlValue (
2308
+ $ condition ->dictionary ,
2309
+ $ condition ->criteria ,
2310
+ $ params
2311
+ )
2312
+ . ' ' ;
2313
+ }
2314
+ $ conditions [] ="t.CommentID NOT LIKE 'DDE_%' " ;
2292
2315
}
2293
2316
$ where = 'WHERE ' . join (' AND ' , $ conditions );
2294
2317
$ query = "SELECT CandID,
2295
2318
SessionID,
2296
2319
CommentID,
2297
2320
session.Visit_Label as VisitLabel,
2321
+ flag.Administration,
2322
+ flag.Data_entry as DataEntry,
2323
+ flag.Validity,
2298
2324
Data
2299
2325
FROM flag
2300
2326
JOIN session ON (session.ID=flag.SessionID)
@@ -2306,12 +2332,18 @@ abstract class NDB_BVL_Instrument extends NDB_Page
2306
2332
foreach ($ jsondata as $ row ) {
2307
2333
$ newinst = clone $ this ;
2308
2334
2309
- $ newinst ->candID = new CandID (strval ($ row ['CandID ' ]));
2310
- $ newinst ->commentID = $ row ['CommentID ' ];
2311
- $ newinst ->visitLabel = $ row ['VisitLabel ' ];
2312
- $ newinst ->sessionID = new SessionID (
2313
- strval ($ row ['SessionID ' ])
2335
+ $ newinst ->candID = new CandID (strval ($ row ['CandID ' ]));
2336
+ $ newinst ->commentID = $ row ['CommentID ' ];
2337
+ $ newinst ->visitLabel = $ row ['VisitLabel ' ];
2338
+ $ newinst ->sessionID = new SessionID (
2339
+ strval ($ row ['SessionID ' ])
2340
+ );
2341
+ $ newinst ->flags = new \InstrumentFlags (
2342
+ $ row ['Data_entry ' ],
2343
+ $ row ['Administration ' ],
2344
+ $ row ['Validity ' ]
2314
2345
);
2346
+ unset($ row ['Data_entry ' ], $ row ['Administration ' ], $ row ['Validity ' ]);
2315
2347
$ newinst ->instanceData = json_decode (
2316
2348
$ row ['Data ' ] ?? '{} ' ,
2317
2349
true ,
@@ -2327,11 +2359,21 @@ abstract class NDB_BVL_Instrument extends NDB_Page
2327
2359
(SELECT CommentID FROM load_comment_ids) " ;
2328
2360
}
2329
2361
if ($ condition !== null ) {
2330
- $ conditions [] = 't. '
2331
- . substr (
2362
+ $ fname = substr (
2332
2363
$ condition ->dictionary ->getName (),
2333
2364
strlen ($ this ->testName )+1
2334
- )
2365
+ );
2366
+ if ($ fname == 'Administration '
2367
+ || $ fname == 'Validity '
2368
+ || $ fname == 'Data_entry '
2369
+ ) {
2370
+ $ tname = 'f. ' ;
2371
+ } else {
2372
+ $ tname = 't. ' ;
2373
+ }
2374
+
2375
+ $ conditions [] = $ tname
2376
+ . $ fname
2335
2377
. ' '
2336
2378
. \LORIS \Data \Query \SQLQueryEngine::sqlOperator (
2337
2379
$ condition ->criteria
@@ -2343,12 +2385,16 @@ abstract class NDB_BVL_Instrument extends NDB_Page
2343
2385
$ params
2344
2386
)
2345
2387
. ' ' ;
2388
+ $ conditions [] ="t.CommentID NOT LIKE 'DDE_%' " ;
2346
2389
}
2347
2390
$ where = 'WHERE ' . join (' AND ' , $ conditions );
2348
2391
$ query = "SELECT
2349
2392
session.CandID as CandID,
2350
2393
t.CommentID as CommentID,
2351
2394
session.Visit_Label as VisitLabel,
2395
+ f.Administration,
2396
+ f.Data_entry,
2397
+ f.Validity,
2352
2398
session.ID as SessionID, t.*
2353
2399
FROM $ this ->table t
2354
2400
JOIN flag f ON (t.CommentID=f.CommentID)
@@ -2365,6 +2411,13 @@ abstract class NDB_BVL_Instrument extends NDB_Page
2365
2411
$ newinst ->sessionID = new SessionID (strval ($ row ['SessionID ' ]));
2366
2412
unset($ row ['CommentID ' ], $ row ['VisitLabel ' ], $ row ['SessionID ' ]);
2367
2413
2414
+ $ newinst ->flags = new \InstrumentFlags (
2415
+ $ row ['Data_entry ' ],
2416
+ $ row ['Administration ' ],
2417
+ $ row ['Validity ' ]
2418
+ );
2419
+ unset($ row ['Data_entry ' ], $ row ['Administration ' ], $ row ['Validity ' ]);
2420
+
2368
2421
$ newinst ->instanceData = $ row ;
2369
2422
2370
2423
yield $ newinst ;
@@ -3071,13 +3124,17 @@ abstract class NDB_BVL_Instrument extends NDB_Page
3071
3124
return $ this ->determineDataEntryAllowed ();
3072
3125
}
3073
3126
3127
+ private ?\InstrumentFlags $ flags = null ;
3074
3128
/**
3075
3129
* Gets the flags of that instrument
3076
3130
*
3077
3131
* @return \InstrumentFlags
3078
3132
*/
3079
3133
public function getFlags (): \InstrumentFlags
3080
3134
{
3135
+ if ($ this ->flags !== null ) {
3136
+ return $ this ->flags ;
3137
+ }
3081
3138
$ row = \NDB_Factory::singleton ()->database ()->pselectRow (
3082
3139
'SELECT
3083
3140
Data_entry as dataentry,
@@ -3093,11 +3150,12 @@ abstract class NDB_BVL_Instrument extends NDB_Page
3093
3150
$ administration = $ row ['administration ' ] ?? null ;
3094
3151
$ validity = $ row ['validity ' ] ?? null ;
3095
3152
3096
- return new \InstrumentFlags (
3153
+ $ this -> flags = new \InstrumentFlags (
3097
3154
$ dataentry ,
3098
3155
$ administration ,
3099
3156
$ validity
3100
3157
);
3158
+ return $ this ->flags ;
3101
3159
}
3102
3160
3103
3161
/**
0 commit comments