Moodle

How to install the execution server (vpl-jail-service 2.x) in Ubuntu

Orginal link:


Installing execution server on Ubuntu

Our tests indicate that the 32-bit version is more convenient than the 64 because the 32-bit implementation consumes less memory and CPU than the 64-bit version. The machine requirements are highly dependent on the software used, our experience is that a machine with only 2Gb of ram and 2 cores can support a class of 50 students online using Java.
The steps for installation and configuration are:
  1. Install an Ubuntu server as clean as possible
  2. Search for the latest software version browsing http://vpl.dis.ulpgc.es/releases. Look at vpl-jail-system-[version].tar.gz files and select the hightest version. From here replace [version] by the the version selected.
  3. Download the latest version of the software (vpl-jail-system) with the command
    • wget http://vpl.dis.ulpgc.es/releases/vpl_jail_system-[version].tar.gz
  4. Unzip and install the vpl-jail-system
    • tar -xvf vpl_jail_system-[version].tar.gz
    • cd vpl_jail_system-[version]
    • sudo ./install-vpl-sh
  5. Follow the instructions and wait for the necessary downloads. The installation script will try to install the development software commonly used, but you may need to install some other by hand.
  6. Stop the service with the command
    • sudo service vpl- jail-system stop
  7. Edit the file /etc/vpl/vpl-jail-system.conf. Set the URLPATH that will be used as key in connections with your execution server
  8. Start the service
    • sudo service vpl-jail-system start

Checking

You can check the availability of your execution server using the URL
http://server:PORT/OK and https://server:SECURE_PORT/OK
where server is the name of your execution server
The system must return a page with OK

Troubleshooting

You can obtain a detailed log of the service by starting it in debug mode with "service vpl-jail-system start -d 8". The logs will be written in "/var/log/syslog"

Using

The URL of the service in the general module configuration or in the local execution server settings of your Moodle server is
http://server:PORT/URLPATH or https://server:SECURE_PORT/URLPATH
:PORT and :SECURE_PORT can be omitted if using the standard ports.


File configurations:/etc/vpl/vpl-jail-system.conf.

The following  lines needs to change

URLPATH=/OK

#default 80
PORT=8001 ->in my case it is port 8001 as i am using port 80 for my website
#Socket port number to listen for secure connections (https: and wss:)
#default 443
SECURE_PORT=444
FIREWALL=0


after changing restart the vpl-jail-system service
If Your Server Working You can check  with the following port
http://192.168.15.254:8001/OK
It will return OK message.

Then go to
Moodle->Site administration->Plugins->Activity modules->Manage activities->Virtual programming lab->settings
Execution servers list

add the following 
http://192.168.15.254:8001/OK



How to remove Moodle Logo 



There are two solutions:
I. First (hack Moodle core):
  1. go to [moodle dir]\lib\outputrenderers.php
  2. find public function home_link()
  3. and replace it code:
    public function home_link() {
    global $CFG, $SITE;
    
    if ($this->page->pagetype == 'site-index') {
        // Special case for site home page - please do not remove
        return '';
    } else if (!empty($CFG->target_release) && $CFG->target_release != $CFG->release) {
        // Special case for during install/upgrade.
        return '';
    
    } else if ($this->page->course->id == $SITE->id || strpos($this->page->pagetype, 'course-view') === 0) {
        return '<div class="homelink"><a href="' . $CFG->wwwroot . '/">' .
                get_string('home') . '</a></div>';
    
    } else {
        return '<div class="homelink"><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $this->page->course->id . '">' .
                format_string($this->page->course->shortname, true, array('context' => $this->page->context)) . '</a></div>';
    }
    }
    
II. Second (simple hide logo):
  1. Add to your css file (for example "custom.css") next lines :
    .sitelink {
        display: none;
    }
https://stackoverflow.com/questions/28829194/how-to-remove-moodle-logo-in-version-2-8


-----------------------------------------------------------------------------------------------

importing Aiken Formatted Questions


Rather than creating individual questions in Moodle you can have multiple questions constructed in a text document that you can then import into Moodle. The Aiken Format provides you with an easy way to import multiple choice questions into Moodle.
1. Open the document that contains your multiple choice questions.
There are many different office programs and text editors available. For this particular tutorial we are going to concentrate on how to start in Microsoft Word and end in Moodle.

2. Format your document in the Aiken Format.
The Aiken format is a very simple way of creating multiple choice questions using a clear human-readable format. The question must be all on one line. Each answer must start with a capitalized single-letter character, followed by a period '.' or a bracket ')', then a space. Whichever you choose to use, it must be consistent thoughout the document. The answer line must immediately follow, starting with "ANSWER: " (NOTE: space after the colon, and all capitalized letters) and then provide the correct answer letter. To separate each question, place only one line space between each new question. Here is an example of the format:
NOTE: The answer letters (A,B,C etc.) and the word "ANSWER" must be capitalized as shown otherwise the import will fail.
NOTE: There must be a space in between the lettering and "." and the answer as shown otherwise the import will fail.

3. Save the file as a plain text file (.txt). When saving as a plain text file, you may see the following window. Choose "Other Encoding" for text, and then choose "UTF-8" as the option. Click OK.


4. Under the Settings Block, click on Question Bank >> Import.

5. Choose Aiken format for the file format type.

6. Expand the 'General' section. Choose the category you wish to import your questions into.

7. Choose the file you wish to import.
You may either drag and drop the file into Moodle or click on Choose a File and the file picker will come up. Navigate to the .txt file on your computer and choose to upload the file. The exam file title will appear in the box, click Import at the bottom.

8. Preview the import.
A list-style preview will appear after you click Import. You must click Continue to finish the import. If you have imported a file with a great deal of questions, you may have to scroll down the page to find the continue button.

9. Double Check your Questions.
Once the import is complete you will be able to see them in the category listings within the question bank. It is a good idea to double check your questions by randomly previewing a few to make sure they imported properly (question text and correct answers).

Troubleshooting
Often times if an Aiken formatted quiz fails to import, or if certain questions fail to import it is because of the formatting of the document or hidden special characters. Editors such as Microsoft Word often put special hidden characters into their documents. These cause problems during the import process. It is key to get everything into a plain text format. Copying and pasting into a plain text editor is helpful. In many plain text editors, there is a feature to format as plain text. This usually eliminates any special characters that could be causing import problems.

curtesy:http://moodleanswers.com/index.php/book-an-exam/89-importing-aiken-formatted-questions

-----------------------------------------------------------------------------------------
Bulk user action format

username  password  firstname  lastname  email
cs1 Y2QsgGKm  cs1 staff staff@test.com
cs2 hf64dPXC  cs2 staff staff@test.com
cs3 SHJpQx8U  cs3 staff staff@test.com
cs4 YBg39FcK   cs4 staff staff@test.com
cs5 s5qeT2xb  cs5 staff staff@test.com
cs6 qyJaw5jt  cs6 staff staff@test.com
cs7 wfULuC5Q  cs7 staff staff@test.com
cs8 YqUHyb4t  cs8 staff staff@test.com
cs9 w8EhFXkm  cs9 staff staff@test.com
cs10 btmA4wzx  cs10 staff staff@test.com
copy above lines and open excel and past as text.
save this excel file  as test.csv file and got to siteadministration->users->acounts->uploaduser
click on choose file and upload user

-----------------------------------

Moodle equation editing

https://docs.moodle.org/33/en/Using_TeX_Notation
----------------------------------------------------------------------------------------------------------------------

Exporting MySQL database from XAMPP 



  • by command line
backup: # 
  • by command line
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
  • or use phpmyadmin (usually installed with XAMP), or something like that and export it from browser
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql

  • or use phpmyadmin (usually installed with XAMP), or something like that and export it from browser
For Example:  #/opt/lampp/bin/mysqldump -u root -p moodle  >~/moodle.sql



https://stackoverflow.com/questions/14923150/exporting-mysql-database-from-xampp



C Program" question type  accept command line arguments in coderunner.



The template code below shows a simple example in which a Python question prototype is used to define a new question type c_via_python that mimics the built-in c_program question type but provides more flexibility. To create the new question type using this template:
  1. Create a new CodeRunner question.
  2. Choose the question type python3
  3. Click Customise
  4. Replace the contents of the Template text area with the template code below.
  5. Uncheck the Is combinator checkbox.
  6. Enter DEMO_PROTOTYPE_C_using_python as the question name
  7. Enter whatever text you wish to use to describe the question type in the Question text area. This text will be displayed to any authors using this new question type if they open the Question type details section of the question authoring form.
  8. Open Advanced Customisation
  9. Set Is prototype? to Yes (user defined)
  10. Set Question type to c_via_python.
  11. Set Ace language to c, so that the students' code will be edited as C even though the prototype is in Python.
  12. Save the question.
You should now find the new question type c_via_python appearing in the Question type dropdown of the author edit form for a new CodeRunner question. This new question type should behave like the built-in c_program question type but is more flexible; for example, it can easily be extended to perform checks on the submitted C code prior to compilation.
The full question prototype for the c_via_python question type is included in the samples folder of the CodeRunner distribution.

""" The template for a question type that compiles and runs a student-submitted
    C program. 
"""

import subprocess

# Write the student code to a file prog.c
student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
with open("prog.c", "w") as src:
    print(student_answer, file=src)

# Compile
{% if QUESTION.parameters.cflags is defined %}
cflags = """{{ QUESTION.parameters.cflags | e('py') }}"""
{% else %}
cflags = "-std=c99 -Wall -Werror"
{% endif %}
return_code = subprocess.call("gcc {0} -o prog prog.c".format(cflags).split())
if return_code != 0:
    print("** Compilation failed. Testing aborted **", file=sys.stderr)

# If compile succeeded, run the code. Since this is a per-test template,
# stdin is already set up for the stdin text specified in the test case,
# so we can run the compiled program directly.
if return_code == 0:
    try:
        output = subprocess.check_output(["./prog"], universal_newlines=True)
        print(output)
    except subprocess.CalledProcessError as e:
        if e.returncode > 0:
            # Ignore non-zero positive return codes
            if e.output:
                print(e.output)
        else:
            # But negative return codes are signals - abort
            if e.output:
                print(e.output, file=sys.stderr)
            if e.returncode < 0:
                print("Task failed with signal", -e.returncode, file=sys.stderr)
            print("** Further testing aborted **", file=sys.stderr) 
 
 
 
 
 
I attach a Moodle XML question export file containing a prototype using that template to define a  new question type C_prog_with_args . The file includes a single demo program. That one demo is the full extent of any testing I've done, so you might have to do some further tweaking.
If you wish to check that students aren't using particular functions like getchar, scanf etc you can simply add a bit of Python code to the template to see if the banned function names are present. This is a bit of hack (e.g. they might be present in comments) but is good enough for most cases, provided you warn the students. If you want to do the job properly you can use a C parser like pycparse.

Here's a screen shot of the demo program in action.


 https://coderunner.org.nz/mod/forum/discuss.php?d=85
 https://coderunner.org.nz/mod/book/view.php?id=193&chapterid=749
 

Comments

Popular posts from this blog