Skip to content

Commit

Permalink
Warming up!
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Apr 4, 2023
1 parent 4bb2fe4 commit 505490a
Show file tree
Hide file tree
Showing 220 changed files with 511 additions and 450 deletions.
124 changes: 124 additions & 0 deletions dist/api/searchPublicActivities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Allow-Credentials: true");
header('Content-Type: application/json');

require 'defineDBAndUserAndCourseInfo.php';

$success = TRUE;
$message = "";

$q = mysqli_real_escape_string($conn,$_REQUEST["q"]);

if ($q == ""){
$success = FALSE;
$message = 'Internal Error: missing search query';
}

$matchingUsers = [];
$matchingActivities = [];
//Get Matching Activities
if ($success) {
$sql = "
SELECT cc.doenetId,
CAST(cc.jsonDefinition as CHAR) AS json,
cc.imagePath,
cc.label,
cc.courseId,
p.doenetId AS 'pageDoenetId'
FROM course_content AS cc
LEFT JOIN pages AS p
ON p.containingDoenetId = cc.doenetId
WHERE cc.label LIKE '%$q%'
AND cc.isPublic = 1
AND cc.isDeleted = 0
LIMIT 100
";

$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()){
$json = json_decode($row['json'], true);
array_push($matchingActivities,[
'doenetId' => $row['doenetId'],
'courseId' => $row['courseId'],
'version' => $json['version'],
'content' => $json['content'],
'imagePath' => $row['imagePath'],
'label' => $row['label'],
'public' => '1',
'pageDoenetId' => $row['pageDoenetId'],
]);
}
// $courseToOwnerFullName = [];
foreach($matchingActivities as &$activity){
$courseId = $activity['courseId'];
$sql = "
SELECT u.firstName,
u.lastName
FROM course_role AS cr
LEFT JOIN course_user AS cu
ON cu.roleId = cr.roleId
LEFT JOIN user AS u
ON u.userId = cu.userId
WHERE cr.courseId = '$courseId'
AND cr.isOwner = 1
LIMIT 1
";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$activity['fullName'] = $row['firstName'] . ' ' . $row['lastName'];
}
}
}


$sql = "
SELECT c.courseId,
u.firstName,
u.lastName
FROM user AS u
LEFT JOIN course AS c
ON c.portfolioCourseForUserId = u.userId
WHERE c.portfolioCourseForUserId IS NOT NULL
AND CONCAT(u.firstName, ' ', u.lastName) LIKE '%$q%'
LIMIT 100
";

$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()){
$json = json_decode($row['json'], true);
array_push($matchingUsers,[
'courseId' => $row['courseId'],
'firstName' => $row['firstName'],
'lastName' => $row['lastName'],
]);
}
}



}



$response_arr = array(
"success"=>$success,
"message"=>$message,
"searchResults"=>["users"=>$matchingUsers,"activities"=>$matchingActivities],
);


// set response code - 200 OK
http_response_code(200);

// make it json format
echo json_encode($response_arr);
$conn->close();

?>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import{j as o,F as h,a as u,s as d}from"./index-6c514841.js";const c=d.button`
import{j as o,F as h,a as u,s as d}from"./index-762a3e7c.js";const c=d.button`
margin: ${e=>e.theme.margin};
height: 24px;
width: ${e=>e.width};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import{s as r,aw as l,j as a,F as f,a as m,ax as p}from"./index-6c514841.js";const h=r.div`
import{s as r,av as l,j as a,F as f,a as m,aw as p}from"./index-762a3e7c.js";const h=r.div`
/* margin-left: 3px; */
display: ${e=>e.vertical?"static":"flex"};
overflow: auto;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/assets/AssignmentBreadCrumb-95fe0eb6.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/assets/AssignmentBreadCrumb-d3753dea.js

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/assets/AssignmentSettingsMenu-584c09c2.js

This file was deleted.

Loading

0 comments on commit 505490a

Please sign in to comment.