Need help with assignment

Okay so, I’ve been tasked with creating a moodle-esque type page purely in php, and I’ve hit a snag that is driving me up the wall.

I’m unsure how to hide “section 0” without hiding the links within it. I’ve asked for advice and I’ve been told to make an if statement that says to hide all section headings that are less than 1. But I’m unsure how to do that.

Also, I’m meant to make a counter to count the modules under each section, but only the ones that contain modules. The counter re occurs down the page, and I’m unsure how to make it stop. I presume I could use an if statement but I’m not sure how to structure it or where to put it.

Screenshot: https://ibb.co/dHOKZ9

Here is my code:

	echo "<h1>Course: <a href=' $PAGE->url '>$course->fullname</a></h1>";
   

    
	
 
	$course = course_get_format($course)->get_course();
	
	
	
	
	for ($section = 0; $section <= $course->numsections; $section++) {
		$section;
		echo "<h3>Section $section </h3>"; 
	    if (!empty($sections[$section])) {
		   $thissection = $sections[$section];
		} else {
			continue;			
	
		}
		$counter = 0;
		
			
			
					
		
		
		
	 if (!empty($thissection->sequence)) {
			echo "<ul>";
				
			// $sectionmods becomes a list of module ids for this section
			$sectionmods = explode(",", $thissection->sequence);
			
			// Show the modules in this section as list elements
			foreach ($sectionmods as $modnumber)
		{ 
			    
			    $mod = $mods[$modnumber];
				$modulenames[$mod->modname] = get_string('modulename', $mod->modname);
				$modulename = $modulenames[$mod->modname];
				
			    echo "<li> $modulename <a href=" . $mod->get_url() . ">". $mod->name . "</a></li>";
				
				$counter = $counter + 1;
				
		}
		
			
			echo "</ul>";
		}  echo "<h5>Number of modules in section: $counter</h5>";     
	}
	
	echo "You are logged on as $USER->firstname $USER->lastname"

Sorted the counting, just need to hide section 0 now.

Sponsor our Newsletter | Privacy Policy | Terms of Service