Ejemplo n.º 1
0
 /**
  * Return HTML form to allow prerequisites selection
  * @todo use FormValidator
  * @param	integer Item ID
  * @return	string	HTML form
  */
 public function display_item_prerequisites_form($item_id)
 {
     $course_id = api_get_course_int_id();
     $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     $item_id = intval($item_id);
     /* Current prerequisite */
     $sql = "SELECT * FROM {$tbl_lp_item}\n                WHERE c_id = {$course_id} AND id = " . $item_id;
     $result = Database::query($sql);
     $row = Database::fetch_array($result);
     $prerequisiteId = $row['prerequisite'];
     $return = '<legend>';
     $return .= get_lang('AddEditPrerequisites');
     $return .= '</legend>';
     $return .= '<form method="POST">';
     $return .= '<table class="data_table">';
     $return .= '<tr>';
     $return .= '<th height="24">' . get_lang('LearnpathPrerequisites') . '</th>';
     $return .= '<th width="70" >' . get_lang('Minimum') . '</th>';
     $return .= '<th width="70">' . get_lang('Maximum') . '</th>';
     $return .= '</tr>';
     // Adding the none option to the prerequisites see http://www.chamilo.org/es/node/146
     $return .= '<tr >';
     $return .= '<td colspan="3" class="radio">';
     $return .= '<input checked="checked" id="idNone" name="prerequisites"  style="margin-left:0px; margin-right:10px;" type="radio" />';
     $return .= '<label for="idNone">' . get_lang('None') . '</label>';
     $return .= '</tr>';
     $sql = "SELECT * FROM {$tbl_lp_item}\n                WHERE c_id = {$course_id} AND lp_id = " . $this->lp_id;
     $result = Database::query($sql);
     $arrLP = array();
     $selectedMinScore = array();
     $selectedMaxScore = array();
     while ($row = Database::fetch_array($result)) {
         if ($row['id'] == $item_id) {
             $selectedMinScore[$row['prerequisite']] = $row['prerequisite_min_score'];
             $selectedMaxScore[$row['prerequisite']] = $row['prerequisite_max_score'];
         }
         $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], 'ref' => $row['ref'], 'description' => $row['description'], 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite'], 'next_item_id' => $row['next_item_id'], 'display_order' => $row['display_order'], 'prerequisite_min_score' => $row['prerequisite_min_score'], 'prerequisite_max_score' => $row['prerequisite_max_score']);
     }
     $this->tree_array($arrLP);
     $arrLP = isset($this->arrMenu) ? $this->arrMenu : null;
     unset($this->arrMenu);
     for ($i = 0; $i < count($arrLP); $i++) {
         $item = $arrLP[$i];
         if ($item['id'] == $item_id) {
             break;
         }
         $selectedMaxScoreValue = isset($selectedMaxScore[$item['id']]) ? $selectedMaxScore[$item['id']] : $item['max_score'];
         $selectedMinScoreValue = isset($selectedMinScore[$item['id']]) ? $selectedMinScore[$item['id']] : 0;
         $return .= '<tr>';
         $return .= '<td class="radio"' . ($item['item_type'] != TOOL_QUIZ && $item['item_type'] != TOOL_HOTPOTATOES ? ' colspan="3"' : '') . '>';
         $return .= '<label for="id' . $item['id'] . '">';
         $return .= '<input' . (in_array($prerequisiteId, array($item['id'], $item['ref'])) ? ' checked="checked" ' : '') . ($item['item_type'] == 'dokeos_module' || $item['item_type'] == 'dokeos_chapter' ? ' disabled="disabled" ' : ' ') . 'id="id' . $item['id'] . '" name="prerequisites" style="margin-left:' . $item['depth'] * 10 . 'px; margin-right:10px;" type="radio" value="' . $item['id'] . '" />';
         $icon_name = str_replace(' ', '', $item['item_type']);
         if (file_exists('../img/lp_' . $icon_name . '.png')) {
             $return .= '<img alt="" src="../img/lp_' . $icon_name . '.png" style="margin-right:5px;" title="" />';
         } else {
             if (file_exists('../img/lp_' . $icon_name . '.gif')) {
                 $return .= '<img alt="" src="../img/lp_' . $icon_name . '.gif" style="margin-right:5px;" title="" />';
             } else {
                 $return .= Display::return_icon('folder_document.gif', '', array('style' => 'margin-right:5px;'));
             }
         }
         $return .= $item['title'] . '</label>';
         $return .= '</td>';
         if ($item['item_type'] == TOOL_QUIZ) {
             // lets update max_score Quiz information depending of the Quiz Advanced properties
             $tmp_obj_lp_item = new LpItem($course_id, $item['id']);
             $tmp_obj_exercice = new Exercise();
             $tmp_obj_exercice->read($tmp_obj_lp_item->path);
             $tmp_obj_lp_item->max_score = $tmp_obj_exercice->get_max_score();
             $tmp_obj_lp_item->update_in_bdd();
             $item['max_score'] = $tmp_obj_lp_item->max_score;
             $return .= '<td class="exercise">';
             $return .= '<input size="4" maxlength="3" name="min_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '" value="' . $selectedMinScoreValue . '" />';
             $return .= '</td>';
             $return .= '<td class="exercise">';
             $return .= '<input size="4" maxlength="3" name="max_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '" value="' . $selectedMaxScoreValue . '" />';
             $return .= '</td>';
         }
         if ($item['item_type'] == TOOL_HOTPOTATOES) {
             $return .= '<td class="exercise">';
             $return .= '<center><input size="4" maxlength="3" name="min_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '" value="' . $selectedMinScoreValue . '" /></center>';
             $return .= '</td>';
             $return .= '<td class="exercise"">';
             $return .= '<center><input size="4" maxlength="3" name="max_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '"  value="' . $selectedMaxScoreValue . '" /></center>';
             $return .= '</td>';
         }
         $return .= '</tr>';
     }
     $return .= '<tr>';
     $return .= '</tr>';
     $return .= '</table>';
     $return .= '<div style="padding-top:3px;">';
     $return .= '<button class="btn btn-primary" name="submit_button" type="submit">' . get_lang('ModifyPrerequisites') . '</button>';
     $return .= '</form>';
     return $return;
 }
Ejemplo n.º 2
0
 /**
  * Exclude object from result
  *
  * @param     LpItem $lpItem Object to remove from the list of results
  *
  * @return    LpItemQuery The current query, for fluid interface
  */
 public function prune($lpItem = null)
 {
     if ($lpItem) {
         $this->addUsingAlias(LpItemPeer::ID, $lpItem->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      LpItem $value A LpItem object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(LpItem $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }