Skip to content

Commit

Permalink
updated for vitamins and videos watched
Browse files Browse the repository at this point in the history
  • Loading branch information
KartikKapur committed Jan 28, 2019
1 parent f9d530c commit 5fb6cb1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 0 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ def ask_piazza_question(course_ok_id, lecture_url_name, video_index,
identity_msg=identity_msg
)["id"]
try:

sql_client.post_question(
user_email=email,
course_ok_id=course_ok_id,
Expand Down
24 changes: 24 additions & 0 deletions utils/schemas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,32 @@ CREATE TABLE IF NOT EXISTS piazza_questions (
identity varchar NOT NULL
);

CREATE TABLE IF NOT EXISTS vitamin_answers (
user_ok_id varchar NOT NULL,
course_ok_id varchar NOT NULL,
time_answered timestamp NOT NULL,
answer varchar NOT NULL,
video_index integer NOT NULL,
vitamin_index integer NOT NULL,
lecture_url_name varchar NOT NULL
);

CREATE TABLE IF NOT EXISTS videos_watched (
user_ok_id varchar NOT NULL,
course_ok_id varchar NOT NULL,
time_watched timestamp NOT NULL,
video_index integer NOT NULL,
lecture_url_name varchar NOT NULL
);

PREPARE post_question AS
INSERT INTO piazza_questions VALUES ($1, $2, $3, $4, $5, $6, $7);

PREPARE retrieve_questions_for_timestamp as
SELECT * FROM piazza_questions WHERE seconds >= $1 AND seconds <= $2 AND course_ok_id=($3) AND lecture_url_name=($4) AND video_index=($5);

PREPARE answer_vitamin as
INSERT INTO vitamin_answers VALUES ($1, $2, $3, $4, $5, $6, $7);

PREPARE watch_video as
INSERT INTO videos_watched VALUES ($1, $2, $3, $4, $5);
18 changes: 17 additions & 1 deletion utils/sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ def retrieve_questions_for_timestamp(self, start_second, end_second, course_ok_i
(start_second, end_second, course_ok_id, lecture_url_name, video_index)
)
self.conn.commit()
cursor = cur.fetchall()
cursor = cur.fetchall()
cur.close()
return cursor

def answer_vitamin(self,user_ok_id,course_ok_id, time_answered,answer,
video_index, vitamin_index,lecture_url_name):
cur = self.conn.cursor()
cur.execute(
'EXECUTE answer_vitamin (%s, %s, %s, %s, %s, %s, %s)',
(user_ok_id, course_ok_id, time_answered, answer,video_index,
vitamin_index, lecture_url_name)
)

def watch_video(self,user_ok_id, course_ok_id,time_watched,video_index, lecture_url_name):
cur = self.conn.cursor()
cur.execute(
'EXECUTE watch_video (%s, %s, %s, %s, %s)',
(user_ok_id, course_ok_id,time_watched,video_index, lecture_url_name)
)

0 comments on commit 5fb6cb1

Please sign in to comment.