Register for InstructureCon25 • Passes include access to all sessions, the expo hall, entertainment and networking events, meals, and extraterrestrial encounters.
Found this content helpful? Log in or sign up to leave a like!
Is there any API function that returns the title or URL of the page that students viewed?
The number of page_views can be achieved by making this call (Analytics - Canvas LMS REST API Documentation ), but it only returns the page_view counts and its timestamp.
Hi @bneporadny ,
Thank you for the information!
Yes, I was able to get the URL of the page that the students viewed, but I need title of the page that students visited for the application that I'm working on.
Do you know if there is a way to retrieve page title via page URL through an API call?
Thank you
Hi Brian,
I haven't really used this table very much just because it is extremely large, but included in the table is the "ID" for the assignment, quiz, etc. that you should then be able to use to tie back to the appropriate table to get the title of said request.
Request table documenation
Hope this helps.
Brian
@kj460 ,
I don't think you want to do this with the API, see API Call: User Page Views/Submissions within Date Range
For Canvas Data, you can JOIN tables together.
I just pieced this together from some of my samples. This will return:
-- mssql
-- join requests to course, assignments, quiz and display the title...
-- WHEN the request is associated to those records
SELECT *
FROM (
SELECT
r.user_id,
CONVERT(DATETIME, CONVERT(VARCHAR(20), r.timestamp, 100)) timestamp,
r.url,
--r.course_id,
c.canvas_id AS canvas_course_id,
c.name AS course_name,
--r.quiz_id,
q.canvas_id AS canvas_quiz_id,
q.name AS quiz_name,
--r.assignment_id,
a.canvas_id AS canvas_assignment_id,
a.title AS assignment_name,
CASE
WHEN PATINDEX('/courses/%/pages/%', url) >= 1 AND PATINDEX('%?%', url) >= 1
THEN SUBSTRING(LEFT(url,CHARINDEX('?',url)), CHARINDEX('/pages/',url,0)+7,(CHARINDEX('/', REVERSE(url), 1)-CHARINDEX('?', REVERSE(url), 1))-1)
WHEN PATINDEX('/courses/%/pages/%', url) >= 1 AND PATINDEX('%?%', url) = 0
THEN SUBSTRING(url, CHARINDEX('/pages/',url,0)+7,1000)
WHEN PATINDEX('/courses/%/pages', url) >= 1
THEN 'pages-list'
ELSE ''
END AS wiki_url
FROM dbo.requests r
LEFT JOIN dbo.course_dim c ON (c.id = r.course_id)
LEFT JOIN dbo.quiz_dim q ON (q.id = r.quiz_id)
--LEFT JOIN dbo.discussion_dim d ON (d.id = r.discussion_id)
LEFT JOIN dbo.assignment_dim a ON (a.id = r.assignment_id)
WHERE
user_id IS NOT NULL -- AND user_id =
AND PATINDEX('%ping%',url) = 0
AND PATINDEX('%page_views%',url) = 0
AND PATINDEX('/api/v1/%',url) = 0
AND PATINDEX('%edit%',url) = 0
AND PATINDEX('%.json%',url) = 0
AND web_application_controller NOT IN ('files','folders')
AND web_application_action NOT IN ('backup')
) x
GROUP BY user_id, timestamp, url, canvas_course_id, course_name, canvas_quiz_id, quiz_name, canvas_assignment_id, assignment_name, wiki_url
ORDER BY timestamp
I will warn you that every clause or join you create on the requests table starts to slow down your results. Also check out Requests Table, Canvas Data Page Views
@kj460 ,
I'm responding to this specific question
Do you know if there is a way to retrieve page title via page URL through an API call?
The answer is yes, this can be done using the Show pages endpoint of the Pages API.
Let's say the URL (without the host) was this
/courses/896851/pages/followup-page?module_item_id=23210019
You would make an API call to
GET /api/v1/courses/896851/pages/followup-page
It returns an object like this ( I deleted the last edited by and removed the body)
{
"title": "Followup Page",
"created_at": "2016-06-05T04:03:26Z",
"url": "followup-page",
"editing_roles": "teachers",
"page_id": 6988007,
"last_edited_by": {
},
"published": true,
"hide_from_students": false,
"front_page": false,
"html_url": "https://richland.instructure.com/courses/896851/pages/followup-page",
"updated_at": "2016-06-05T04:03:58Z",
"locked_for_user": false,
"body": "<p> ... </p>"
}
Right there at the top is the title of the page.
If you anticipate a lot of URLs from the same course, you can make the call to without specifying the page name at the end and it will give you all the pages in a course.
To interact with Panda Bot in the Instructure Community, you need to sign up or log in:
Sign In