wims-moodle-4.0.orig/0000755000175000017500000000000012125612434014746 5ustar georgeskgeorgeskwims-moodle-4.0.orig/localwims.template0000644000175000017500000000234212125602510020470 0ustar georgeskgeorgesk# This is an example of identification file for connection to another # platform. It is used for platform authentification. # If you copy this file to another one in the same directory, # and modify the definitions, you get another platform identification # whose name is the name of that file. # calling the same WIMS server. # For security reasons, it is highly recommended that you only accept # localhost connections. Accept several sites, but no wildcard. ident_site=127.0.0.1 # Short description ident_desc=This local WIMS server # User agent of the connecting platform must identify itself as such. #ident_agent=WIMS-webget # if ident_agent is void, there will be no check. ident_agent= # https is highly recommended for security. ident_protocol=https # password must be a word composed of alpha-numeric characters. # This identification is disabled by the * in the password definition. ident_password=secret # type of remote platform. # available types: wims. ident_type=wims # The address and identifier/password pair for calling back. back_url=https://localhost/wims/wims.cgi back_ident=myself back_password=*** # allowed or disabled requests. At most one of the two should be active. # ident_allow= # ident_deny=deluser delclass wims-moodle-4.0.orig/etc/0000755000175000017500000000000011243735771015533 5ustar georgeskgeorgeskwims-moodle-4.0.orig/etc/moodle/0000755000175000017500000000000011417103666017005 5ustar georgeskgeorgeskwims-moodle-4.0.orig/etc/moodle/wimsconf.php0000644000175000017500000000074111417103666021345 0ustar georgeskgeorgeskwimshost="localhost"; // the IP address for the Wims server $CFG->wimsroot="wims"; // URL = "http://".$CFG->wimshost."/".$CFG->wimsroot $CFG->wimsRemoteUrl="https://wims.url.domain"; // the external URL for Wims $CFG->protocol="localwims"; // the name of the configuration file for Wims // this file is in ${WIMS_HOME}/log/classes/.connections/ , with the following password. $CFG->passwims="azerty"; // a shared secret ?>wims-moodle-4.0.orig/mod/0000755000175000017500000000000012124335542015526 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/0000755000175000017500000000000012124335542017676 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/0000755000175000017500000000000012124335542020657 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/0000755000175000017500000000000012125610641021633 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/backup/0000755000175000017500000000000012124335542023103 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/backup/moodle1/0000755000175000017500000000000012124335542024443 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/backup/moodle1/lib.php0000644000175000017500000000241212122347300025712 0ustar georgeskgeorgesk. /** * @package assignment * @subpackage online subplugin * @copyright 2011 onwards Aparup Banerjee (nebgor) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * A dummy class for online conversions. * The online subplugin doesn't really need anything converted. * See the moodle1_assignment_subplugin_handler class. */ class moodle1_mod_assignment_wims_subplugin_handler extends moodle1_assignment_subplugin_handler { /** * Override the append_subplugin_data($data) method here for plugin specific processing. */ } wims-moodle-4.0.orig/mod/assignment/type/wims/wimsclass.php0000644000175000017500000002026712123071024024352 0ustar georgeskgeorgesklibdir.'/datalib.php'); // for get_record(...) /** * The class wc_data encapsulates the format of the request necessary * to create a Wims class. * @author: Georges Khaznadar * * initialisation: wc_data($rclass,$service,$servicepass) * parameters: * * $rclass is the name of the class in Moodle * * There must be a file wimshome/log/classes/.connections/$service * * with a line defining: 'ident_password=$servicepass' * * an accessor: toString($html=1) * this function outputs a string with the object's internals. * parameters: * $html, when true, fits the output to be displaied in a HTML page. * * two functions: data1() and data2() * these functions prepare the data for the Wims class according to the * documentation file http://wims.unice.fr/wims/?module=adm/raw&job=help **********************************************************************/ class wc_data{ var $description; var $institution; var $firstname; var $lastname; var $supervisor; var $email; var $password; var $lang; var $expiration; var $limit; var $secure; var $qclass; var $service; var $servicepass; function wc_data($assignment,$service,$servicepass){ global $DB; $this->service=$service; $this->servicepass=$servicepass; $this->description=rclass($assignment); // $c1=get_record("course","id",1); $c1=$DB->get_record("course",array("id"=>1)); //Recuperation du nom du site moodle $this->institution=protection($c1->shortname); $context = get_context_instance(CONTEXT_COURSE, $assignment->course); $teacherID=3; // 3 is the id for teachers. $users = get_role_users($teacherID, $context, true, '', 'u.lastname ASC', true); $firstuser=array_shift($users); $tid=$firstuser->id; // $t=get_record("user","id",$tid); $t=$DB->get_record("user",array("id"=>$tid)); $this->firstname=$t->firstname; $this->lastname=$t->lastname; $this->supervisor=$t->username; $this->email=$t->email; $this->password=random_string(8); $this->lang=ereg_replace("_.*","",$t->lang); $now=time(); $this->expiration=(date('Y',$now)+1).date('md',$now); $this->limit="499"; $this->secure="all"; $this->qclass=""; } function toString($html=1){ if ($html) $spacer="
"; else $spacer=" "; $result=""; $result.="description = ".$this->description.$spacer; $result.="institution = ".$this->institution.$spacer; $result.="firstname = ".$this->firstname.$spacer; $result.="lastname = ".$this->lastname.$spacer; $result.="supervisor = ".$this->supervisor.$spacer; $result.="password = ".$this->password.$spacer; $result.="lang = ".$this->lang.$spacer; $result.="expiration = ".$this->expiration.$spacer; $result.="limit = ".$this->limit.$spacer; $result.="secure = ".$this->secure.$spacer; return $result; } function data1(){ $d1=array('description', 'institution', 'supervisor', 'email', 'password', 'lang', 'expiration', 'limit', 'level', 'secure', 'bgcolor', 'refcolor', 'css'); $data1=""; foreach ($d1 as $d){ if (isset($this->$d) && strlen($this->$d)>0){ $data1.=$d."=".$this->$d."\n"; } } return urlencode($data1); } function data2(){ $d2=array('lastname', 'firstname', 'useremail', 'comment', 'regnum'); $data2=""; foreach ($d2 as $d){ if (isset($this->$d) && strlen($this->$d)>0){ $data2.=$d."=".$this->$d."\n"; } } $data2.="password=".random_string(8)."\n";// this password will not be used return urlencode($data2); } } /** * makes a name for the "Wims class" on Moodle's side */ function rclass($assignment){ global $DB; //$c=get_record("course","id",$assignment->course); v1.9 moodle $c=$DB->get_record("course",array("id"=>($assignment->course))); return rclassFromCourseAndModule($c,$assignment); } function rclassFromCourseAndModule($c,$m){ return wimsIconv($c->shortname)."_".wimsIconv($m->name); } /** * protects a worksheet's contents before calling the job addsheet */ function protectSheetContents($contents){ $contents=str_replace("\n",";",$contents); $contents=str_replace("=","@",$contents); return $contents; } /** * the class workSheet encapsulates pentuples (index,title,status,rclass,qclass) * AFAIK, the status are the following with WIMS : * 0 = in preparation * 1 = active worksheet * 2 = unactive worksheet * 3 = hidden worksheet */ class workSheet{ var $index; var $title; var $status; var $rclass; var $qclass; var $rclassEnc; /** * the constructor */ function workSheet($index,$title,$status,$rclass,$qclass){ $this->index=$index; $this->title=$title; $this->status=$status; $this->rclass=$rclass; $this->qclass=$qclass; $this->rclassEnc=urlencode($rclass); } /** * @return an url to get the worksheet's file * @param $jr : a job_raw object already initialized */ function getUrl($jr){ $url=$jr->url("getclassfile", "qclass=$this->qclass&rclass=$this->rclassEnc". "&option=sheets/.sheet".$this->index); return $url; } /** * @return an url to add the worsheet's contents to * a wims assignment's miniclass. * @param $assign_wims the wims assignment * @param $forbidMD5sums an array of already present md5 sums of contents */ function addsheetToUrl($assign_wims, $forbidMD5sums=array()){ global $CFG; global $DB; $contents=$this->contents($assign_wims->jr); $md5=md5($contents); if (array_intersect($forbidMD5sums,array($md5))) return ""; $contents=protectSheetContents($contents); $qclass=$assign_wims->assignment->var2; $course= $DB->get_record("course", array("id"=>$assign_wims->cm->course)); $rclass=rclassFromCourseAndModule($course, $assign_wims->cm); $rclassEnc=urlencode($rclass); $parms="qclass=$qclass&rclass=$rclassEnc&data1=" . urlencode("contents=$contents\nsheetmode=3\ntitle=$this->title\n"); $url=$assign_wims->jr->url("addsheet",$parms); return $url; } /** * @return the contents of the worksheet's file * @param $jr : a job_raw object already initialized */ function contents($jr){ global $CFG; $url=$this->getUrl($jr); $url=urlencode($url); $url=$CFG->wwwroot."/mod/assignment/type/wims/getsheetsource.php?url=$url"; $f=fopen($url,"r"); if($f){ $contents=fread($f,20480); fclose($f); } else { $contents=""; } return $contents; } } /** * the class wimsExam encapsulates quadruples (index,title,rclass,qclass) * AFAIK, the status are the following with WIMS : * 0 = in preparation * 1 = active exam * 2 = unactive exam * 3 = hidden exam */ class wimsExam{ var $index; var $i; var $title; var $rclass; var $qclass; var $rclassEnc; /** * the constructor */ function wimsExam($index,$title,$rclass,$qclass){ $this->index=$index; $this->i=substr($index,4,255); // the number after "exam" $this->title=$title; $this->rclass=$rclass; $this->qclass=$qclass; $this->rclassEnc=urlencode($rclass); } function wimsButton($user){ $result="here should be button to access the exam ".$this->title; print "debug user:
";print_r($user->lastname);; print "
"; return $result; } } /** * converts utf8 strings for WIMS * @param s the input string * @return a string recoded for Wims */ function wimsIconv($s,$mode="forth"){ $r=$s; $wims_is_not_utf8=TRUE; if($wims_is_not_utf8 && function_exists('iconv')){ if ($mode=="forth") $r=iconv('UTF-8','ISO8859-1',$s); else $r=iconv('ISO8859-1','UTF-8',$s); // $mode=='back' for instance } return protection($r); } /******** * protects some names which are not allowable as an rclass for Wims * @param $s input string * @return the protected string */ function protection($s){ for ($i=0; $i wims-moodle-4.0.orig/mod/assignment/type/wims/file.php0000644000175000017500000000541012123061576023270 0ustar georgeskgeorgeskset_url('/mod/assignment/type/wims/file.php', array('id'=>$id, 'userid'=>$userid)); if (! $cm = get_coursemodule_from_id('assignment', $id)) { print_error('invalidcoursemodule'); } if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance))) { print_error('invalidid', 'assignment'); } if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) { print_error('coursemisconf', 'assignment'); } if (! $user = $DB->get_record("user", array("id"=>$userid))) { print_error('usermisconf', 'assignment'); } require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', $context)) { print_error('cannotviewassignment', 'assignment'); } if ($assignment->assignmenttype != 'wims') { print_error('invalidtype', 'assignment'); } $assignmentinstance = new assignment_wims($cm->id, $assignment, $cm, $course); if ($submission = $assignmentinstance->get_submission($user->id)) { $PAGE->set_pagelayout('popup'); $PAGE->set_title(fullname($user,true).': '.$assignment->name); echo $OUTPUT->header(); echo $OUTPUT->box_start('generalbox boxaligcenter', 'dates'); echo ''; if ($assignment->timedue) { echo ''; echo ' '; } echo ''; echo ' '; } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')'; } echo '
'.get_string('duedate','assignment').':'.userdate($assignment->timedue).'
'.get_string('lastedited').':'.userdate($submission->timemodified); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')
'; echo $OUTPUT->box_end(); $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $context->id, 'mod_assignment', $assignmentinstance->filearea, $submission->id); echo $OUTPUT->box(format_text($text, $submission->data2, array('overflowdiv'=>true)), 'generalbox boxaligncenter boxwidthwide'); echo $OUTPUT->close_window_button(); echo $OUTPUT->footer(); } else { print_string('emptysubmission', 'assignment'); } wims-moodle-4.0.orig/mod/assignment/type/wims/wimsconf.php0000644000175000017500000000073612125610641024177 0ustar georgeskgeorgeskwimshost="localhost"; // the IP address for the Wims server $CFG->wimsroot="wims"; // URL = "http://".$CFG->wimshost."/".$CFG->wimsroot $CFG->wimsRemoteUrl="localhost"; // the external URL for Wims $CFG->protocol="localwims"; // the name of the configuration file for Wims // this file is in ${WIMS_HOME}/log/classes/.connections/ , with the following password. $CFG->passwims="azerty"; // a shared secret ?> wims-moodle-4.0.orig/mod/assignment/type/wims/wims_raw.php0000644000175000017500000001440312123071022024166 0ustar georgeskgeorgeskserver. * */ class job_raw{ var $server; var $root; var $service; var $servicepass; var $debug; var $data; var $qclass; var $ok; function job_raw($server,$root,$service,$servicepass){ $this->server=$server; $this->root=$root; $this->service=$service; $this->servicepass=$servicepass; $this->qclass=""; $this->debug=0; $this->ok=0; $this->code=""; } function wimslogin($login){ // clean some chars which are not allowed by wims return str_replace(".","0",$login); } function url($which,$parms=""){ $this->code=random_string(3); $url="https://".$this->server."/".$this->root. "/wims.cgi?module=adm/raw&job=".$which. "&code=".$this->code. "&ident=".$this->service. "&passwd=".$this->servicepass; if (strlen($parms)>0) $url.= "&".$parms; if ($this->debug > 0) print(" parms = $parms
url = $url
"); return $url; } function job($which,$parms=""){ $url=$this->url($which,$parms); if ($this->debug > 0) print("
url = ".$url."
"); $f=fopen($url,"r"); if ($f){ $this->data=fread($f,2048); fclose($f); } else { $this->data="Error: could not open $url"; } $e=explode("\n",$this->data); // $this->ok=($e[0]=="OK ".$this->code); if($e[0]=="OK ".$this->code){ $this->ok=1;} else{ $this->ok=0; } if ($this->debug > 0) print("
ok = ".$this->ok."
"); return $e; } function help(){ return $this->job("help"); } function checkident(){ return $this->job("checkident"); } function checkclass($qcl,$rcl){ $this->qclass=$qcl; $parms="qclass=".urlencode($qcl)."&rclass=".urlencode($rcl); return $this->job("checkclass",$parms); } function getclass($qcl,$rcl){ $this->qclass=$qcl; $parms="qclass=".urlencode($qcl)."&rclass=".urlencode($rcl); return $this->job("getclass",$parms); } function addclass($wc,$rcl){ // The queried class will always be a new class number, choosen randomly // Warning: the random value might collide with an already existing class // TODO: make this function safer ! $qcl=rand(1000000,9999999); $parms="data1=".$wc->data1(). "&data2=".$wc->data2(). "&qclass=".urlencode($qcl)."&rclass=".urlencode($rcl); return $this->job("addclass",$parms); } function authuser($qcl,$rcl,$login){ $parms="qclass=".$qcl."&rclass=".urlencode($rcl)."&quser=".$this->wimslogin($login); return $this->job("authuser",$parms); } function get_class($qcl,$rcl){ //getclass is a forbidden name in PHP? $parms="qclass=".$qcl."&rclass=".urlencode($rcl); return $this->job("getclass",$parms); } function del_class($qcl,$rcl){ //delclass may be forbidden too? $parms="qclass=".$qcl."&rclass=".urlencode($rcl); return $this->job("delclass",$parms); } function adduser($qcl,$rcl,$firstname,$lastname,$login){ $password=random_string(8); // this password is not useful $data1=urlencode("firstname=".$firstname. "\nlastname=".$lastname. "\npassword=".$password."\n"); $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $parms.="&data1=".$data1."&quser=".$this->wimslogin($login); return $this->job("adduser",$parms); } function deluser($qcl,$rcl,$login){ $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $parms.="&quser=".$this->wimslogin($login); return $this->job("deluser",$parms); } function getuser($qcl,$rcl,$login){ $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $parms.="&quser=".$this->wimslogin($login); return $this->job("getuser",$parms); } function getscore($qcl,$rcl,$login){ $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $parms.="&quser=".$this->wimslogin($login); return $this->job("getscore",$parms); } function getsheet($qcl,$rcl,$login,$sheet,$format="mean"){ $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $parms.="&quser=".$this->wimslogin($login)."&qsheet=".$sheet."&format=".$format; return $this->job("getsheet",$parms); } function addsheet($qcl,$rcl,$contents="",$sheetmode="0",$title="",$description="",$expiration=""){ $contents=str_replace("\n",";",$contents); $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $data1=""; if ($title!="") $data1.=urlencode("title=$title\n"); if ($description!="") $data1.=urlencode("description=$description\n"); if ($expiration!="") $data1.=urlencode("expiration=$expiratiion\n"); if ($contents!="") $data1.=urlencode("contents=$contents\n"); if ($sheetmode!="0") $data1.=urlencode("sheetmode=$sheetmode\n"); $parms.="&data1=$data1"; return $this->job("addsheet",$parms); } function listsheets($qcl,$rcl){ $parms="qclass=".$qcl."&rclass=".urlencode($rcl); return $this->job("listsheets",$parms); } function getcsv($qcl,$rcl,$option=""){ // this primitive does not reply "OK" at the first line, since it is // designed to output a valid csv file. $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $parms.="&option=".$option; $url=$this->url("getcsv",$parms); $f=fopen($url,"r"); if ($f){ $this->data=fread($f,204800); fclose($f); $this->ok=1; } else { $this->data="Error: could not open $url"; $this->ok=0; } return explode("\n",$this->data); } function getclassfile($qcl,$rcl,$option=""){ $parms="qclass=".$qcl."&rclass=".urlencode($rcl); $parms.="&option=".$option; return $this->job("getclassfile",$parms); } } ?> wims-moodle-4.0.orig/mod/assignment/type/wims/version.php0000644000175000017500000000231612122347720024035 0ustar georgeskgeorgesk. /** * Version details * * @package assignment * @subpackage wims * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2013031500; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2011112900; // Requires this Moodle version $plugin->component = 'assignment_wims'; // Full name of the plugin (used for diagnostics) wims-moodle-4.0.orig/mod/assignment/type/wims/lang/0000755000175000017500000000000012124335542022557 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/lang/en/0000755000175000017500000000000012124336130023153 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/lang/en/assignment_wims.php0000644000175000017500000000466412124336130027105 0ustar georgeskgeorgeskPlease consider importing some previously submitted worksheets.
See below'; $string['create_an_exam'] = 'There are still no exam session defined. Please manage the contents of this miniclass.'; $string['exam'] = 'Exam session'; $string['exam_meanscore'] = 'Overall score for the exam:'; $string['examFeedback'] = 'List of exam sessions'; $string['getcsv'] = 'CSV file'; $string['getexamsource'] = 'Source'; $string['getsheetsource'] = 'Source'; $string['hello_designer'] = 'Exercise type'; $string['import_selected_sheets'] = 'Import the selected sheets'; $string['importableSheets'] = 'List of previously submitted worksheets (for imports)'; $string['listofsheets'] = 'Worksheets available in this Wims miniclass'; $string['makeasheet'] = 'There is still no worksheet. Please use the button above to create at least one sheet.'; $string['maybewimsbusy'] = 'Sometimes, Wims is busy during a while, to do some daily housekeeping. You may try creating the Wims miniclass a little later.'; $string['meansheet'] = 'Average score:'; $string['no_exam_yet'] = 'The teacher has not yet defined an exam. Please check later.'; $string['nosheetsyet'] = 'The teacher has not yet defined a worksheet. Please check later.'; $string['retry'] = 'Try again'; $string['score_is'] = 'score: '; $string['sessions_done'] = 'sessions have been finished.'; $string['sorrynoauthuser'] = 'Sorry, the authentification failed.'; $string['sorrynothing'] = 'Sorry, no contents were found for this assignment.'; $string['sorrynotopen'] = 'Sorry, you cannot enter because this assignment is not open.'; $string['user_data'] = 'User\'s data'; $string['defaultexercise'] = 'Ordinary worksheet'; ?> wims-moodle-4.0.orig/mod/assignment/type/wims/lang/fr/0000755000175000017500000000000012124336146023167 5ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/lang/fr/assignment_wims.php0000644000175000017500000000532412124336146027113 0ustar georgeskgeorgeskVeuillez importer quelques feuilles de travail précédemment publiées.
Voir ci-dessous'; $string['create_an_exam'] = 'Il n\'y a pas encore de session d\'examen. Veuillez gérer le contenu de la mini-classe Wims.'; $string['defaultexercise'] = 'Feuille de travail ordinaire'; $string['exam'] = 'Session d\'examen'; $string['exam_meanscore'] = 'Note moyenne de l\'examen :'; $string['examFeedback'] = 'Liste de sessions d\'examen'; $string['getcsv'] = 'fichier CSV'; $string['getexamsource'] = 'Source'; $string['getsheetsource'] = 'Source'; $string['hello_designer'] = 'Type d\'exercice'; $string['import_selected_sheets'] = 'Importer les feuilles de travail sélectionnées'; $string['importableSheets'] = 'Liste des feuilles de travail précédemment publiées (pour importation)'; $string['listofsheets'] = 'Feuilles de travail disponibles dans cette mini-classe Wims'; $string['makeasheet'] = 'Il n\'y a pas encore de feuille de travail. Veuillez utiliser le bouton ci-dessous et créer au moins une feuille de travail.'; $string['maybewimsbusy'] = 'De temps en temps Wims reste occupé pendant un moment, par exemple pour une maintenance journalière. Vous pouvez réessayer de créer la mini-classe Wims un peu plus tard.'; $string['meansheet'] = 'Note moyenne :'; $string['no_exam_yet'] = 'Aucun examen n\'est encore publié. Revenez plus tard.'; $string['nosheetsyet'] = 'Aucune feuille d\'exercices n\'a encore été publiée. Revenez plus tard.'; $string['retry'] = 'Réessayer'; $string['score_is'] = 'note : '; $string['sessions_done'] = 'sessions ont été terminées.'; $string['sorrynoauthuser'] = 'Désolé, l\'authentification a échoué'; $string['sorrynothing'] = 'Désolé, il n\'y a pas ecore de contenu pour ce devoir'; $string['sorrynotopen'] = 'Désolé, vous ne pouvez pas entrer parce que ce devoir n\'est pas encore ouvert.'; $string['user_data'] = 'Données utilisateur'; ?> wims-moodle-4.0.orig/mod/assignment/type/wims/closing.php0000644000175000017500000000125512124330464024006 0ustar georgeskgeorgesk
wims-moodle-4.0.orig/mod/assignment/type/wims/all.php0000644000175000017500000001147012123061466023122 0ustar georgeskgeorgeskdirroot}/mod/assignment/lib.php"); require_once($CFG->libdir.'/gradelib.php'); require_once('assignment.class.php'); // get parameter $id = required_param('id', PARAM_INT); // course if (!$course = $DB->get_record('course', array('id'=>$id))) { print_error('invalidcourse'); } $PAGE->set_url('/mod/assignment/type/wims/all.php', array('id'=>$id)); require_course_login($course); // check for view capability at course level $context = get_context_instance(CONTEXT_COURSE,$course->id); require_capability('mod/assignment:view',$context); // various strings $str = new stdClass; $str->assignments = get_string("modulenameplural", "assignment"); $str->duedate = get_string('duedate','assignment'); $str->duedateno = get_string('duedateno','assignment'); $str->editmysubmission = get_string('editmysubmission','assignment'); $str->emptysubmission = get_string('emptysubmission','assignment'); $str->noassignments = get_string('noassignments','assignment'); $str->wimstext = get_string('typewims','assignment'); $str->submitted = get_string('submitted','assignment'); $PAGE->navbar->add($str->assignments, new moodle_url('/mod/assignment/index.php', array('id'=>$id))); $PAGE->navbar->add($str->wimstext); // get all the assignments in the course $assignments = get_all_instances_in_course('assignment',$course, $USER->id ); $sections = get_all_sections($course->id); // array to hold display data $views = array(); // loop over assignments finding online ones foreach( $assignments as $assignment ) { // only interested in online assignments if ($assignment->assignmenttype != 'wims') { continue; } // check we are allowed to view this $context = get_context_instance(CONTEXT_MODULE, $assignment->coursemodule); if (!has_capability('mod/assignment:view',$context)) { continue; } // create instance of assignment class to get // submitted assignments $onlineinstance = new assignment_wims( $assignment->coursemodule ); $submitted = $onlineinstance->submittedlink(true); $submission = $onlineinstance->get_submission(); // submission (if there is one) if (empty($submission)) { $submissiontext = $str->emptysubmission; if (!empty($assignment->timedue)) { $submissiondate = "{$str->duedate} ".userdate( $assignment->timedue ); } else { $submissiondate = $str->duedateno; } } else { $submissiontext = format_text( $submission->data1, $submission->data2 ); $submissiondate = "{$str->submitted} ".userdate( $submission->timemodified ); } // edit link $editlink = "wwwroot}/mod/assignment/view.php?". "id={$assignment->coursemodule}&edit=1\">{$str->editmysubmission}"; // format options for description $formatoptions = new stdClass; $formatoptions->noclean = true; // object to hold display data for assignment $view = new stdClass; // start to build view object $view->section = get_section_name($course, $sections[$assignment->section]); $view->name = $assignment->name; $view->submitted = $submitted; $view->description = format_module_intro('assignment', $assignment, $assignment->coursemodule); $view->editlink = $editlink; $view->submissiontext = $submissiontext; $view->submissiondate = $submissiondate; $view->cm = $assignment->coursemodule; $views[] = $view; } //=================== // DISPLAY //=================== $PAGE->set_title($str->assignments); echo $OUTPUT->header(); foreach ($views as $view) { echo $OUTPUT->container_start('clearfix generalbox assignment'); // info bit echo $OUTPUT->heading("$view->section - $view->name", 3, 'mdl-left'); if (!empty($view->submitted)) { echo ''; } // description part echo '
'.$view->description.'
'; //submission part echo $OUTPUT->container_start('generalbox submission'); echo '
'.$view->submissiondate.'
'; echo "

$view->submissiontext

\n"; echo "

$view->editlink

\n"; echo $OUTPUT->container_end(); // feedback part $onlineinstance = new assignment_wims( $view->cm ); $onlineinstance->view_feedback(); echo $OUTPUT->container_end(); } echo $OUTPUT->footer(); wims-moodle-4.0.orig/mod/assignment/type/wims/getcsv.php0000644000175000017500000000062312122035666023645 0ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/getsheetsource.php0000644000175000017500000000063112122035666025402 0ustar georgeskgeorgeskwims-moodle-4.0.orig/mod/assignment/type/wims/assignment.class.php0000644000175000017500000011317612124336114025630 0ustar georgeskgeorgesklibdir.'/formslib.php'); require_once($CFG->libdir . '/portfoliolib.php'); require_once($CFG->dirroot . '/mod/assignment/lib.php'); require_once($CFG->libdir . '/filelib.php'); require_once("wimsclass.php"); require_once("wims_raw.php"); require_once("wimsconf.php"); /** * Wims class (create a link between moodle and wims) * */ class assignment_wims extends assignment_base { var $filearea = 'submission'; function assignment_wims($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL) { parent::assignment_base($cmid, $assignment, $cm, $course); $this->type = 'wims'; $this->wimsClassId=$this->createWimsClass(); } function createWimsClass(){ global $DB, $CFG; if(is_object($this->cm)){ if ($this->cm->id){ if (! $this->assignment->var2 || intval($this->assignment->var2) <= 0){ // the wims virtual class does not yet exist. $wc=new wc_data($this->assignment, $CFG->protocol, $CFG->passwims); $this->initJobRaw(); // at this point, a request is sent to the wims server // if $_GETS['retry'] == '1', that means that such a request has // been sent already; otherwise it is the first attempt. $lines=$this->jr->addclass($wc,$wc->description); if ($this->jr->ok){ // at this point, a class has been created by WIMS successfully; // however the job addclass is not supposed to return the code of // the created class. So we must get it now. $this->assignment->var2=intval($lines[1]); // update_record("assignment",$this->assignment); $DB->update_record("assignment",$this->assignment); } else { // the class has not been added !! $this->assignment->var2="-1"; // update_record("assignment",$this->assignment); $DB->update_record("assignment",$this->assignment); } } } return $this->assignment->var2; } } function initJobRaw(){ global $CFG; $this->jr=new job_raw($CFG->wimshost, $CFG->wimsroot, $CFG->protocol, $CFG->passwims); return $this->jr; } /** * returns the status of the user: True if she is a teacher. */ function isTeacher(){ global $USER; $context = get_context_instance(CONTEXT_MODULE, $this->cm->id); return has_capability('mod/assignment:grade',$context); } /** * Displays a button to enter the Wims miniclass * if the user does not exist yet in the miniclass, she is * created on the fly. */ function miniClassEnterButton(){ global $USER; global $CFG; if ($this->isTeacher()){ $login="supervisor"; $prompt=get_string("adminsheet","assignment_wims"); } else { $prompt=get_string("apply","assignment_wims"); $this->ensureUserExists(); $login=$USER->username; } $lines=$this->jr->authuser($this->assignment->var2, rclass($this->assignment), $login); $this->getSession($login); if ($this->session){ $result=$this->wimsButton($prompt,array("session"=>"$this->session","lang"=>$this->wimsLang())); } else { $result=get_string("sorrynoauthuser","assignment_wims"); } return $result; } /** * Returns the links for the wims class * @param var1 integer, defaults to 0 * if $this->assignment->var1 is 0, it is an ordinary worksheet * if $this->assignment->var1 is 1, it is an exam. */ function wims_links(){ $this->initJobRaw(); if ($this->assignment->var1==0){ return $this->miniClassEnterButton() . $this->miniClassSheetFeedback(). $this->miniClassGradesOrAdmin(); } else { return $this->miniClassEnterButton() . $this->miniClassExamFeedback() . $this->importableSheets(); } } function view() { global $OUTPUT, $CFG, $USER, $PAGE; $edit = optional_param('edit', 0, PARAM_BOOL); $saved = optional_param('saved', 0, PARAM_BOOL); $context = get_context_instance(CONTEXT_MODULE, $this->cm->id); require_capability('mod/assignment:view', $context); $submission = $this->get_submission($USER->id, false); //Guest can not submit nor edit an assignment (bug: 4604) if (!is_enrolled($this->context, $USER, 'mod/assignment:submit')) { $editable = false; } else { $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked); } $editmode = ($editable and $edit); if ($editmode) { // prepare form and process submitted data $editoroptions = array( 'noclean' => false, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $this->course->maxbytes, 'context' => $this->context ); $data = new stdClass(); $data->id = $this->cm->id; $data->edit = 1; if ($submission) { $data->sid = $submission->id; $data->text = $submission->data1; $data->textformat = $submission->data2; } else { $data->sid = NULL; $data->text = ''; $data->textformat = NULL; } $data = file_prepare_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $data->sid); $mform = new mod_assignment_wims_edit_form(null, array($data, $editoroptions)); if ($mform->is_cancelled()) { redirect($PAGE->url); } if ($data = $mform->get_data()) { $submission = $this->get_submission($USER->id, true); //create the submission if needed & its id $data = file_postupdate_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $submission->id); $submission = $this->update_submission($data); //TODO fix log actions - needs db upgrade add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id); $this->email_teachers($submission); //redirect to get updated submission date and word count redirect(new moodle_url($PAGE->url, array('saved'=>1))); } } add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id); /// print header, etc. and display form if needed if ($editmode) { $this->view_header(get_string('editmysubmission', 'assignment')); } else { $this->view_header(); } $this->view_intro(); $this->view_dates(); if (has_capability('mod/assignment:submit', $context) || has_capability('mod/assignment:grade', $context)) { echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter', 'wims'); if ($this->wimsClassId > 0){ // A wims class exists. Let us decribe it and make a link for it if ($this->isTeacher()||$this->isopen()){ // the links for the class will always be visible for a teacher print $this->wims_links(); } else { print(get_string("sorrynotopen","assignment_wims")); } } else { print(get_string("sorrynothing","assignment_wims")); print($this->reTryButton()); } echo $OUTPUT->box_end(); } $this->view_feedback(); $this->view_footer(); } /** * Ensures that the user $USER exists in the Wims miniclass */ function ensureUserExists(){ global $USER; $login=$USER->username; $lines=$this->jr->getuser($this->assignment->var2, rclass($this->assignment),$login); $tmp = $lines[1]; if (!$this->jr->ok and $lines[1]=="bad user (empty quser or bad chars detected)"){ $firstname=wimsIconv($USER->firstname); $lastname=wimsIconv($USER->lastname); $lines=$this->jr->adduser($this->assignment->var2, rclass($this->assignment), $firstname,$lastname,$login); } } /** * defines $this->$session with the name of an authenticated session * for user $login in the Wims miniclass */ function getSession($login){ $lines=$this->jr->authuser($this->assignment->var2, rclass($this->assignment), $login); if ($this->jr->ok) { $this->session=$lines[1]; } else { $this->session=""; } } function wimsButton($prompt,$dict){ global $CFG; global $USER; $backurl=$CFG->wwwroot."/mod/assignment/view.php?id=".$this->cm->id; $closemsg=wimsIconv(get_string("closeandupdate","assignment_wims")); $url=$CFG->wimsRemoteUrl."/".$CFG->wimsroot."/wims.cgi?"; $amp=""; foreach($dict as $k=>$v){ $url.=$amp."$k=$v"; $amp="&"; } $tfurl=$CFG->wwwroot."/mod/assignment/type/wims/twoframes.php?url=".urlencode($url)."&backurl=".urlencode($backurl)."&closemsg=".urlencode($closemsg); $result="\n"; return $result; } /** * returns the lang for the Wims miniclass */ function wimsLang(){ global $USER; $lang=$USER->lang; if (strlen($lang) == 0) $lang="en"; return substr($lang,0,2); } /** * displays a column of buttons to enter directly existing worksheets * if there is no worksheet, gives a hint about their future creation * for the supervisor, gives also links to get the sheet's contents */ function miniClassSheetFeedback(){ $result=""; $lines=$this->jr->getcsv($this->assignment->var2, rclass($this->assignment), "sheets"); $this->meansheet=0; if ($this->jr->ok){ $sheets=explode(",",$lines[0]); if ($sheets[0] != "ERROR"){ $sheetnames=explode(",",$lines[1]); $i=0; $this->totalsheet=0; $this->countsheet=0; $result.="
".get_string("listofsheets","assignment_wims")."
\n"; $result.="\n"; foreach($sheets as $s) { $sn=$sheetnames[$i]; $i++; $si="".$i; $result.=$this->miniClassSheetFeedbackLine($sn,$si); } } else { $result.=$this->hintNewSheet(); } $result.="
\n"; if (isset($this->countsheet) && $this->countsheet!=0){ $this->meansheet=$this->totalsheet/$this->countsheet;}else{ $this->meansheet = 0; } } return $result; } /** * displays one button to enter directly an existing worksheet * for the supervisor, gives also links to get the sheet's contents */ function miniClassSheetFeedbackLine($sn,$si){ global $CFG,$USER; $result=" "; if($this->isTeacher()){ $result.=$this->wimsButton(wimsIconv($sn,"back"),array("session"=>"$this->session","lang"=>$this->wimsLang(),"module"=>"adm/class/sheet","sheet"=>"$si")); $result.=""; $url=urlencode($this->jr->url("getclassfile", "qclass=".$this->assignment->var2. "&rclass=".urlencode(rclass($this->assignment)). "&option=sheets/.sheet".$si )); $result.="". get_string("getsheetsource","assignment_wims"). ""; // get the CSV of the scores. $url=urlencode($this->jr->url("getcsv", "qclass=".$this->assignment->var2. "&rclass=".urlencode(rclass($this->assignment)). "&option=lastname,name,sheet$si" )); $result.="  ". get_string("getcsv","assignment_wims"). " ($si)"; } else { $result.=$this->wimsButton(wimsIconv($sn,"back"),array("session"=>"$this->session","lang"=>$this->wimsLang(),"module"=>"adm/sheet","sh"=>"$si")); $result.=""; $login=$USER->username; $lines1=$this->jr->getscore($this->assignment->var2, rclass($this->assignment), $login, $si); if ($this->jr->ok){ $avg=array(); $weight=array(); $readAvg=0; $readWeight=0; foreach($lines1 as $l){ if(substr($l,0,14)=="scoreaverages="){ $avg=explode(" ",substr($l,14,1024)); // got the first line of averages // but this not necessary the relevant line // so take in account the number $si if ($si>1) $readAvg=$si; }else{ if ($readAvg>0){ $readAvg-=1; if ($readAvg==1){ // we read $si lines, this is the good one to take in account $avg=explode(" ",$l); $readAvg=0; } } } if(substr($l,0,8)=="weights="){ $weight=explode(" ",substr($l,8,1024)); // got the first line of weights // but this not necessary the relevant line // so take in account the number $si if ($si>1) $readWeight=$si; }else{ if ($readWeight>0){ $readWeight-=1; if ($readWeight==1){ // we read $si lines, this is the good one to take in account $weight=explode(" ",$l); $readWeight=0; } } } } $total=0; $max=0; $i=0; foreach($weight as $w){ // we should get rid of elements containing "\\" if ($w!="\\"){ $max+=$w; $total+=$avg[$i]*$w; $i++; } } $score=$total/$max; //now $score is a mark in a scale ranging fro 0 to 10 $score*=$this->assignment->grade/10; //now $score is a mark in a scale ranging //from 0 to =$this->assignment->grade } else { $score=-1000; // we should trigger an error message! } $this->countsheet+=1; $this->totalsheet+=$score; $result.=get_string("score_is","assignment_wims").$this->roundedGrade($score).""; } $result.="\n"; return $result; } /** * Displays a rounded grade with the maximum visible */ function roundedGrade($grade){ return (round(100*$grade)/100)." / ".$this->assignment->grade; } /** * Displays the grades and updates them in Moodle for a student * Adds a button to enter the miniclass in admin mode for the teacher */ function miniClassGradesOrAdmin(){ global $USER; global $DB; global $CGF; $result=""; if (!$this->isTeacher()){ // it's a student $result.=get_string("meansheet","assignment_wims")." ".$this->roundedGrade($this->meansheet)."
\n"; //if($sub=get_record("assignment_submissions","assignment",$this->assignment->id,"userid",$USER->id)){ if($sub=$DB->get_record("assignment_submissions",array("assignment"=>$this->assignment->id,"userid"=>$USER->id))){ if($this->meansheet != round($sub->grade)){ $sub->grade=round($this->meansheet); $sub->timemodified=time(); $sub->timemarked=time(); $sub->submissioncomment=get_string("automatic_score","assignment_wims"); $DB->update_record("assignment_submissions",$sub); } } else { $sub=$this->prepare_new_submission($USER->id); $sub->grade=round($this->meansheet); $sub->timemarked=time(); $sub->submissioncomment=get_string("automatic_score","assignment_wims"); $id=$DB->insert_record("assignment_submissions",$sub); } } else { // it's a teacher $result.=$this->wimsButton(get_string("adminclass","assignment_wims"),array('session'=>$this->session,'lang'=>$this->wimsLang(),'module'=>'adm/class/config')); } return $result; } /** * makes easier the importation of wims sheets published in the past */ function importableSheets(){ global $CFG; global $DB; if (! $this->isTeacher()) return ""; // display importable sheets only for the teachers. $course= $DB->get_record("course", array("id"=>$this->cm->course)); //require_course_login($course); error moodle 2 require_login(); // make up a list of our own Wims worksheets $ownsheets=$this->mySheets(); $ownMD5sums=array(); foreach($ownsheets as $ownsh){ $ownMD5sums[]=md5($ownsh->contents($this->jr)); } if (!$cms = get_coursemodules_in_course('assignment', $course->id, 'm.assignmenttype, m.timeavailable, m.var1,m.var2')) { notice(get_string('noassignments', 'assignment'), "../../course/view.php?id=$course->id"); die; } // now $cms contains all assignments for this course. $result="
\n"; foreach ($cms as $c){ if ($c->assignmenttype=="wims" && $c->timeavailable < $this->assignment->timeavailable && $c->var1==0){ // we select assignments of type wims + ordinary worksheet // which have been made available *before* this exam. $sheets=$this->listSheets($c); if (count($sheets)>0){ $result.="\n"; foreach($sheets as $sh){ $url=$sh->addsheetToUrl($this,$ownMD5sums); // TODO: the sheets should be added with their respective titles if ($url=="") { $importLink=get_string("already_imported","assignment_wims"); } else { $importLink=" ".get_string("add_this_sheet","assignment_wims"); } $result.="\n"; } $result.="
".$c->name."
".$sh->title." : $importLink
\n"; $result.=""; $result.="\n"; } } } return "

".get_string("importableSheets","assignment_wims")."

\n".$result; } /** * lists the wims sheets contained in a course module * @return a table of quintuples (index,title, status, rclass, qclass) * @param cm a course module object, which must be augmented * with a member var2 which musr contain the value of the qclass */ function listSheets($cm){ $this->initJobRaw(); $qclass=$cm->var2; $rclass=rclassFromCourseAndModule($this->course,$cm); $lines=$this->jr->listsheets($qclass,$rclass); $result=array(); if ($this->jr->ok){ foreach ($lines as $l){ if(substr($l,0,6)=="count="){ $count=1*substr($l,6,255); } if(substr($l,0,10)=="titlelist="){ $titlelist="x".substr($l,10,2048); $titlelist=explode(":",$titlelist); } } for($i=0;$i<$count;$i++){ $index=1*substr($titlelist[2*$i],1,255); $title=$titlelist[2*$i+1]; $status=1*substr($titlelist[2*$i+2],0,1); $ws = new workSheet($index,$title,$status,$rclass,$qclass); $result[]=$ws; } } return $result; } /** * returns the sheets owned by this assignment of type wims */ function mySheets(){ $this->cm->var2=$this->assignment->var2; // copies the value of qclass return $this->listSheets($this->cm); } function hintNewSheet(){ if ($this->isTeacher()){ $result=get_string("makeasheet","assignment_wims"); } else { $result=get_string("nosheetsyet","assignment_wims"); } return $result; } /** * @return a list of exams */ function exams(){ $result=array(); $lines=$this->jr->getcsv($this->assignment->var2, rclass($this->assignment), "exams"); if($lines[0]=="ERROR") { return $result; } else { $titles=$lines[1]; $l=strlen($titles); $titles=substr($titles,1,$l-2); $titles=explode('","',$titles); $indices=explode(",",$lines[0]); $qclass=$this->assignment->var2; $rclass=rclassFromCourseAndModule($this->course,$this->cm); for($i=0; $iexams()){ $feedback.="\n"; foreach ($exams as $e){ if($this->isTeacher()){ $feedback.="\n"; } else { // TODO : create the buttons for a student !!! $feedback.=""; } } $feedback.="
"; $feedback.=$this->wimsButton($e->title,array("session"=>"$this->session","lang"=>$this->wimsLang(),"module"=>"adm/class/exam","exam"=>$e->i)); $feedback.=""; $url=urlencode($this->jr->url("getclassfile", "qclass=".$e->qclass. "&rclass=".$e->rclassEnc. "&option=exams/.exam".$e->i )); $feedback.="". get_string("getexamsource","assignment_wims"). ""; $feedback.="
"; $feedback.=$this->wimsButton($e->title,array("session"=>"$this->session","lang"=>$this->wimsLang(),"module"=>"adm/class/exam","job"=>"student","exam"=>$e->i)); $feedback.=""; $login=$USER->username; $lines1=$this->jr->getscore($e->qclass,$e->rclass,$login,$e->i); $examBegin=-1; foreach($lines1 as $l){ if(substr($l,0,11)=="examscores="){ $examBegin=0; $l=substr($l,11,1024); $scores=explode(" ",$l); } if($examBegin>=0){ if($l==""){ $examBegin=-1; } else { // take in account the sessions left if($examBegin==$e->i){ // it is the relevant line for this exam $sessionData=explode(" ",$l); $maxSession=1*$sessionData[0]; $doneSession=1*$sessionData[1]; } $examBegin++; } } } $score=$scores[$e->i - 1]*$this->assignment->grade/10; $total+=$score; $n++; $feedback.=get_string("score_is","assignment_wims").$this->roundedGrade($score); $feedback.=""; $feedback.=" ... $doneSession/$maxSession ".get_string("sessions_done","assignment_wims"); $feedback.="
"; // now we shall submit the mean score if we are a student if (! $this->isTeacher()){ $mean=$total/$n; $feedback.= get_string("exam_meanscore","assignment_wims")." ".$this->roundedGrade($mean)."
\n"; if($sub=$DB->get_record("assignment_submissions",array("assignment"=>$this->assignment->id,"userid"=>$USER->id))){ if(round($mean) != $sub->grade){ $sub->grade=round($mean); $sub->timemodified=time(); $sub->timemarked=time(); $sub->submissioncomment=get_string("automatic_score","assignment_wims"); $DB->update_record("assignment_submissions",$sub); } } else { $sub=$this->prepare_new_submission($USER->id); $sub->grade=round($mean); $sub->timemarked=time(); $sub->submissioncomment=get_string("automatic_score","assignment_wims"); $id=$DB->insert_record("assignment_submissions",$sub); } } } else { if($this->isTeacher()){ $feedback=get_string("create_an_exam","assignment_wims"); if (! $this->mySheets()){ $feedback.="
".get_string("consider_imports","assignment_wims")."
"; } } else { $feedback=get_string("no_exam_yet","assignment_wims"); } } return "

".get_string("examFeedback","assignment_wims")."

\n$feedback"; } /* * Display the assignment dates */ function view_dates() { global $USER, $CFG, $OUTPUT; if (!$this->assignment->timeavailable && !$this->assignment->timedue) { return; } echo $OUTPUT->box_start('generalbox boxaligncenter', 'dates'); echo ''; if ($this->assignment->timeavailable) { echo ''; echo ' '; } if ($this->assignment->timedue) { echo ''; echo ' '; } $submission = $this->get_submission($USER->id); if ($submission) { echo ''; echo ' '; } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')'; } } echo '
'.get_string('availabledate','assignment').':'.userdate($this->assignment->timeavailable).'
'.get_string('duedate','assignment').':'.userdate($this->assignment->timedue).'
'.get_string('lastedited').':'.userdate($submission->timemodified); /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')
'; echo $OUTPUT->box_end(); } function update_submission($data) { global $CFG, $USER, $DB; $submission = $this->get_submission($USER->id, true); $update = new stdClass(); $update->id = $submission->id; $update->data1 = $data->text; $update->data2 = $data->textformat; $update->timemodified = time(); $DB->update_record('assignment_submissions', $update); $submission = $this->get_submission($USER->id); $this->update_grade($submission); return $submission; } function print_student_answer($userid, $return=false){ global $OUTPUT; if (!$submission = $this->get_submission($userid)) { return ''; } $link = new moodle_url("/mod/assignment/type/wims/file.php?id={$this->cm->id}&userid={$submission->userid}"); $action = new popup_action('click', $link, 'file'.$userid, array('height' => 450, 'width' => 580)); $popup = $OUTPUT->action_link($link, shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15), $action, array('title'=>get_string('submission', 'assignment'))); $output = '
'./*. 'html'. $popup .*/ '
'; return $output; } function print_user_files($userid, $return=false) { global $OUTPUT, $CFG; if (!$submission = $this->get_submission($userid)) { return ''; } $link = new moodle_url("/mod/assignment/type/wims/file.php?id={$this->cm->id}&userid={$submission->userid}"); $action = new popup_action('click', $link, 'file'.$userid, array('height' => 450, 'width' => 580)); $popup = $OUTPUT->action_link($link, get_string('popupinnewwindow','assignment'), $action, array('title'=>get_string('submission', 'assignment'))); $output = '
'./* 'html'. $popup .*/ '
'; $wordcount = '

'. $popup . ' '; /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { $wordcount .= '('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')'; } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { $wordcount .= '('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')'; } $wordcount .= '

'; $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id); return $wordcount . format_text($text, $submission->data2, array('overflowdiv'=>true)); } function preprocess_submission(&$submission) { if ($this->assignment->var1 && empty($submission->submissioncomment)) { // comment inline if ($this->usehtmleditor) { // Convert to html, clean & copy student data to teacher $submission->submissioncomment = format_text($submission->data1, $submission->data2); $submission->format = FORMAT_HTML; } else { // Copy student data to teacher $submission->submissioncomment = $submission->data1; $submission->format = $submission->data2; } } } function setup_elements(&$mform) { global $CFG, $COURSE; /* OLD CODE $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes')); $mform->addElement('select', 'resubmit', get_string('allowresubmit', 'assignment'), $ynoptions); $mform->addHelpButton('resubmit', 'allowresubmit', 'assignment'); $mform->setDefault('resubmit', 0); $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions); $mform->addHelpButton('emailteachers', 'emailteachers', 'assignment'); $mform->setDefault('emailteachers', 0); $mform->addElement('select', 'var1', get_string('commentinline', 'assignment'), $ynoptions); $mform->addHelpButton('var1', 'commentinline', 'assignment'); $mform->setDefault('var1', 0); */ $wimsmode=array( 0 => get_string('defaultexercise', 'assignment_wims'), 1 => get_string('exam', 'assignment_wims')); $mform->addElement('select', 'var1', get_string('type_exe','assignment_wims'), $wimsmode); $mform->addHelpButton('var1','type_exe', 'assignment_wims'); $mform->setDefault('var1', 0); } function portfolio_exportable() { return true; } function portfolio_load_data($caller) { $submission = $this->get_submission(); $fs = get_file_storage(); if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) { $caller->set('multifiles', $files); } } function portfolio_get_sha1($caller) { $submission = $this->get_submission(); $textsha1 = sha1(format_text($submission->data1, $submission->data2)); $filesha1 = ''; try { $filesha1 = $caller->get_sha1_file(); } catch (portfolio_caller_exception $e) {} // no files return sha1($textsha1 . $filesha1); } function portfolio_prepare_package($exporter, $user) { $submission = $this->get_submission($user->id); $options = portfolio_format_text_options(); $html = format_text($submission->data1, $submission->data2, $options); $html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', $this->filearea, $submission->id, $exporter->get('format')); if (in_array($exporter->get('formatclass'), array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_RICHHTML))) { if ($files = $exporter->get('caller')->get('multifiles')) { foreach ($files as $f) { $exporter->copy_existing_file($f); } } return $exporter->write_new_file($html, 'assignment.html', !empty($files)); } else if ($exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) { $leapwriter = $exporter->get('format')->leap2a_writer(); $entry = new portfolio_format_leap2a_entry('assignmentwims' . $this->assignment->id, $this->assignment->name, 'resource', $html); $entry->add_category('web', 'resource_type'); $entry->published = $submission->timecreated; $entry->updated = $submission->timemodified; $entry->author = $user; $leapwriter->add_entry($entry); if ($files = $exporter->get('caller')->get('multifiles')) { $leapwriter->link_files($entry, $files, 'assignmentwims' . $this->assignment->id . 'file'); foreach ($files as $f) { $exporter->copy_existing_file($f); } } $exporter->write_new_file($leapwriter->to_xml(), $exporter->get('format')->manifest_name(), true); } else { debugging('invalid format class: ' . $exporter->get('formatclass')); } } function extend_settings_navigation($node) { global $PAGE, $CFG, $USER; // get users submission if there is one $submission = $this->get_submission(); if (is_enrolled($PAGE->cm->context, $USER, 'mod/assignment:submit')) { $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked); } else { $editable = false; } // If the user has submitted something add a bit more stuff if ($submission) { // Add a view link to the settings nav $link = new moodle_url('/mod/assignment/view.php', array('id'=>$PAGE->cm->id)); $node->add(get_string('viewmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING); if (!empty($submission->timemodified)) { $submittednode = $node->add(get_string('submitted', 'assignment') . ' ' . userdate($submission->timemodified)); $submittednode->text = preg_replace('#([^,])\s#', '$1 ', $submittednode->text); $submittednode->add_class('note'); if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) { $submittednode->add_class('early'); } else { $submittednode->add_class('late'); } } } if (!$submission || $editable) { // If this assignment is editable once submitted add an edit link to the settings nav $link = new moodle_url('/mod/assignment/view.php', array('id'=>$PAGE->cm->id, 'edit'=>1, 'sesskey'=>sesskey())); $node->add(get_string('editmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING); } } public function send_file($filearea, $args) { global $USER; require_capability('mod/assignment:view', $this->context); $fullpath = "/{$this->context->id}/mod_assignment/$filearea/".implode('/', $args); $fs = get_file_storage(); if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { send_file_not_found(); } if (($USER->id != $file->get_userid()) && !has_capability('mod/assignment:grade', $this->context)) { send_file_not_found(); } session_get_instance()->write_close(); // unlock session during fileserving send_stored_file($file, 60*60, 0, true); } /** * creates a zip of all assignment submissions and sends a zip to the browser */ public function download_submissions() { global $CFG, $DB; raise_memory_limit(MEMORY_EXTRA); $submissions = $this->get_submissions('',''); if (empty($submissions)) { print_error('errornosubmissions', 'assignment'); } $filesforzipping = array(); //NOTE: do not create any stuff in temp directories, we now support unicode file names and that would not work, sorry //online assignment can use html $filextn=".html"; $groupmode = groups_get_activity_groupmode($this->cm); $groupid = 0; // All users $groupname = ''; if ($groupmode) { $groupid = groups_get_activity_group($this->cm, true); $groupname = groups_get_group_name($groupid).'-'; } $filename = str_replace(' ', '_', clean_filename($this->course->shortname.'-'.$this->assignment->name.'-'.$groupname.$this->assignment->id.".zip")); //name of new zip file. foreach ($submissions as $submission) { $a_userid = $submission->userid; //get userid if ((groups_is_member($groupid,$a_userid)or !$groupmode or !$groupid)) { $a_assignid = $submission->assignment; //get name of this assignment for use in the file names. $a_user = $DB->get_record("user", array("id"=>$a_userid),'id,username,firstname,lastname'); //get user firstname/lastname $submissioncontent = "". format_text($submission->data1, $submission->data2). ""; //fetched from database //get file name.html $fileforzipname = clean_filename(fullname($a_user) . "_" .$a_userid.$filextn); $filesforzipping[$fileforzipname] = array($submissioncontent); } } //end of foreach if ($zipfile = assignment_pack_files($filesforzipping)) { send_temp_file($zipfile, $filename); //send file and delete after sending. } } } class mod_assignment_wims_edit_form extends moodleform { function definition() { $mform = $this->_form; list($data, $editoroptions) = $this->_customdata; // visible elements $mform->addElement('editor', 'text_editor', get_string('submission', 'assignment'), null, $editoroptions); $mform->setType('text_editor', PARAM_RAW); // to be cleaned before display $mform->addRule('text_editor', get_string('required'), 'required', null, 'client'); // hidden params $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'edit'); $mform->setType('edit', PARAM_INT); // buttons $this->add_action_buttons(); $this->set_data($data); } } wims-moodle-4.0.orig/mod/assignment/type/wims/twoframes.php0000644000175000017500000000210612124330656024356 0ustar georgeskgeorgesk$v){ $k=$v; } ?> Wims in Moodle <body> <p>Il vous faut un navigateur supportant les frames</p> </body>