Skip to content

Commit

Permalink
setup + exemple
Browse files Browse the repository at this point in the history
  • Loading branch information
bnothomb committed Jul 1, 2019
0 parents commit 5d59eb7
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 0 deletions.
Binary file added 01_demo/faciledemo
Binary file not shown.
30 changes: 30 additions & 0 deletions 01_demo/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# A AMELIORER
import os
import subprocess
import shlex
from inginious import feedback
from inginious import input


if __name__ == "__main__":
os.chdir("student")
input.parse_template("student_code.py.tpl", "student_code.py")

p = subprocess.Popen(shlex.split("python3 test.py"), stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
make_output = p.communicate()[0].decode('utf-8')

if p.returncode:
feedback.set_global_result("failed")
feedback.set_global_feedback("La compilation de votre code a échoué. Voici l'erreur:" + make_output)
exit(0)
elif "True" in make_output:
feedback.set_global_result("success")
feedback.set_global_feedback("Vous avez résolu l'exercice.")
feedback.set_problem_feedback("Bien","thecode") #attention! thecode est l'id de la sous-question
else:
feedback.set_global_result("failed")
feedback.set_global_feedback("Vous n'avez pas résolu cette instance")
feedback.set_problem_feedback(make_output,"thecode")
36 changes: 36 additions & 0 deletions 01_demo/solution/Q1Aout2018corr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import math

def arret(but):
hb,lb,lg=0,0,0
output=[0,0,0]
for h in range(len(but)): #until H
for l in range(len(but[0])): #until L
if but[h][l]=='B':
hb,lb=h,l
elif but[h][l]=='G':
hg,lg=0,l
# //Gestion de la direction
if lb<lg:
output[0]=-1.0
else:
if (lg!=lb):
output[0]=1.0

#Calcul de la distance
output[2]=math.sqrt((hb**2)+(lg-lb)**2)

#Calcul de l'angle

if (lg==lb):
output[1]=90
else:
output[1]=math.degrees(math.atan(hb/(abs(lg-lb))))
return output

H=10
L=20
BUT=[['X' for j in range(0,L)] for i in range(0,H)]
BUT[6][5]='G'
BUT[3][14]='B'
res=arret(BUT)
print("Je saute en direction {} avec un angle de {} sur une distance de {}".format(res[0],res[1],res[2]))
5 changes: 5 additions & 0 deletions 01_demo/student/student_code.py.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import math

def arret(but):
@ @thecode@@

43 changes: 43 additions & 0 deletions 01_demo/student/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from student_code import arret
import math

def arret_good(but):
hb,lb,lg=0,0,0
output=[0,0,0]
for h in range(len(but)): #until H
for l in range(len(but[0])): #until L
if but[h][l]=='B':
hb,lb=h,l
elif but[h][l]=='G':
hg,lg=0,l
# //Gestion de la direction
if lb<lg:
output[0]=-1.0
else:
if (lg!=lb):
output[0]=1.0

#Calcul de la distance
output[2]=math.sqrt((hb**2)+(lg-lb)**2)

#Calcul de l'angle

if (lg==lb):
output[1]=90
else:
output[1]=math.degrees(math.atan(hb/(abs(lg-lb))))
return output


if __name__ == "__main__":
H=10
L=20
BUT=[['X' for j in range(0,L)] for i in range(0,H)]
BUT[6][5]='G'
BUT[3][14]='B'
res=arret(BUT)
res_good = arret_good(BUT)
if res == res_good:
print("True")
else:
print("La bonne réponse B en [3][14] et G en [6][5] est la direction {} avec un angle de {} sur une distance de {}".format(res_good[0],res_good[1],res_good[2]))
28 changes: 28 additions & 0 deletions 01_demo/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
accessible: true
author: Bastien NOTHOMB
context: |-
Demo
environment: default
evaluate: best
groups: false
limits:
time: '3'
memory: '100'
output: '2'
name: 1. Getting started
network_grading: false
order: 0
problems:
thecode:
name: Hello World !
language: python
type: code
header: |-
Here you are asked to provide a basic Python 3 program displaying ``Hello World!`` on standard output.
*Hint :* to display something on standard output, use the built-in ``print`` method.
stored_submissions: 0
submission_limit:
amount: -1
period: -1
weight: 1.0
30 changes: 30 additions & 0 deletions 01_demo/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# A AMELIORER
import os
import subprocess
import shlex
from inginious import feedback
from inginious import input


if __name__ == "__main__":
os.chdir("student")
input.parse_template("student_code.tpl.py", "student_code.py")

p = subprocess.Popen(shlex.split("python3 student_code.py"), stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
make_output = p.communicate()[0].decode('utf-8')

if p.returncode:
feedback.set_global_result("failed")
feedback.set_global_feedback("La compilation de votre code a échoué. Voici l'erreur:" + make_output)
exit(0)
elif "True" in make_output:
feedback.set_global_result("success")
feedback.set_global_feedback("Vous avez résolu l'exercice.")
feedback.set_problem_feedback("Bien","code") #attention! code est l'id de la sous-question
else:
feedback.set_global_result("failed")
feedback.set_global_feedback("Vous n'avez pas résolu cette instance")
feedback.set_problem_feedback(make_output,"code")
4 changes: 4 additions & 0 deletions course.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: '[OW2019] Tasks'
admins:
- superadmin

0 comments on commit 5d59eb7

Please sign in to comment.