Skip to content

Commit

Permalink
Now you also test and run c and c++ files
Browse files Browse the repository at this point in the history
  • Loading branch information
blueedgetechno committed Aug 23, 2020
1 parent 6930d37 commit 74ec1e4
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 63 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
## An Atom package for all your competitive coding needs
<br>

![overview](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/face.png)

### Installation
Step 1.
Expand All @@ -32,25 +33,31 @@ oj l https://codeforces.com/
- Automatically create an environment for contest including working files 💻
- Run code with official sample cases of any particular problem 🔭
- Compare your output with expected output in a elegant manner 📺
- Get your code verdicts like OK ✅, Wrong answer ❌, TLE 🕒, MLE 🛢, Runtime error ⚠, Queue ⏳, Hacked ☠️
- Get your code verdicts like OK ✅, Wrong answer ❌, TLE 🕒, MLE 🛢, Runtime error or Compilation error ⚠, Queue ⏳, Hacked ☠️
- Submit 🏳‍🌈 your code from your favorite text editor
- Get your official standing of the live contest 👥
- Play minigames while you wait for the contest 🎮

## Updates
- Now supports the feature to test and run C++(g++ compiler) and C (gcc compiler) language codes 🎉🎊
- Option to run code for case independent problems 📡

## Guide
- Set your preferences in settings of the package, in advance
- Delete the folders and files of working directory before contest
- Click on Refresh button to refresh the standing
- Click on your standing to minimize problems view
- Click on your profile picture to refresh problems
- Click on an example number to copy its input data

## Limitations
- Currently, test and run code option is only available for python users
- I will try to remove the dependency of online-judge-tools for non-python users in future updates

<br>
- While running C or C++ files, it sometimes run the previously compiled file and shows the same verdict. Incase of that delete the previously compiled file and run the code again

![overview](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/face.png)
##### Any feedback will be highly appreciable

<br>

![work](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/work.png)
<hr>
Expand All @@ -76,4 +83,3 @@ oj l https://codeforces.com/

# MLE - Its a thing too
![TLE](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/mle.png)
<hr>
35 changes: 23 additions & 12 deletions lib/view/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default class Actions extends React.PureComponent {
outputs: props.outputs,
tests: props.tests,
runexamples: props.runexamples,
submitsolution: props.submitsolution
submitsolution: props.submitsolution,
changeignorevalue: props.changeignorevalue
}
}

Expand All @@ -23,19 +24,20 @@ export default class Actions extends React.PureComponent {
outputs: nextProps.outputs,
tests: nextProps.tests,
runexamples: nextProps.runexamples,
submitsolution: nextProps.submitsolution
submitsolution: nextProps.submitsolution,
changeignorevalue: nextProps.changeignorevalue
});
}

change(ele){
if(ele==null) return
ele.target.classList.toggle("icon-chevron-right")
ele.target.classList.toggle("icon-chevron-down")
var val = ele.target.parentElement.nextElementSibling.style.display
change(){
var ele = this.refs.chevronbutton
ele.classList.toggle("icon-chevron-right")
ele.classList.toggle("icon-chevron-down")
var val = this.refs.down.style.display
if(val=="flex"){
ele.target.parentElement.nextElementSibling.style.display = "none";
this.refs.down.style.display = "none";
}else{
ele.target.parentElement.nextElementSibling.style.display = "flex";
this.refs.down.style.display = "flex";
}
}

Expand Down Expand Up @@ -88,13 +90,22 @@ export default class Actions extends React.PureComponent {
return (
<div className="actions">
<h2 className="title titlename">{this.state.prob.index} - {this.state.prob.name}</h2>
<div className="addoption">
<div className="igcasediv">
<input ref="igcase" type="checkbox" name="igcase" checked={this.state.prob.ignorecase} onChange={this.state.changeignorevalue}/>
<span>Ignore case</span>
</div>
</div>
<div className="tasks">
<div className="task">
<div className="up">
<span onClick={this.change.bind(this)} className="icon icon-chevron-right">Examples</span>
<button className="actionbutton" onClick={this.state.runexamples}>Run all</button>
<span ref="chevronbutton" onClick={this.change.bind(this)} className="icon icon-chevron-right">Examples</span>
<button className="actionbutton" onClick={()=>{
this.state.runexamples()
this.refs.down.style.display = "flex"
}}>Run all</button>
</div>
<div className="down" style={{display: "none"}}>
<div ref="down" className="down" style={{display: "none"}}>
{this.state.tests && this.state.tests.map(test=>{
if(test.error){
if(test.stdout.length>0 && test.stderr.length>0) moredetails = <div className="errordetails"> <pre>{test.stdout}<br/>{test.stderr}</pre> </div>
Expand Down
1 change: 0 additions & 1 deletion lib/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Problems from './problems';
import config from '../config'
import cheerio from 'cheerio'
import Play from './play'
// import CodeforcesScraper from './codeforces-scraper';

function couple(x) {
if(x<10){
Expand Down
47 changes: 37 additions & 10 deletions lib/view/judge.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use babel';

class Judge {
constructor(){
constructor() {
this.ignorewhitespace = true;
}

clearstring(s){
clearstring(s) {
s = s.trim()
s = s.split("\n")
for (var i = 0; i < s.length; i++) {
Expand All @@ -14,19 +14,23 @@ class Judge {
return s.join("\n")
}

verify(exp, out){
verify(exp, out, ig) {
exp = this.clearstring(exp)
out = this.clearstring(out)
if(ig){
exp = exp.toUpperCase()
out = out.toUpperCase()
}
return exp == out
}

beautify(err){
beautify(err) {
err = err.trim()
err = err.split("\n")
var tmp = []
for (var i = 1; i < err.length; i++) {
if(err[i].length){
if(err[i].includes("File")){
if (err[i].length) {
if (err[i].includes("File")) {
err[i] = err[i].split(",")[1]
}
tmp.push(err[i].trim())
Expand All @@ -35,22 +39,45 @@ class Judge {

var sol = []
for (var i = 0; i < tmp.length; i++) {
if(i&1^1){
if (i & 1 ^ 1) {
sol.push(tmp[i])
}else{
sol[sol.length-1]+=" : " + tmp[i]
} else {
sol[sol.length - 1] += " : " + tmp[i]
}
}

var toreturn = []

for (var i = sol.length-1; i >=0 ; i--) {
for (var i = sol.length - 1; i >= 0; i--) {
toreturn.push(sol[i])
}

return toreturn.join("\n");
}

beautifycpp(err,fname){
const path = require('path');
err = err.trim()
err = err.split("\n")
var tmp = []
for (var i = 1; i < err.length; i++) {
if(err[i].length && err[i].includes("In function")==false){
err[i] = err[i].trim()
var idx = err[i].indexOf(fname)
if(idx==0){
err[i] = err[i].replace(fname,path.basename(fname))
var errarray = err[i].split(":")
if(errarray[2].trim()!="note"){
errarray[1]="Line "+errarray[1]
tmp.push(errarray.slice(1,).join(":").trim())
}
}
}
}

return tmp.join("\n")
}

}

export default new Judge();
4 changes: 3 additions & 1 deletion lib/view/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ export default class Play extends React.PureComponent {
fetchimage(){
fetch("https://source.unsplash.com/random/280x280").then(res=>{
this.setState({image: res.url})
this.refs.nextbutton.style.display = "initial";
}).catch(err=> {
this.setState({image: "https://images.unsplash.com/photo-1595496710086-d69bff2ccb19?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=280&ixlib=rb-1.2.1&q=80&w=280"})
this.refs.nextbutton.style.display = "initial";
})
}

Expand Down Expand Up @@ -175,7 +177,7 @@ export default class Play extends React.PureComponent {
})
})}
</div>
<button className="nextbutton" onClick={this.reset.bind(this)}>Next</button>
<button ref="nextbutton" className="nextbutton" style={{display: "none"}} onClick={this.reset.bind(this)}>Next</button>
</div>
</div>
)
Expand Down
Loading

0 comments on commit 74ec1e4

Please sign in to comment.