Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #66 from CodeChefVIT/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
aditansh authored Oct 15, 2023
2 parents 328da48 + d9f1882 commit 178db2a
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 84 deletions.
101 changes: 48 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,64 @@
<p align="center"><a href="https://www.codechefvit.com" target="_blank"><img src="https://i.ibb.co/4J9LXxS/cclogo.png" width=160 title="CodeChef-VIT" alt="Codechef-VIT"></a>
</p>

<h2 align="center"> Project Title </h2>
<h1 align="center"> CookOff </h1>
<br/>

> Include project description here.
> <p>Welcome to CookOff - your go-to online coding portal for honing your programming skills and mastering algorithmic challenges! CookOff is designed to provide an immersive coding experience, offering a diverse range of programming problems and challenges that will put your skills to the test. Our platform leverages the power of Judge0 as its compiler, ensuring efficient and accurate code evaluation. Whether you're a seasoned coder looking for a new challenge or a beginner eager to learn, CookOff has something for everyone. Explore a vast collection of coding problems, practice, and compete in coding contests to measure your progress against the best in the community. CookOff is not just a coding platform; it's a vibrant community of programmers, eager to learn, share knowledge, and excel in the world of coding. Join us on CookOff, and let's cook up some code together!</p>
## Tech Stacks

---
- Next Js
- JavaScript
- TypeScript
- Tailwind CSS
- Framer Motion

[![DOCS](https://img.shields.io/badge/Documentation-see%20docs-green?style=flat-square&logo=appveyor)](INSERT_LINK_FOR_DOCS_HERE)
[![UI ](https://img.shields.io/badge/User%20Interface-Link%20to%20UI-orange?style=flat-square&logo=appveyor)](INSERT_UI_LINK_HERE)
[![GitHub Super-Linter](https://github.com/<OWNER>/<REPOSITORY>/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
## Features
- Insert list of features here

## Screenshots
<p align="center">
<img src="https://i.ibb.co/VppxmWZ/cet.png" alt="Common-Entry-Test" width="400px"/>
</p>
- Diverse Problem Set: CookOff offers a wide variety of programming problems, ranging from beginner to advanced levels, covering different programming languages and data structures.
- Contests and Challenges: Users can participate in coding contests and challenges regularly hosted on the platform. These contests can be time-limited, fostering a competitive and engaging environment.
- Instant Code Compilation: Utilizing Judge0 as the compiler, CookOff ensures fast and accurate code evaluation, providing instant feedback on code correctness and performance.
- API Support: Consider offering an API that allows developers to integrate CookOff's functionality into their own projects or websites.
- Admin Panel: For platform administrators, a comprehensive admin panel can be provided to manage user accounts, monitor system performance, and moderate user-generated content.

## Get Started

## Dependencies
- < dependency >
- < dependency >
## Instructions
There are two branches - test and typescript. The test branch hosts the portal in Javascript while the latter does it in Typescript.

To get started, fork your own copy and clone the brnach of your choice. To clone a branch you can run the following:

```bash
#Javascript hosted:
git clone -b test https://github.com/<Your username>/cookoff23-portal.git

#Typescript hosted
git clone -b ts https://github.com/<Your username>/cookoff23-portal.git

#### Directions to Install
```sh
$ git clone https://github.com/CodeChefVIT/<Project>
$ cd <Project>
$ npm install
```
#### Directions to Run
```sh
$ npm serve

Run these commands on your bash/terminal and open it in a code editor of your choice.
Please not that pull requests should only be made to these two branches and not the master branch.

Run the following to install all the dependencies:

```bash
npm i
```

To start your development server run:

```bash
npm run dev

```
## Contributors
<table>
<tr align="center" style="font-weight:bold">
<td>
John Doe
<p align="center">
<img src = "https://i.ibb.co/4J9LXxS/cclogo.png" width="150" height="150" alt="Your Name Here (Insert Your Image Link In Src">
</p>
<p align="center">
<a href = "https://github.com/<GitHub-username>">
<img src = "http://www.iconninja.com/files/241/825/211/round-collaboration-social-github-code-circle-network-icon.svg" width="36" height = "36" alt="GitHub"/>
</a>
</p>
</td>
<td>
John Doe
<p align="center">
<img src = "https://i.ibb.co/4J9LXxS/cclogo.png" width="150" height="150" alt="Your Name Here (Insert Your Image Link In Src">
</p>
<p align="center">
<a href = "https://github.com/<GitHub-username>">
<img src = "http://www.iconninja.com/files/241/825/211/round-collaboration-social-github-code-circle-network-icon.svg" width="36" height = "36" alt="GitHub"/>
</a>
</p>
</td>
</tr>
</table>

To have the entire functionality please note that you will have to either create your own backend or fork the official backend of CookOff :
[ https://github.com/CodeChefVIT/cookoff-backend](https://github.com/CodeChefVIT/cookoff-backend)

You will also need to host judge0 on your system. To learn more you can head over to their documentation[ https://github.com/judge0/judge0](https://github.com/judge0/judge0) .

You can also make a forked copy of the admin portal by heading over to: [ https://github.com/CodeChefVIT/cookoff23-admin](https://github.com/CodeChefVIT/cookoff23-admin)

## License

[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)

<p align="center">
Expand Down
16 changes: 16 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Since the ".env" file is gitignored, you can use the ".env.example" file to
# build a new ".env" file when you clone the repo. Keep this file up-to-date
# when you add new variables to `.env`.

# This file will be committed to version control, so make sure not to have any
# secrets in it. If you are cloning this repo, create a copy of this file named
# ".env" and populate it with your secrets.

# When adding additional environment variables, the schema in "/src/env.mjs"
# should be updated accordingly.

# Example:
# SERVERVAR="foo"
# NEXT_PUBLIC_CLIENTVAR="bar"
NEXT_PUBLIC_API_KEY= #link to backend
NEXT_PUBLIC_JUDGE0_URI= #link to Judge0 Servers
Binary file added frontend/src/assets/cookofflogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/components/EditorWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function EditorWindow(props) {
async function fetchSubmissionStatus(string) {
try {
const response = await axios.get(
"https://judge0.codechefvit.com/submissions/batch?tokens=" +
process.env.NEXT_PUBLIC_JUDGE0_URI+"submissions/batch?tokens=" +
string.toString() +
"&base64_encoded=true&fields=status_id,stdout,expected_output,stdin,stderr,compile_output,source_code"
);
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/components/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Navbar = () => {
const access_token = localStorage.getItem("access_token");
try {
const response = await axios.post(
"https://api-cookoff-prod.codechefvit.com/auth/logout",
process.env.NEXT_PUBLIC_API_KEY+"auth/logout",
{},
{
headers: {
Expand Down Expand Up @@ -66,7 +66,7 @@ const Navbar = () => {
await RefreshToken();
const access_token = localStorage.getItem("access_token");
const response = await axios.get(
"https://api-cookoff-prod.codechefvit.com/submit/endtest",
process.env.NEXT_PUBLIC_API_KEY+"submit/endtest",
{
headers: {
Authorization: `Bearer ${access_token}`,
Expand Down Expand Up @@ -111,9 +111,7 @@ const Navbar = () => {
End Test
</button>

<button>
<Image src={profile} quality={100} alt="user" />
</button>
</div>
</div>
) : (
Expand All @@ -130,9 +128,7 @@ const Navbar = () => {
Logout
</button>

<button>
<Image src={profile} quality={100} alt="user" />
</button>
</div>
</div>
)}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/TestCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const TestCase = ({ clickedButton, runData, code, program }) => {
async function fetchSubmit() {
try {
const response = await axios.get(
"https://judge0.codechefvit.com/submissions/" +
process.env.NEXT_PUBLIC_JUDGE0_URI+"submissions/" +
runToken +
"?base64_encoded=true&fields=stdout,stderr,status_id,language_id"
);
Expand Down Expand Up @@ -75,7 +75,7 @@ const TestCase = ({ clickedButton, runData, code, program }) => {

try {
const response = await axios.post(
"https://judge0.codechefvit.com/submissions/?base64_encoded=false",
process.env.NEXT_PUBLIC_JUDGE0_URI+"submissions/?base64_encoded=false",
{
language_id: code,
source_code: program,
Expand Down Expand Up @@ -274,7 +274,7 @@ const TestCase = ({ clickedButton, runData, code, program }) => {
className="bg-[#0d0d0d] text-white py-5 px-7 whitespace-pre"
>
<ReactMarkdown remarkPlugins={[remarkGfm]}>
{atob(runData[testCaseIndex].stdout)}
{runData[testCaseIndex].stdout === null || runData[testCaseIndex].stdout === undefined ? (null):(atob(runData[testCaseIndex].stdout))}
</ReactMarkdown>
</div>
</div>
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/components/compError.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { Buffer } from 'buffer';
import { Buffer } from "buffer";
import { useRef, useEffect } from "react";

function CompilationError(props) {
const { runTestCases, runData } = props;
const compileOutputBase64 = runData[0].compile_output;
const stderrBase64 = runData[0].stderr;

const compileOutputText = compileOutputBase64
? Buffer.from(compileOutputBase64, "base64").toString("utf-8")
: "";

const stderrText = stderrBase64
? Buffer.from(stderrBase64, "base64").toString("utf-8")
: "";
const containerRef = useRef(null);
useEffect(() => {
containerRef.current.scrollIntoView();
Expand All @@ -15,7 +25,7 @@ function CompilationError(props) {
<div className="bg-[#1f1f1f] w-full h-fit mb-10" ref={containerRef}>
<div className="pl-5 py-4">
<h1 className="text-[#CC3333] text-2xl font-semibold">
Compilation Error :(
Compilation Error :
</h1>
</div>
<div className=" text-[#c1bbb3] px-5">
Expand All @@ -27,7 +37,7 @@ function CompilationError(props) {
<p className="font-semibold text-lg">Compile Message</p>
<div className="bg-[#0D0D0D] py-2 pl-3 whitespace-pre">
<ReactMarkdown remarkPlugins={[remarkGfm]}>
{Buffer.from(runData[0].compile_output, 'base64').toString('utf-8') || Buffer.from(runData[0].stderr, 'base64').toString('utf-8')}
{compileOutputText || stderrText}
</ReactMarkdown>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Portal(props) {
const access_token = localStorage.getItem("access_token");
axios
.post(
"https://api-cookoff-prod.codechefvit.com/ques/getRound",
process.env.NEXT_PUBLIC_API_KEY+"ques/getRound",
{ round: round },
{
headers: {
Expand Down
Loading

0 comments on commit 178db2a

Please sign in to comment.