Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 84838b60 authored by Matthieu Moy's avatar Matthieu Moy
Browse files

Obsolete

parent bc0a6c8a
Pipeline #56292 failed with stage
in 2 minutes and 19 seconds
Copyright ou © ou Copr. Sébastien Viardot and Matthieu Moy (2016)
Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
Ce logiciel est un programme informatique servant à interagir avec le
logiciel Chamilo.
Ce logiciel est régi par la licence CeCILL soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".
En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.
A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
Copyright or © or Copr. Sébastien Viardot and Matthieu Moy (2016)
Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
This software is a computer program whose purpose is to interact with
the Chamilo LMS from a client computer.
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
This diff is collapsed.
This diff is collapsed.
PY = ${shell git ls-files '*.py'} chamilotools
USER =
COURSE =
INSTANCE =
OPTIONS =
CONFIG = config.mk
-include $(CONFIG)
.PHONY: static test check interactive quick
quick: static test
.NOTPARALLEL: check
check: quick interactive
static:
for f in $(PY); do \
python -m py_compile $$f || { echo; echo $$f; status=1; } \
done; exit $$status
pep8 $(PY) --max-line-length=125 --ignore=E402
pyflakes $(PY)
test:
./test/testCreateQuizChamilo.py
interactive:
env USER=$(USER) COURSE=$(COURSE) INSTANCE=$(INSTANCE) OPTIONS="$(OPTIONS)" \
./test/interactive_tests.sh
# Chamilo tools
# Obsolete location for chamilotools
Chamilo tools is a set of tools to interact with a
[Chamilo](https://chamilo.org/) server without using your browser.
Right now, the main commands are:
* `chamilotools upload-zip FILE.zip`: to upload the content of your course
in one command.
* `chamilotools set-intro INTRO.html`: to set the introduction text
from a local file.
* `chamilotools create-quiz`: to write quiz (Exercices)
offline in a XLS file or a [Yaml](http://yaml.org/) file, and upload
it to Chamilo in one command. Some
[documentation](doc/create-quizz.md) is available.
It has initially been written by and for Ensimag teachers, but should
work for any Chamilo installation. It is tested both on Ensimag's
installation and on https://campus.chamilo.org/. Patches to make the
tools more generic and let them work in more contexts are welcome.
Chamilotools also contain a deprecated shell script `setChamilo` that
does the same as `upload-file` and `set-intro`.
# Installation and first step
To install Chamilotools:
* Make sure you have Python 2.7 installed (2.7.x required,
chamilotools does not work with Python 2.6 nor Python 3).
* Install dependencies:
```
pip install --user git+https://github.com/hickford/MechanicalSoup
pip install --user mediawiki xlrd xlwt BeautifulSoup pyyaml HTMLParser six
```
* Download Chamilotools
(`git clone https://gitlab.com/chamilotools/chamilotools.git` or
download ZIP [here](https://gitlab.com/chamilotools/chamilotools/repository/archive.zip?ref=master)).
* Run `./chamilotools --help`.
# Configuration
chamilotools uses two configuration files:
* A per-user configuration file, located in
`~/.config/chamilotools/config.yml`, meant to store your username.
* A per-project configuration file, located in `./.chamilotools.yml`,
`../.chamilotools.yml`, `../../.chamilotools.yml`, etc. It is meant
to store the course name and the Chamilo instance.
Configuration files are Yaml files. Currently, the only content
allowed in configuration files is (insert actual value instead of
`...` obviously):
```
username: ...
instance: ...
course: ...
```
These 3 keys provide default values for, respectively, `-u`,
`--instance` and `-c`. When the command-line options are specified,
the corresponding value from the configuration file is ignored.
# Creating Quizz (or test, or exercices)
Introduction: [create-quizz.md](doc/create-quizz.md)
The Yaml format: [yaml-syntax.md](doc/yaml-syntax.md)
Different syntax available in quiz: [syntax.md](doc/syntax.md)
Types of questions: [question-types.md](doc/question-types.md)
# Commands Related to Quiz
To get more information about each command, run
`chamilotools <command> --help`.
* `chamilotools create-quiz`: Upload a quiz (exercise) from a local file.
See [doc/create-quizz.md](doc/create-quizz.md) for details.
* `chamilotools list-quiz`: List quiz available on a course.
* `chamilotools delete-quiz`: Delete a quiz remotely from the
command-line. Specify which quiz to delete with `--exercise-id` or
`--all` (dangerous ...).
* `chamilotools download-quiz`: Downloads the quiz in XML format. Note
that chamilotools can currently not read this XML file.
* `chamilotools check-quiz`: Checks a quiz for syntax errors, without
sending it to Chamilo.
# Commands Related to Introduction
* `chamilotools set-intro INTRO.html`: to set the introduction text
from a local file.
* `chamilotools get-intro`: Get the introduction text from Chamilo.
# Commands Related to Documents
* `chamilotools upload-zip FILE.zip`: to upload the content of your
course in one command. Warning: on most versions of Chamilo, if the
destination directory already exist, the new is unziped in a new
location (e.g. the ZIP file contains `my_directory`, but
`my_directory` already exists: the new files will be created in
`my_directory_1` and the old files won't be modified). You may want
to use the (dangerous) command `chamilotools delete-doc` before
using `upload-zip`. More [here](https://support.chamilo.org/issues/8416).
* `chamilotools upload-file FILE`: to upload a single file to Chamilo.
If the file already exists on Chamilo, the new file will overwrite
the old one.
* `chamilotools delete-doc FILE`: Delete the file `FILE` on Chamilo.
The command can currently only delete files at the toplevel
directory (not in subdirectories).
Warning: this is an experimental feature and may be buggy (i.e. we
try hard not to, but it may delete the wrong file). As a safety
measure, `delete-doc` does a first pass where it looks for the
filename in a relatively strict way. Use `--fuzzy-file-name` to
allow a second pass where only the basename is used. For example,
`delete-doc --fuzzy-file-name index` will delete `index.html`, but
may also delete `index.pdf` or any file whose basename is `index`.
Another safety measure is that if more than one matching file is
found, `delete-doc` stops and does not delete anything.
* `chamilotools get-doc FILENAME`: Download the document `FILENAME`
from Chamilo. `FILENAME` can be a full path like `path/to/file.txt`.
# Other commands
* `chamilotools version`: Get the version number of chamilotools.
* `chamilotools --help` (or `chamilotools <command> --help`): Get help.
# Troubleshooting and debugging
A few hints if Chamilotools do not work as you expect:
* Try running with `-vv` (or `-v -v`). You will see each URL visited
by chamilotools.
* Try running with `--debug`. A browser will be launched on the
current page if chamilotools encourters an error.
* If it is not sufficient, adding `br.launch_browser()` statements in
the code to launch a browser at different steps.
* Don't hesitate to report bugs ;-).
# Scripting `chamilotools`
A common use of `chamilotools` is to use it in scripts, Makefiles,
cron job, ... A few advices on how to do this is available here:
[scripting.md](doc/scripting.md).
Chamilotools latest version is available at https://gricad-gitlab.univ-grenoble-alpes.fr/chamilotools/chamilotools.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright or © or Copr. Sébastien Viardot and Matthieu Moy (2016)
#
# Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
#
# This software is a computer program whose purpose is to interact with
# the Chamilo LMS from a client computer.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
from __future__ import absolute_import
from .ChamiloInstance import ChamiloInstance
class CampusChamiloInstance(ChamiloInstance):
def __init__(self):
super(CampusChamiloInstance, self).__init__("https://campus.chamilo.org")
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright or © or Copr. Sébastien Viardot and Matthieu Moy (2016)
#
# Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
#
# This software is a computer program whose purpose is to interact with
# the Chamilo LMS from a client computer.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
from ChamiloInstance import (ChamiloInstance, MIMETEX)
class ChamiloDevGrenetChamiloInstance(ChamiloInstance):
def __init__(self):
super(ChamiloDevGrenetChamiloInstance, self).__init__("http://chamilodev.grenet.fr/chamilo-uga-1910/")
def get_url_login(self):
return "http://chamilodev.grenet.fr/chamilo-uga-1910/"
def get_math_engine(self):
return MIMETEX
def get_url_mimetex(self):
return "http://chamilodev.grenet.fr/cgi-bin/mimetex.cgi"
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright or © or Copr. Sébastien Viardot and Matthieu Moy (2016)
#
# Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
#
# This software is a computer program whose purpose is to interact with
# the Chamilo LMS from a client computer.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
import importlib
from chamilolib.chamiloBrowser import ChamiloBrowser
from chamilolib.utilities import (
display_html,
AuthenticationError
)
MIMETEX = 0
MATHJAX = 1
class ChamiloInstance(object):
def __init__(self, url):
self.url_base = url
self.br = None
@staticmethod
def build_instance(name):
assert(name and name != '')
klass_name = name + "ChamiloInstance"
try:
module = importlib.import_module(
'chamilolib.' + klass_name)
klass = getattr(module, klass_name)
return klass()
except (ImportError, AttributeError):
pass
if klass_name in globals():
klass = globals()[klass_name]
return klass()
return None
def create_browser(self, o):
br = ChamiloBrowser()
br.set_debug(o.debug)
br.set_verbose(o.verbose)
self.br = br
return br
def connect(self, o):
br = self.create_browser(o)
br.open(self.get_url_login())
login_form = br.select_form('#formLogin')
login_form.input({'login': o.username, 'password': o.password})
response = br.submit_selected()
html = response.soup.encode()
if "user_password_incorrect" in br.geturl():
display_html(html, "Invalid login or password")
raise AuthenticationError()
elif o.verbose >= 2:
print("login successful")
self.br = br
return br
def disconnect(self, br=None):
if br is not None:
br = self.br
if br is None:
return
br.follow_link(url_regex="index.php\?logout=logout")
def get_url_login(self):
return self.get_url_base() + "/login"
def get_url_base(self):
"""Base URL of the Chamilo instance"""
return self.url_base
def get_url_course(self, course):
"""URL for individual course"""
return self.get_url_base() + "/courses/" + course + "/"
def get_entry_url_course(self, course):
"""Entry URL for individual course. This may differ from
get_url_course() if the user is expected to visit another
URL before entering the course."""
return self.get_url_course(course)
def get_math_engine(self):
"""Return the type of engine used to render Math."""
return MATHJAX
def get_url_mimetex(self):
"""If the math engine is MIMETEX, return the URL to the mimetex
installation."""
raise NotImplementedError()
def has_double_escaping_bug(self):
"""Some instance of Chamilo un-HTML-escape the input we give them,
hence we need to double-escape the text as a workaround.
Return True if this is the case."""
return False
def text_field_width(self, nb_chars):
"""In 'text to be completed' type questions, we guess the size of
the text field, in pixels, based on the expected input (in characters).
Depending on the local CSS, the optimal width may vary.
Return the width in pixels of the text input field."""
# Based on display on campus.chamilo.org: 12 pixels padding +
# 1 pixel width on each side = 26 pixels lost, plus 10 pixels
# per character.
return nb_chars * 10 + 26
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright or © or Copr. Sébastien Viardot and Matthieu Moy (2016)
#
# Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
#
# This software is a computer program whose purpose is to interact with
# the Chamilo LMS from a client computer.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
from SimsuChamiloInstance import SimsuChamiloInstance
class GrenobleINPChamiloInstance(SimsuChamiloInstance):
def __init__(self):
super(GrenobleINPChamiloInstance, self).__init__("http://chamilo2.grenet.fr/inp")
def get_url_agalan(self):
return "https://cas-simsu.grenet.fr/login"
def get_url_mimetex(self):
return "http://chamilo2.grenet.fr/cgi-bin/mimetex.cgi"
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright or © or Copr. Sébastien Viardot and Matthieu Moy (2016)
#
# Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
#
# This software is a computer program whose purpose is to interact with
# the Chamilo LMS from a client computer.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
from GrenobleINPChamiloInstance import GrenobleINPChamiloInstance
from ChamiloInstance import ChamiloInstance
class GrenobleINPNoCasChamiloInstance(GrenobleINPChamiloInstance):
def __init__(self):
super(GrenobleINPChamiloInstance, self).__init__("http://chamilo2.grenet.fr/inp/")
connect = ChamiloInstance.connect
def get_url_login(self):
# Warning: the trailing slash seems mandatory
return "http://chamilo2.grenet.fr/inp/"
def get_url_agalan(self):
return NotImplementedError()
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Copyright or © or Copr. Sébastien Viardot and Matthieu Moy (2016)
#
# Matthieu.Moy@grenoble-inp.fr, Sebastien.Viardot@grenoble-inp.fr
#
# This software is a computer program whose purpose is to interact with
# the Chamilo LMS from a client computer.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only