function jclic_update_instance($jclic) { /// Given an object containing all the necessary data, /// (defined by the form in mod.html) this function /// will update an existing instance with new data. $jclic->id = $jclic->instance; $jclic->url = trim($jclic->url); if (update_record("jclic", $jclic)) { return jclic_update_gradebook(null, $jclic); } return false; }
case "multiple": foreach ($beans as $bean) { if ($bean['ID'] == 'add activity') { $jclic_activity->session_id = $bean['PARAMS']['session']; $jclic_activity->activity_id = $bean['PARAMS']['num']; $jclic_activity->activity_name = $bean['ACTIVITY']['name']; $jclic_activity->num_actions = $bean['ACTIVITY']['actions']; $jclic_activity->activity_solved = $bean['ACTIVITY']['solved'] == 'true' ? 1 : 0; $jclic_activity->score = $bean['ACTIVITY']['score']; $jclic_activity->qualification = getPrecision($bean['ACTIVITY']['minActions'], $bean['ACTIVITY']['actions'], '' . $bean['ACTIVITY']['solved'], $bean['ACTIVITY']['score']); //$jclic_activity->starttime=$bean['ACTIVITY']['start']; $jclic_activity->total_time = $bean['ACTIVITY']['time']; insert_record("jclic_activities", $jclic_activity); } } jclic_update_gradebook($jclic_activity); echo '<?xml version="1.0" encoding="UTF-8"?' . '>'; echo '<bean id="add activity">'; echo ' <param name="activity" value="' . $jclic_activity->activity_id . '"/>'; echo '</bean>'; break; default: echo '<?xml version="1.0" encoding="UTF-8"?' . '>'; echo '<bean id="' . $beans[0]['ID'] . '">'; echo ' <param name="error" value="bean not defined"/>'; echo '</bean>'; } function getPrecision($minActions, $numActions, $solved, $score) { $precision = 0; if ($minActions > 0 && $numActions > 0) {