diff --git a/compair/api/assignment_search_enddate.py b/compair/api/assignment_search_enddate.py index e571533d..94da5412 100644 --- a/compair/api/assignment_search_enddate.py +++ b/compair/api/assignment_search_enddate.py @@ -60,8 +60,8 @@ def get(self): db_url = str(current_app.config['SQLALCHEMY_DATABASE_URI']) engine = create_engine(db_url, pool_size=5, pool_recycle=3600) conn = engine.connect() - sql_text = str("SELECT JSON_OBJECT('course_name', t1.name,'name', t2.name,'answer_start', date_format(t2.answer_start, '%%M %%d, %%Y'),'answer_end', date_format(t2.answer_end, '%%M %%d, %%Y'),'compare_start', date_format(t2.compare_start, '%%M %%d, %%Y'), 'compare_end', date_format(t2.compare_end, '%%M %%d, %%Y')) FROM course as t1, assignment as t2 WHERE (t1.id = t2.course_id) AND (t2.compare_end >= '" + end_date + "' OR answer_end >= '" + end_date + "');"); - ##print(sql_text) + + sql_text = str("SELECT JSON_OBJECT('course_name', t1.name,'name', t2.name,'answer_start', date_format(t2.answer_start, '%%M %%d, %%Y'),'answer_end', date_format(t2.answer_end, '%%M %%d, %%Y'),'compare_start', date_format(t2.compare_start, '%%M %%d, %%Y'), 'compare_end', date_format(t2.compare_end, '%%M %%d, %%Y')) FROM course as t1, assignment as t2 WHERE (t1.id = t2.course_id) AND (t2.active=1) AND (t2.compare_end >= '" + end_date + "' OR answer_end >= '" + end_date + "');"); result = conn.execute(sql_text) final_result = [list(i) for i in result] diff --git a/compair/static/script-assignment-search.js b/compair/static/script-assignment-search.js index 7e66747c..2c0c1839 100644 --- a/compair/static/script-assignment-search.js +++ b/compair/static/script-assignment-search.js @@ -51,6 +51,15 @@ function showsearchapi(search_data) { for (let key in search_data) { //tab += `${search_data[key]}`; let obj = JSON.parse(search_data[key]) + + if (obj.compare_start == null){ + obj.compare_start = 'After answering ends'; + } + + if (obj.compare_end == null){ + obj.compare_end = 'No end date'; + } + tab += `${JSON.stringify(obj.course_name).replace(/\"/g, "")}${JSON.stringify(obj.name).replace(/\"/g, "")}${JSON.stringify(obj.answer_start).replace(/\"/g, "")}${JSON.stringify(obj.answer_end).replace(/\"/g, "")}${JSON.stringify(obj.compare_start).replace(/\"/g, "")}${JSON.stringify(obj.compare_end).replace(/\"/g, "")}`; iKey++; }